Documents

Twig.pdf

Categories
Published
of 163
All materials on our website are shared by users. If you have any questions about copyright issues, please report us to resolve them. We are always happy to assist you.
Related Documents
Share
Description
The Twig Book generated on November 15, 2013 The Twig Book This work is licensed under the “Attribution-Share Alike 3.0 Unported” license (http://creativecommons.org/ licenses/by-sa/3.0/). You are free to share (to copy, distribute and transmit the work), and to remix (to adapt the work) under the following conditions: ã Attribution: You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work). ã
Transcript
  The Twig Book  generated on November 15, 2013  The Twig Book Thisworkislicensedunderthe“Attribution-ShareAlike3.0Unported”license( http://creativecommons.org/ licenses/by-sa/3.0/  ).Youarefree  toshare (tocopy,distributeandtransmitthework),and  toremix (toadaptthework)underthefollowing conditions:ã  Attribution :Youmustattributetheworkinthemannerspecifiedbytheauthororlicensor(butnot in any way that suggests that they endorse you or your use of the work).ã  ShareAlike :Ifyoualter,transform,orbuilduponthiswork,youmaydistributetheresultingworkonlyunderthesame,similaroracompatiblelicense.Foranyreuseordistribution,youmustmakeclear to others the license terms of this work.Theinformationinthisbookisdistributedonan“asis”basis,withoutwarranty.Althougheveryprecautionhasbeentakeninthepreparationofthiswork,neithertheauthor(s)norSensioLabsshallhaveanyliabilitytoanypersonorentitywithrespecttoanylossordamagecausedorallegedtobecauseddirectlyorindirectlybythe information contained in this work.  Contents at a Glance Introduction.......................................................................................................................................5Twig for Template Designers...............................................................................................................7Twig for Developers..........................................................................................................................21Extending Twig................................................................................................................................30Twig Internals...................................................................................................................................44Recipes.............................................................................................................................................47Coding Standards.............................................................................................................................56 autoescape ......................................................................................................................................58 block ...............................................................................................................................................60 filter ..............................................................................................................................................61 do .....................................................................................................................................................62 embed ...............................................................................................................................................63 extends ............................................................................................................................................67 flush ...............................................................................................................................................72 for ...................................................................................................................................................73 from .................................................................................................................................................77 if .....................................................................................................................................................78 import ..............................................................................................................................................79 include ............................................................................................................................................81 macro ...............................................................................................................................................83 sandbox ............................................................................................................................................85 set ...................................................................................................................................................86 spaceless ........................................................................................................................................88 use ...................................................................................................................................................89 verbatim ..........................................................................................................................................92 abs ...................................................................................................................................................93 batch ...............................................................................................................................................94 capitalize ......................................................................................................................................96 convert_encoding ...........................................................................................................................97 date .................................................................................................................................................98 date_modify ...................................................................................................................................100 default ..........................................................................................................................................101 escape ............................................................................................................................................102 first .............................................................................................................................................105 format ............................................................................................................................................106 PDF brought to you by generated on November 15, 2013 Contents at a Glance | iii  join ...............................................................................................................................................107 json_encode ...................................................................................................................................108 keys ...............................................................................................................................................109 last ...............................................................................................................................................110 length ............................................................................................................................................111 lower .............................................................................................................................................112 nl2br .............................................................................................................................................113 number_format ...............................................................................................................................114 merge .............................................................................................................................................116 upper .............................................................................................................................................117 raw .................................................................................................................................................118 replace ..........................................................................................................................................119 reverse ..........................................................................................................................................120 slice .............................................................................................................................................122 sort ...............................................................................................................................................124 split .............................................................................................................................................125 striptags ......................................................................................................................................127 title .............................................................................................................................................128 trim ...............................................................................................................................................129 url_encode ....................................................................................................................................130 attribute ......................................................................................................................................131 block .............................................................................................................................................132 constant ........................................................................................................................................133 cycle .............................................................................................................................................134 date ...............................................................................................................................................135 dump ...............................................................................................................................................137 include ..........................................................................................................................................139 parent ............................................................................................................................................141 random ............................................................................................................................................142 range .............................................................................................................................................143 source ............................................................................................................................................145 template_from_string ..................................................................................................................146 constant ........................................................................................................................................147 defined ..........................................................................................................................................148 divisible by .................................................................................................................................149 empty .............................................................................................................................................150 even ...............................................................................................................................................151 iterable ........................................................................................................................................152 null ...............................................................................................................................................153 odd .................................................................................................................................................154 same as ..........................................................................................................................................155Installation.....................................................................................................................................156Deprecated Features........................................................................................................................159 iv | Contents at a Glance Contents at a Glance | 4
We Need Your Support
Thank you for visiting our website and your interest in our free products and services. We are nonprofit website to share and download documents. To the running of this website, we need your help to support us.

Thanks to everyone for your continued support.

No, Thanks