Created
January 4, 2012 23:10
-
-
Save xavierbriand/1562741 to your computer and use it in GitHub Desktop.
Twig training 2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
{% block head %} | |
<link rel="stylesheet" href="style.css" /> | |
<title>{% block title %}{% endblock %} Sensio</title> | |
{% endblock %} | |
</head> | |
<body> | |
<div>{% block content %}{% endblock %}</div> | |
<div> | |
{% block footer %}© sensio{% endblock %} | |
</div> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% extends "base.html" %} | |
{% block title %}Index{% endblock %} | |
{% block head %} | |
{{ parent() }} | |
<link rel="stylesheet" href="grid.css" /> | |
{% endblock %} | |
{% block content %} | |
<h1>Index</h1> | |
... | |
{% endblock %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{# block #} | |
{% block title 'mon titre'|title %} | |
{{ block('title') }} | |
{% block sidebar %} | |
{% block inner_sidebar %} | |
... | |
{% endblock inner_sidebar %} | |
{% endblock sidebar %} | |
{# extends #} | |
{% extends ajax_actif ? 'ajax.html.twig' : 'ss_ajax.html.twig' %} | |
{% extends 'layout_'~locale~'.html.twig' %} | |
{% extends ['layout_'~locale~'.html.twig', 'layout.html.twig'] %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{# forms.html #} | |
{% macro txtarea(name, value, cols) %} | |
<textarea cols="{{ cols|default(5) }}" name="{{ name }}"> | |
{{ value|e }} | |
</textarea> | |
{% endmacro %} | |
... | |
{# shortcuts.html #} | |
{% macro wrapped_txtarea(name, value, cols) %} | |
{% import "forms.html" as forms %} | |
<div class="field"> | |
{{ forms.txtarea(name, value, cols) }} | |
</div> | |
{% endmacro %} | |
{# template.html #} | |
{% from 'forms.html' import txtarea as input_long_text %} | |
{{ input_long_text('name', article.body, null) }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{# blocks.html.twig #} | |
{% block sidebar %}<ul>...{% endblock %} | |
{# content.html.twig #} | |
{% extends "layout.html.twig" %} | |
{% use 'block.html.twig' %} | |
{% block title %}{% endblock %} | |
{% block content %}{% endblock %} | |
{# content.html.twig #} | |
{% extends "layout.html.twig" %} | |
{% use 'block.html.twig' with sidebar as my_sidebar %} | |
{% block sidebar %} | |
{{ block('my_sidebar') }} | |
{% endblock %} | |
{% block title %}{% endblock %} | |
{% block content %}{% endblock %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment