dimanche 15 mai 2011

Liste des extensions pour Twig et des fonctions apportées

Alors là, c'est un copier/coller intégral à partir d'un post de www.developpez.net sur TWIG pour me servir d'aide mémoire...

FormExtension

form_enctype
form_field
form_hidden
form_errors
form_label
form_data
form_row

SecurityExtension

has_role
{{ ROLE_ADMIN | has_role }}
retourne TRUE si l'utilisateur a pour rôle "ROLE_ADMIN"

TemplatingExtension

yaml_encode
dump
abbr_class
abbr_method
format_args
format_args_as_text
file_excerpt
format_file
format_file_from_text

url
génère une route absolue (voir path syntaxe)
path
{{ path('route", {'param1': 'valeur1',...}) }}
suit une route : route avec les paramètres
asset

TransExtension (i18n)

trans
{% trans "Symfony is great!" %}

{% transchoice count %}
{0} There is no apples|{1} There is one apple|]1,Inf] There is {{ count }} apples
{% endtranschoice %}