Drupal Technical
[Drupal] What are Twig templates in Drupal?
What is Twig? How will it change Drupal themes? Drupal 8 is coming with lot of improvement in theme layer. Twig is a template engine and easy to learn. Twig is help to create template without knowledge of PHP. Twig is part of the symfony2. It created by SensioLabs. The changes in classes and arrays combined to attribute object. In Drupal 8 .tpl.php file is replaced by *.html.twig template files.
This is Drupal 7 and the page.tpl.php file:
<ul id="navigation">
<?php
for($item as $navigation) {
?>
<li><a href="<?php echo $navigation['href'];?>"><?php echo $navigation['caption'];?></a></li>
<?php
}
?>
</ul>
This is Drupal 8 and the page.html.twig file:
<ul id="navigation">
{% for item in navigation %}
<li><a href="{{ item.href }}">{{ item.caption }}</a></li>
{% endfor %}
</ul>
Twig defines three kinds of delimiters:
<ul>
<li>{% ... %}, which is used to execute statements, such as for-loops.</li>
<li<{{ ... }}, which is used to print the content of variables</li>
<li<{# ... #}, which is used to add comments in the templates.</li>
</ul>
Theme info files
In drupal 8 , Converting the .info file to info.yml. Its the symbolic component of symfony.
stylesheets[all][] = css/style.css
We now,
stylesheets:all:- css/style.css