Plantillas Twig (Symfony)

7
Grupo de Trabajo GNU/Linux Universidad Distrital Francisco Jos´ e de Caldas

Transcript of Plantillas Twig (Symfony)

Page 1: Plantillas Twig (Symfony)

Grupo de TrabajoGNU/Linux Universidad

Distrital FranciscoJose de Caldas

Page 2: Plantillas Twig (Symfony)

Creado por: Fabien Potencier1

bajo la licencia BSD

http:

//twig.sensiolabs.org/

app/cache/ entorno /twig

• dev : modo debugactivado

• prod : modo debugdesactivado

1https://github.com/fabpot

Page 3: Plantillas Twig (Symfony)

Plantilla php

Page 4: Plantillas Twig (Symfony)

Plantilla Twig2

2 Sandbox

Page 5: Plantillas Twig (Symfony)

Herencia en Twig

”Una plantilla puede decorar el contenido de otra plantilla”3

{% extends %} : Debe ser laprimera linea

• Procesa la plantilla base

• Se renderiza la plantillahija

{{ parent () }}: Obtiene elcontenido de algun bloque de

la plantilla padre

{{ ::base.html.twig }}:

app/Resources/views

3https://librosweb.es/libro/symfony 2 x/capitulo 7/herencia de plantillas y layout.html

Page 6: Plantillas Twig (Symfony)

• Nomenclatura: 4

index.html.twig: formato HTML, motor Twig.index.html.php: formato HTML, motor PHP.index.css.twig: formato CSS, motor Twig.

• Etiquetas: for, if, macro, include,importhttp://gitnacho.github.io/Twig/tags/index.html

{% for i in range(low = 1,high = 10, step = 2) %}{{ i }},{% endfor %}

{% for i in range(0, 3) %}{{ i }},{% endfor %}

• Inclusion de CSS y JavaScript: http://librosweb.es/libro/symfony_2_x/capitulo_7/incluyendo_hojas_

de_estilo_y_javascript_en_twig.html

4https://librosweb.es/libro/symfony 2 x/capitulo 7/nomenclatura y localizacion de las plantillas.html

Page 7: Plantillas Twig (Symfony)