dev-master
9999999-dev https://github.com/phpconcur/twig-resourceResource handling for Twig templates
MIT
The Requires
- php >=5.5.0
- twig/twig ^1.18|^2.0
by Chris Chase
twig css resource js
Wallogit.com
2017 © Pedro Peláez
Resource handling for Twig templates
Resource handling for Twig templates, (*1)
index.php, (*2)
$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, (*3)
<!DOCTYPE html>
<html lang="en">
<head>
{% 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') %}
<link rel="stylesheet" type="text/css" href="{{ c.name }}" />
{% endfor %}
</head>
<body>
{% block body %}
{% endblock %}
{% for s in ResourceList('JS') %}
{% endfor %}
</body>
</html>
home.twig, (*4)
{% extends "base.twig" %}
{% resource CSS '/css/home.css' %}
{% resource JS '/js/home.js' %}
{% block body %}
HOME PAGE
{% endblock %}
render, (*5)
<!DOCTYPE html> <html lang="en"> <head> <link rel="stylesheet" type="text/css" href="/css/bootstrap.min.css" /> <link rel="stylesheet" type="text/css" href="/css/bootstrap-theme.min.css" /> <link rel="stylesheet" type="text/css" href="/css/home.css" /> </head> <body>HOME PAGE</body> </html>
Resource handling for Twig templates
MIT
twig css resource js