Ecosyste.ms: Awesome

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

https://github.com/phpconcur/twig-resource

Resource handling for Twig templates
https://github.com/phpconcur/twig-resource

Last synced: 21 days ago
JSON representation

Resource handling for Twig templates

Lists

README

        

# TwigResource
Resource handling for Twig templates

## Example Template

*index.php*
```php
$loader = new Twig_Loader_Filesystem('/path/to/templates');
$twig = new Twig_Environment($loader);
$twig->addExtension ( new Concur\Resource\Twig () );
echo $twig->render('home.twig');
```

*base.twig*
```html

{% resource CSS '/css/bootstrap.min.css' %}
{% resource CSS '/css/bootstrap-theme.min.css' %}
{% resource JS '/js/jquery.min.js' %}
{% resource JS '/js/bootstrap.min.js' %}

{% for c in ResourceList('CSS') %}

{% endfor %}

{% block body %}
{% endblock %}

{% for s in ResourceList('JS') %}

{% endfor %}

```

*home.twig*
```html
{% extends "base.twig" %}
{% resource CSS '/css/home.css' %}
{% resource JS '/js/home.js' %}

{% block body %}


HOME PAGE

{% endblock %}
```

*render*
```html




HOME PAGE



```