<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en-us" xmlns="http://www.w3.org/2005/Atom"><title>Simon Willison's Weblog: templates</title><link href="http://simonwillison.net/" rel="alternate"/><link href="http://simonwillison.net/tags/templates.atom" rel="self"/><id>http://simonwillison.net/</id><updated>2024-08-27T15:47:19+00:00</updated><author><name>Simon Willison</name></author><entry><title>MiniJinja: Learnings from Building a Template Engine in Rust</title><link href="https://simonwillison.net/2024/Aug/27/minijinja/#atom-tag" rel="alternate"/><published>2024-08-27T15:47:19+00:00</published><updated>2024-08-27T15:47:19+00:00</updated><id>https://simonwillison.net/2024/Aug/27/minijinja/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="https://lucumr.pocoo.org/2024/8/27/minijinja/"&gt;MiniJinja: Learnings from Building a Template Engine in Rust&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
Armin Ronacher's &lt;a href="https://github.com/mitsuhiko/minijinja/"&gt;MiniJinja&lt;/a&gt; is his re-implemenation of the Python &lt;a href="https://jinja.palletsprojects.com/"&gt;Jinja2&lt;/a&gt; (originally built by Armin) templating language in Rust.&lt;/p&gt;
&lt;p&gt;It's nearly three years old now and, in Armin's words, "it's at almost feature parity with Jinja2 and quite enjoyable to use".&lt;/p&gt;
&lt;p&gt;The WebAssembly compiled demo in the &lt;a href="https://mitsuhiko.github.io/minijinja-playground/"&gt;MiniJinja Playground&lt;/a&gt; is fun to try out. It includes the ability to output instructions, so you can see how this:&lt;/p&gt;
&lt;div class="highlight highlight-text-html-django"&gt;&lt;pre&gt;&amp;lt;&lt;span class="pl-ent"&gt;ul&lt;/span&gt;&amp;gt;
  &lt;span class="pl-e"&gt;{%&lt;/span&gt;- &lt;span class="pl-k"&gt;for&lt;/span&gt; &lt;span class="pl-s"&gt;item&lt;/span&gt; &lt;span class="pl-k"&gt;in&lt;/span&gt; &lt;span class="pl-s"&gt;nav&lt;/span&gt; &lt;span class="pl-e"&gt;%}&lt;/span&gt;
    &amp;lt;&lt;span class="pl-ent"&gt;li&lt;/span&gt;&amp;gt;{{ item.title }}&amp;lt;/&lt;span class="pl-ent"&gt;a&lt;/span&gt;&amp;gt;
  &lt;span class="pl-e"&gt;{%&lt;/span&gt;- &lt;span class="pl-k"&gt;endfor&lt;/span&gt; &lt;span class="pl-e"&gt;%}&lt;/span&gt;
&amp;lt;/&lt;span class="pl-ent"&gt;ul&lt;/span&gt;&amp;gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Becomes this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;0   EmitRaw "&amp;lt;ul&amp;gt;"
1   Lookup  "nav"
2   PushLoop    1
3   Iterate 11
4   StoreLocal  "item"
5   EmitRaw "\n &amp;lt;li&amp;gt;"
6   Lookup  "item"
7   GetAttr "title"
8   Emit    
9   EmitRaw "&amp;lt;/a&amp;gt;"
10  Jump    3
11  PopFrame    
12  EmitRaw "\n&amp;lt;/ul&amp;gt;"&lt;/code&gt;&lt;/pre&gt;

    &lt;p&gt;&lt;small&gt;&lt;/small&gt;Via &lt;a href="https://hachyderm.io/@mitsuhiko/113034016600122789"&gt;@mitsuhiko&lt;/a&gt;&lt;/small&gt;&lt;/p&gt;


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/armin-ronacher"&gt;armin-ronacher&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/jinja"&gt;jinja&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/templates"&gt;templates&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/rust"&gt;rust&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/webassembly"&gt;webassembly&lt;/a&gt;&lt;/p&gt;



</summary><category term="armin-ronacher"/><category term="jinja"/><category term="templates"/><category term="rust"/><category term="webassembly"/></entry><entry><title>datasette-template-sql</title><link href="https://simonwillison.net/2019/Nov/15/datasette-template-sql/#atom-tag" rel="alternate"/><published>2019-11-15T00:59:50+00:00</published><updated>2019-11-15T00:59:50+00:00</updated><id>https://simonwillison.net/2019/Nov/15/datasette-template-sql/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="https://github.com/simonw/datasette-template-sql"&gt;datasette-template-sql&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
New Datasette plugin, celebrating the new ability in Datasette 0.32 to have asynchronous custom template functions in Jinja (which was previously blocked by the need to support Python 3.5). The plugin adds a sql() function which can be used to execute SQL queries that are embedded directly in custom templates.

    &lt;p&gt;&lt;small&gt;&lt;/small&gt;Via &lt;a href="https://twitter.com/simonw/status/1195126529304301573"&gt;@simonw&lt;/a&gt;&lt;/small&gt;&lt;/p&gt;


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/jinja"&gt;jinja&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/projects"&gt;projects&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/sql"&gt;sql&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/templates"&gt;templates&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/datasette"&gt;datasette&lt;/a&gt;&lt;/p&gt;



</summary><category term="jinja"/><category term="projects"/><category term="sql"/><category term="templates"/><category term="datasette"/></entry><entry><title>Seasoning Templates</title><link href="https://simonwillison.net/2007/Jul/19/jacobian/#atom-tag" rel="alternate"/><published>2007-07-19T18:04:22+00:00</published><updated>2007-07-19T18:04:22+00:00</updated><id>https://simonwillison.net/2007/Jul/19/jacobian/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="http://www.jacobian.org/writing/2007/jul/19/salt/"&gt;Seasoning Templates&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
“Designing a template language is a lot like seasoning a dish; there’s a whole range of tastes out there.”


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/django"&gt;django&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/jacob-kaplan-moss"&gt;jacob-kaplan-moss&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/templates"&gt;templates&lt;/a&gt;&lt;/p&gt;



</summary><category term="django"/><category term="jacob-kaplan-moss"/><category term="templates"/></entry><entry><title>Logic in Templates</title><link href="https://simonwillison.net/2007/Jul/19/aboutcmlenz/#atom-tag" rel="alternate"/><published>2007-07-19T08:35:56+00:00</published><updated>2007-07-19T08:35:56+00:00</updated><id>https://simonwillison.net/2007/Jul/19/aboutcmlenz/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="http://www.cmlenz.net/blog/2007/06/logic-in-templa.html"&gt;Logic in Templates&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
I don’t think it would hurt Django to have a bit more support for conditional logic in templates, but I wouldn’t go as far as supporting the ability to call Python functions directly.


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/christopher-lenz"&gt;christopher-lenz&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/django"&gt;django&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/logic"&gt;logic&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/python"&gt;python&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/templates"&gt;templates&lt;/a&gt;&lt;/p&gt;



</summary><category term="christopher-lenz"/><category term="django"/><category term="logic"/><category term="python"/><category term="templates"/></entry><entry><title>Naming URL patterns</title><link href="https://simonwillison.net/2007/Apr/10/naming/#atom-tag" rel="alternate"/><published>2007-04-10T00:19:55+00:00</published><updated>2007-04-10T00:19:55+00:00</updated><id>https://simonwillison.net/2007/Apr/10/naming/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="http://www.djangoproject.com/documentation/url_dispatch/#naming-url-patterns"&gt;Naming URL patterns&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
You can now apply a name to a URL pattern in Django development version, which makes the &lt;code&gt;{% url %}&lt;/code&gt; template tag far more useful.

    &lt;p&gt;&lt;small&gt;&lt;/small&gt;Via &lt;a href="http://www.djangoproject.com/weblog/2007/apr/08/weekinreview/"&gt;Django Weblog - Week in review: April 8&lt;/a&gt;&lt;/small&gt;&lt;/p&gt;


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/django"&gt;django&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/templates"&gt;templates&lt;/a&gt;&lt;/p&gt;



</summary><category term="django"/><category term="templates"/></entry><entry><title>Django templates in Venus</title><link href="https://simonwillison.net/2007/Feb/14/venus/#atom-tag" rel="alternate"/><published>2007-02-14T23:22:55+00:00</published><updated>2007-02-14T23:22:55+00:00</updated><id>https://simonwillison.net/2007/Feb/14/venus/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="http://www.intertwingly.net/blog/2007/02/14/Django-templates-in-Venus"&gt;Django templates in Venus&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
It’s nice to see the Django template system being used outside the context of the overall framework.


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/django"&gt;django&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/templates"&gt;templates&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/venus"&gt;venus&lt;/a&gt;&lt;/p&gt;



</summary><category term="django"/><category term="templates"/><category term="venus"/></entry></feed>