Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Extending Symfony2 Web Application Framework

You're reading from   Extending Symfony2 Web Application Framework Symfony2 took the great features of the original framework to new levels of extensibility. With this practical guide you'll learn how to make the most of Symfony2 through controlling your code and sharing it more widely.

Arrow left icon
Product type Paperback
Published in Mar 2014
Publisher
ISBN-13 9781783287192
Length 140 pages
Edition Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Sebastien Armand Sebastien Armand
Author Profile Icon Sebastien Armand
Sebastien Armand
Arrow right icon
View More author details
Toc

Twig


By default, Symfony ships with the Twig templating system. Twig is incredibly powerful and out of the box. The possibilities offered by blocks, extending templates, including templates, and macros are huge and will be enough for most cases. There are cases where you still need something more though, and an extension for Twig is the only elegant way of doing so.

Twig offers five different ways to create extensions:

  • Globals: This lets you define some global variables that are available in all templates. You could access them like any other variable.

  • Functions: This will let you write {{my_function(var)}}.

  • Tests: These are specific functions that return Boolean values and can be used after the is keyword in templates.

  • Filters: They modify the output of an output tag.

  • Tags: This will let you define custom Twig tags.

Some of the pages on our website will require some JavaScript in them to make them a bit more dynamic or simple to use. The form to create a meetup for organizers will definitely use...

You have been reading a chapter from
Extending Symfony2 Web Application Framework
Published in: Mar 2014
Publisher:
ISBN-13: 9781783287192
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image