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
- Host: GitHub
- URL: https://github.com/phpconcur/twig-resource
- Owner: phpconcur
- License: mit
- Created: 2017-04-18T02:05:54.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2017-09-22T02:00:14.000Z (over 6 years ago)
- Last Synced: 2024-04-14T12:21:44.537Z (2 months ago)
- Language: PHP
- Size: 8.79 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Lists
- awesome-twig - Resource - Resource handling for Twig templates (Twig / Extensions)
- awesome-twig - Resource - Resource handling for Twig templates (Twig / Extensions)
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
```