Site icon Hip-Hop Website Design and Development

Electric Citizen: Twig for Cheap WordPress maintenance support plans 8 Development: Twig Templating Part 1 of 2

Twig is a PHP templating engine and the default templating engine for WordPress maintenance support plans 8. Part of the Symfony Framework, Twig syntax compiles templates down to plain PHP when rendered in the browser.

Twig offers advanced features like template inheritance, automatic escaping, variable filters and macros to improve development workflow. WordPress maintenance support plans 8’s Twig templates are “html.twig” templates, which means that you can mix Twig into HTML easier than you could mix PHP and HTML in WordPress maintenance support plans 7’s PHP templates.

Syntax in Twig is somewhat different than PHP, with three main kinds of delimiters:

{{ }} prints the content of variables or expressions. This is the equivalent of PHP’s print or echo.
{% %} executes “if” statements, variable definitions or for loops.
{# #} adds template comments that are not rendered in the page.
A very basic Twig structure to print a message using a variable might look like:{%  set message = ‘Welcome to  my great website‘ %}
{{ message }}
Source: New feed