Skip to content

Instantly share code, notes, and snippets.

@GromNaN GromNaN/base.twig
Last active Aug 29, 2015

Embed
What would you like to do?
Twig issue #1378
<!DOCTYPE html>
<html>
<head>
<title>{% block title %}{% endblock %}</title>
{% block head %}
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-15" />
{% endblock %}
</head>
<body>
{% block header %}{% endblock %}
<div id="page">
{% block body %}{% endblock %}
</div>
<div id="footer">
{% block footer %}{% endblock %}
</div>
{% block scripts %}{% endblock %}
</body>
</html>
{% block title %}My content title{% endblock %}
{% block head %}
{# {{ parent() }} Not working #}
<meta property="og:image" content="http://static.lexpress.fr/pub/lexpress_fb.jpg" />
{% endblock %}
{% block body %}
{# {% import 'macros.twig' as macros %} #}
{% from 'macros.twig' import breadcrumb as breadcrumb %}
{{ breadcrumb([{url:'/',title:'1'}, {url:'/',title:'2'}]) }}
{% endblock %}
{
"require": {
"twig/twig": "~1.13.0"
}
}
<?php
ini_set('display_errors', 1);
require __DIR__.'/vendor/autoload.php';
$loader = new Twig_Loader_Filesystem(__DIR__);
$twig = new Twig_Environment($loader, array('debug' => true));
echo $twig->render('template.twig', $_GET);
{% macro breadcrumb(breadcrumb) -%}
<nav role="breadcrumb" class="breadcrumb">
<ul>
{% for element in breadcrumb %}
<li><a href="{{ element.url }}">{{ element.title }}</a></li>
{% endfor %}
</ul>
</nav>
{%- endmacro %}
{% extends 'base.twig' %}
{% use 'blocks.twig' %}
{% block footer %}
Specific Footer content
{% endblock %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.