Skip to content

Instantly share code, notes, and snippets.

@steveoliver
Created February 10, 2013 19:31
Show Gist options
  • Select an option

  • Save steveoliver/4750736 to your computer and use it in GitHub Desktop.

Select an option

Save steveoliver/4750736 to your computer and use it in GitHub Desktop.
Drupal 8 Best Practices in Preprocess functions and Twig templates
<h3 id="bestpractices">Best Practices in Preprocess Functions and Twig Templates</h3>
In order to minimize wasteful calls to unneeded resources and make Drupal 8 themeing as performant as possible, please follow these best practices:
<ol>
<li>Always call <code>t()</code> within templates; never call t() in preprocess.</li>
<li>Always return render arrays instead of ever calling <code>theme()</code> within a preprocess function.</li>
</ol>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment