Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/nilportugues/twig-macros-boilerplate

Twig macros as building blocks
https://github.com/nilportugues/twig-macros-boilerplate

Last synced: 19 days ago
JSON representation

Twig macros as building blocks

Awesome Lists containing this project

README

        

# Twig Building blocks

## Installation

```sh
php composer.phar install
cd example/
php -S locahost:8000 index.php
```

----------------------

## Themes

### Bootstrap 3

Macros using Twitter's Bootstrap 3.2 version.

- **macro**: `@bootstrap`
- **path**: `theme/bootstrap3`

Supported Bootstrap themes:

- **FlatUI**
- **macro**: `@flatui`
- **path**: `theme/bootstrap3_flat-ui`

#### Tabs

- **Macro**: `flat_tabs(tabs, tab_content, selected)`
- **Attributes**:
- **tabs** : Associative array `{"key" :"the name of the tab", "value": "the string to show"}`
- **tab_content** : Associative array `{"key" :"the name of the tab", "value": "HTML for the tab"}`
- **selected** : `string` with the name of the `active` tab. If none, first is selected.

```twig
{% from '@bootstrap/components/tabs/flat_tabs/flat_tabs.html.twig' import flat_tabs as tabs %}

Tabs

{% set hoteles_tab %}




Soy de Hoteles





{% endset %}

{% set vuelos_tab %}




Soy de Vuelos





{% endset %}

{% set viajes_tab %}




Soy de Viajes





{% endset %}

{{
tabs
(
{"vuelos" : "Vuelos", "hoteles" : "Hoteles", "viajes": " Viajes"},
{"vuelos" : vuelos_tab, "hoteles" : hoteles_tab, "viajes": viajes_tab},
"viajes"
)
}}


```

#### Social Buttons

**Social Login button**

- **Macro**: `login.twitter(text, args)` (any network listed below)
- **Attributes**:
- **text** : A string.
- **args** : attributes for the anchor tag.

```twig
{% import '@bootstrap/components/social/login.html.twig' as login %}


Sign in



{{ login.twitter('Sign in Twitter') }}
{{ login.facebook('Sign in with Facebook') }}
{{ login.google('Sign in with Google') }}
{{ login.linkedin('Sign in with Linkedin') }}


```

The following function names representing social networks are available:

- login.appnet
- login.bitbucket
- login.dropbox
- facebook
- login.flickr
- login.foursquare
- login.github
- login.google
- login.instagram
- login.linkedin
- login.microsoft
- login.odnoklassniki
- login.openid
- login.pinterest
- login.reddit
- login.soundcloud
- login.tumblr
- login.twitter
- login.vimeo
- login.vk
- login.yahoo

#### Social Share button

- **Macro**: `share_button(shares)`
- **Attributes**:
- **shares** : expects an `array` of `social.*()` macros.

```twig
{% import '@bootstrap/components/social/share.html.twig' as social %}
{% from '@bootstrap/components/social/share_button.html.twig' import share_button as share %}


Simple buttons



{% set social_data = {'href': 'http://localhost:8000/'} %}

{% set twitter_social_data = {
'twitter' : 'niluspc',
'twitter_text' : 'News header'
} %}

{{ social.twitter(twitter_social_data|merge(social_data)) }}
{{ social.facebook(social_data) }}

{{ share([
social.google(social_data),
social.linkedin(social_data),
social.pinterest(social_data)
])
}}


```

----------------

## To do:

- Add the bootstrap and flatUI files to its directories with all its assets.
- Add a layer to clean up included CSS and remove duplicate declarations and minify its output.