TWIGC1 | Modern Templating with Twig

  • Twig is a new de facto standard template engine library for modern web applications and frameworks. It's currently shipped with the Symfony & Silex frameworks and also in Drupal 8 & eZ Publish Content Management Systems. This two day training course is mostly targeted to frontend webdesigners and webmasters who want to master the Twig syntax and features set. A special part of the training also targets the PHP web developers who want to learn how to create their own custom Twig extension to enhance the Twig default features set.
  • Prerequisites

    HTML/CSS + basics of PHP
  • Goals

    This two day training course help web designers and webmasters to learn the fundamentals of the modern Twig template engine. As a frontend developer, you will discover the large Twig features set to help you design concise, secured and powerful templates. The training course also targets the PHP web developers who want to learn how to extend the Twig engine to create their custom Twig extensions. As a PHP developer, you will also discover the internal Twig architecture in order to write your custom Twig keywords.

Full program

Introduction to Twig

  • What is a template engine?
  • Installing Twig with Composer
  • Discovering different Twig tags
  • Understanding how Twig works internally
  • Generating a basic « Hello World » application with Twig
  • Enabling / disabling output autoescaping

Generating dynamic templates with Twig

  • Commenting code with Twig
  • Displaying a string or a variable content
  • Applying a filter on a variable
  • Iterating over an array of an objects collection
  • Making conditional statements with control structures
  • Using native Twig functions
  • Doing some basic arithmetics operations

Refactoring templates

  • Integrating multiple level template inheritance
  • Including  a template inside a master template
  • Splitting a template into several blocks
  • Defining a library of macros
  • Importing and using macros in templates

Extending and overriding Twig

  • Defining and using global variables
  • Defining and using custom filters
  • Defining and using custom functions
  • Defining and using custom tags
  • Overriding and overloading Twig internal components with extensions
  • Securing compilation with the « sandbox » mode
  • Restricting Twig features to ensure security

Time program

Day 1

Appreciation of the training

Global average :

  1. Educational rating : N.C
  2. Content rating : N.C
  3. Pace rating : N.C
  • Duration

    2 day(s)
  • Level

    Beginner
  • Available languages

    French, English
  • Available countries

    France, Germany, Spain, United Kingdom, United States, Worldwide
From €1,290.00
No session scheduled

No session is scheduled for this course. However we organize tailored training courses: contact us for more informations!