Drupal 8

What is TWIG?

Twig is a template engine for PHP and it is part of the Symfony2 framework. Drupal 8 Twig replaces as the default templating engine.

* By default, the twig theming engine compiles templates into PHP code and stores the compiled code in memory.
* Compiled code is unsuitable for development, Since Changes in twig templates are not immediately updated in your Drupal site.

New Core modules in Drupal 8?

* Ban - Block  Ip addresses
* Breakpoint - Keeps track of the height, width and resolution break point for responsive design.
* CKEditor
* Config
* Datetime
* Edit
* Editor
* Email
* Entity
* Entity Reference
* HAL -> Serializes entities using HAL
* History -> Records which user has read which content
* Language
* Layout
* Link
* Menu link
* REST -> RESTful webservices module
* Serialization
* Telephone
* Tour
* Views
* Views UI
* XMLRPC

how to use t() in twig file?

Translation filters
trans
This filter (alternatively, t) will run the variable through the Drupal t() function, which will return a translated string. This filter should be used for any interface strings manually placed in the template that will appear for users.

Example:
<a href="{{ url('<front>') }}" title="{{ 'Home'|t }}" rel="home" class="site-logo"></a>

What is Drupal Big Pipe?

Drupal recently included an experimental module in core called Big Pipe. The Big Pipe concept is about loading page data as it becomes available instead of waiting for the entire response before showing anything. This will not affect the total response time, but will greatly reduce the perceived response time. The page will appear to load faster and portions of the content can be readable in less time. Below is a video showing the perceived speed of Big Pipe.

How to define/set variable in twig templates Drupal 8?

 Passing global variables from settings to twig

  1. on my template.theme
  function theme_preprocess_page(&$variables) {
   $variables[theme_link] = Settings::get('custom_link');
  }

  2. on my twig 
  {{ theme_link }}
   

  Set Variable Example:
  Set a class using the variable
  {% set classes = [
  'test',
  'myclass', 
  ] %}

How to display/debug variables in twig file Drupal 8?

Discovering and Inspecting Variables in Twig Templates using {{ dump() }} function.
 
  To dump only the available variable keys use: {{ dump(_context|keys) }}

  Uncomment the line that contains the twig_debug setting.php
  $settings['twig_debug'] = TRUE;

  Beware of dump()
  If you want to see all variables, but dump() results in exhausted memory because of recursion or the like, you can loop through _context to see all the keys in it: