twig tutorial - What is Twig - twig definition - define twig - twig php - twig template



What is Twig?

  • Twig is a templating language that compiles to optimized PHP code. It is primarily used for outputting HTML, but can also be used to output any other text-based format. It is a standalone component that can be easily integrated into any PHP project.
learn twig - twig tutorial - twig components - twig code -   twig template   - twig programming - twig download - twig examples
learn twig - twig tutorial - twig components - twig code -
twig template
- twig programming - twig download - twig examples

It provides many excellent features:

  • Autoescaping for HTML (helps to prevent XSS)
  • Syntax designed with templating in mind (based on Django templates)
  • Template inheritance
  • Macros

Example of Twig's syntax:

{% extends "base.html" %}

{% block sidebar %}
  {{ parent() }}
  <span>Sidebar content specific to this page</span>
{% endblock sidebar %}

{% block body %}
  <p>Select an item:</p>
  <ul>
    {% for item in list %}
      <li><a href="/items/{{ item.id }}">{{ item.name }}</a>
    {% else %}
      <li>No items yet.
    {% endfor %}
  </ul>
{% endblock body %}
learn twig - twig tutorial - twig components - twig code -   twig template - twig programming - twig download - twig examples
learn twig - twig tutorial - twig components - twig code -
twig template
- twig programming - twig download - twig examples
learn twig - twig tutorial - twig components - twig code -   twig template - twig programming - twig download - twig examples
learn twig - twig tutorial - twig components - twig code -
what is twig
- twig programming - twig download - twig examples

Related Searches to twig tutorial - What is Twig