Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Sample used in our second blog post on theming with Twig in Drupal 8
{% for book_id, menu in book_menus %}
<nav id="book-block-menu-{{ book_id }}" class="book-block-menu">
{{ menu }}
</nav>
{% endfor %}
<?php foreach ($book_menus as $book_id => $menu): ?>
<div id="book-block-menu-<?php print $book_id; ?>" class="book-block-menu">
<?php print render($menu); ?>
</div>
<?php endforeach; ?>
<?php
echo check_plain($title);
?>
{{ title|escape }}
{{ title|e('js') }}
{# Hier steht ein einzeiliger Kommentar #}
{# Hier steht ein mehrzeiliger Kommentar
mit weiteren Informationen zur Funktionsweise des Templates.
#}
<?php
// Hier steht ein einzeiliger Kommentar.
/*
* Hier steht ein mehrzeiliger Kommentar
* mit weiteren Informationen zur Funktionsweise des Templates.
*/
?>
<figure class="{{ item.attributes.class }}"{{ item.attributes }}>
{% if style %}
{% include 'core/themes/stark/templates/image/image_style.html.twig' with {image: item.image } %}
{% else %}
{% include 'core/themes/stark/templates/theme.inc/image.html.twig' with {image: item.image } %}
{% endif %}
{% if item.caption %}
<figcaption>
{{ item.caption }}
</figcaption>
{% endif %}
</figure>
{{ name }} <small>{{ '(Machine name: @type)'|t({ '@type': type }) }}</small>
<div class="description">{{ description }}</div>
<div class="poll">
<div class="title"><?php print $title ?></div>
<?php print $results ?>
<div class="total">
<?php print t('Total votes: @votes', array('@votes' => $votes)); ?>
</div>
</div>
<div class="links"><?php print $links; ?></div>
<div class="custom-wrapper">
<label for="<?php print $widgets['filter-myfield']->id; ?>">
<?php print $widgets['filter-myfield']->label ?>
</label>
<?php print $widgets['filter-myfield']->widget ?>
</div>
<div class="custom-wrapper">
<label for="{{ widgets.filter-myfield.id }}">{{ widgets.filter-myfield.label }}</label>
{{ widgets.filter-myfield.widget }}
</div>
<div id="taxonomy-term-{{ term.tid }}"{{ attributes }}>
{% if not page %}
<h2>{{ term_name }}</h2>
{% endif %}
<div class="content">
{{ content }}
</div>
</div>
<div id="taxonomy-term-<?php print $term->tid; ?>">
<?php if (!$page): ?>
<h2><?php print $term_name; ?></h2>
<?php endif; ?>
<div class="content">
<?php print render($content); ?>
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment