Drupal 8

Drupal 8 Module Structure

xyz.info.yml
xyz.install
xyz.links.menu.yml
xyz.module
xyz.permissions.yml
xyz.routing.yml
Readme.md
|->config
|     |-> install
|     |      |-> xyz.settings.yml
|     |-> schema
|     |      |->  xyz.schema.yml
|     |-> optional
|
|-> src
|     |-> Controller
|     |      |->xyzController.php
|     |-> Form
|     |      |-> xyzBlockForm.php
|     |      |-> xyzForm.php
|     |-> plugin
|     |      |-> Block

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 included a 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. Page data is displayed as it becomes ready, and placeholders are created for sidebar items that will be filled in as the data is available.

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', 
  ] %}