&
Swastik Pareek
@swastik1608
Proud developer @qed42
<?php
/**
* Simple PHP template
*/
?>
<DIV>
Hi!
<SPAN>
<?php if ($user->gender === 'male') : ?>
Mr.
<?php elseif ($user->gender === 'female') : ?>
Mrs.
<?php endif; ?>
<?php print $user->name['first'] ?>
<?php print $user->name['last'] ?>
</SPAN>
<UL>
<?php foreach ($user->items as $item) : ?>
<li> print $item ; </LI>
<?php endforeach; ?>
</UL>
</DIV>{#
# Simple Twig Template
#}
<div>
Hi!
<SPAN>
{% if (user.gender == 'male') %}
Mr.
{% elseif (user.gender == 'female') %}
Mrs.
{% endif %}
{{ user.name.first ~ user.name['last'] }}
</SPAN>
<UL>
{% for item in user.items %}
<li> {{ item }} </LI>
{% endfor %}
</UL>
</div>
Simple Hands On Example of twig coding
Use of rendered array in preprocess
And Other logic goes inside template
https://www.drupal.org/node/1843650
<div {{attributes.class.addClass('superman')
|without('class')}}>
Hello from your inner soul!
</div>Add Your custom :)
Preprocess
to
template files
Questions?