<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="/atom.xsl" type="text/xsl"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title>Posts tagged: jinja</title>
  <id>https://waylonwalker.com/tags/jinja/atom.xml</id>
  <updated>2023-12-26T22:00:42Z</updated>
  <subtitle>All posts with the tag &#34;jinja&#34;</subtitle>
  <link href="https://waylonwalker.com/tags/jinja/" rel="alternate" type="text/html"></link>
  <link href="https://waylonwalker.com/tags/jinja/atom.xml" rel="self" type="application/atom+xml"></link>
  <author>
    <name>Waylon Walker</name>
  </author>
  <generator uri="https://github.com/WaylonWalker/markata-go">markata-go</generator>
  <entry>
    <title>💭 Template Designer Documentation — Jinja Documentation</title>
    <id>https://waylonwalker.com/thought-194/</id>
    <updated>2023-12-26T22:00:42Z</updated>
    <published>2023-12-26T22:00:42Z</published>
    <link href="https://waylonwalker.com/thought-194/" rel="alternate" type="text/html"></link>
    <summary type="text">!https://jinja.palletsprojects.com/en/3.0.x/templates/#whitespace-control</summary>
    <content type="html">&lt;div class=&#34;embed-card embed-card-external&#34;&gt;&#xA;  &lt;a href=&#34;https://jinja.palletsprojects.com/en/3.0.x/templates/#whitespace-control&#34; class=&#34;embed-card-link  has-avatar has-avatar-before&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34; style=&#34;--favicon-url: url(&amp;#39;/assets/markata/link-avatars/jinja.palletsprojects.com.ico&amp;#39;);&#34; data-favicon=&#34;/assets/markata/link-avatars/jinja.palletsprojects.com.ico&#34;&gt;&#xA;    &lt;div class=&#34;embed-card-content&#34;&gt;&#xA;      &lt;div class=&#34;embed-card-title&#34;&gt;Template Designer Documentation — Jinja Documentation (3.1.x)&lt;/div&gt;&#xA;      &lt;div class=&#34;embed-card-meta&#34;&gt;jinja.palletsprojects.com&lt;/div&gt;&#xA;    &lt;/div&gt;&#xA;  &lt;/a&gt;&#xA;&lt;/div&gt;&#xA;&lt;p&gt;&lt;a href=&#34;/html/&#34; class=&#34;glossary-term&#34; title=&#34;HTML (HyperText Markup Language) is the standard markup language used to create and design documents on the World Wide Web. It structures web content by...&#34;&gt;html&lt;/a&gt; code generated by my jinja templates generally look half garbage because of indents and whitespace all over the place.  I just learned about these pesky Whitespace Control characters that can get rid of the whitespace added from templating.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;You can also strip whitespace in templates by hand. If you add a minus sign (-) to the start or end of a block (e.g. a For tag), a comment, or a variable expression, the whitespaces before or after that block will be removed:&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;pre class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;{% for item in seq -%}&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    {{ item }}&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;{%- endfor %}&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&#34;admonition note&#34;&gt;&#xA;&lt;p class=&#34;admonition-title&#34;&gt;Note&lt;/p&gt;&#xA;&lt;p&gt;This post is a &lt;a href=&#34;/thoughts/&#34; class=&#34;wikilink&#34; data-title=&#34;Thoughts&#34; data-description=&#34;These are generally my thoughts on a web page or some sort of url, except a rare few don&amp;#39;t have a link. These are dual published off of my...&#34; data-date=&#34;2024-04-01&#34; data-preview=&#34;These are generally my thoughts on a web page or some sort of url, except a rare few don&amp;#39;t have a link. These are dual published off of my...&#34;&gt;thought&lt;/a&gt;. It’s a short note that I make&#xA;about someone else’s content online &lt;a href=&#34;/tags/thoughts/&#34; class=&#34;hashtag-tag&#34; data-tag=&#34;thoughts&#34; data-count=&#34;2&#34; data-reading-time=&#34;3&#34; data-reading-time-text=&#34;3 minutes&#34;&gt;#thoughts&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/div&gt;&#xA;</content>
    <author>
      <name>Waylon Walker</name>
      <email>hello@waylonwalker.com</email>
      <uri>https://waylonwalker.com</uri>
    </author>
  </entry>
  <entry>
    <title>💭 API — Jinja Documentation</title>
    <id>https://waylonwalker.com/thought-69/</id>
    <updated>2023-08-04T23:54:05Z</updated>
    <published>2023-08-04T23:54:05Z</published>
    <link href="https://waylonwalker.com/thought-69/" rel="alternate" type="text/html"></link>
    <summary type="text">!https://jinja.palletsprojects.com/en/3.0.x/api/#jinja2.Environment.compile_templates</summary>
    <content type="html">&lt;div class=&#34;embed-card embed-card-external&#34;&gt;&#xA;  &lt;a href=&#34;https://jinja.palletsprojects.com/en/3.0.x/api/&amp;lt;a href=&#34; tags=&#34;&#34; jinja2=&#34;&#34; &#34;=&#34;&#34; class=&#34;hashtag-tag  has-avatar has-avatar-before&#34; data-tag=&#34;jinja2&#34; data-count=&#34;1&#34; data-reading-time=&#34;1&#34; data-reading-time-text=&#34;1 minute&#34; style=&#34;--favicon-url: url(&amp;#39;/assets/markata/link-avatars/jinja.palletsprojects.com.ico&amp;#39;);&#34; data-favicon=&#34;/assets/markata/link-avatars/jinja.palletsprojects.com.ico&#34;&gt;#jinja2&lt;/a&gt;.Environment.compile_templates&amp;#34; class=&amp;#34;embed-card-link&amp;#34; target=&amp;#34;_blank&amp;#34; rel=&amp;#34;noopener noreferrer&amp;#34;&amp;gt;&#xA;    &lt;div class=&#34;embed-card-content&#34;&gt;&#xA;      &lt;div class=&#34;embed-card-title&#34;&gt;API — Jinja Documentation (3.1.x)&lt;/div&gt;&#xA;      &lt;div class=&#34;embed-card-meta&#34;&gt;jinja.palletsprojects.com&lt;/div&gt;&#xA;    &lt;/div&gt;&#xA;  &#xA;&lt;/div&gt;&#xA;&lt;p&gt;🤯 jinja comes with a loader to &lt;code&gt;pre-compile&lt;/code&gt; templates!  Defihnitely need to look at this for &lt;code&gt;markata&lt;/code&gt;, as &lt;code&gt;jinja&lt;/code&gt; is till one of the biggest hot spots.&lt;/p&gt;&#xA;&lt;div class=&#34;admonition note&#34;&gt;&#xA;&lt;p class=&#34;admonition-title&#34;&gt;Note&lt;/p&gt;&#xA;&lt;p&gt;This post is a &lt;a href=&#34;/thoughts/&#34; class=&#34;wikilink&#34; data-title=&#34;Thoughts&#34; data-description=&#34;These are generally my thoughts on a web page or some sort of url, except a rare few don&amp;#39;t have a link. These are dual published off of my...&#34; data-date=&#34;2024-04-01&#34; data-preview=&#34;These are generally my thoughts on a web page or some sort of url, except a rare few don&amp;#39;t have a link. These are dual published off of my...&#34;&gt;thought&lt;/a&gt;. It’s a short note that I make&#xA;about someone else’s content online &lt;a href=&#34;/tags/thoughts/&#34; class=&#34;hashtag-tag&#34; data-tag=&#34;thoughts&#34; data-count=&#34;2&#34; data-reading-time=&#34;3&#34; data-reading-time-text=&#34;3 minutes&#34;&gt;#thoughts&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/div&gt;&#xA;</content>
    <author>
      <name>Waylon Walker</name>
      <email>hello@waylonwalker.com</email>
      <uri>https://waylonwalker.com</uri>
    </author>
  </entry>
  <entry>
    <title>💭 API — Jinja Documentation</title>
    <id>https://waylonwalker.com/thought-68/</id>
    <updated>2023-08-04T23:35:09Z</updated>
    <published>2023-08-04T23:35:09Z</published>
    <link href="https://waylonwalker.com/thought-68/" rel="alternate" type="text/html"></link>
    <summary type="text">!https://jinja.palletsprojects.com/en/3.0.x/api/#jinja2.FileSystemLoader</summary>
    <content type="html">&lt;figure&gt;&#xA;![https://jinja.palletsprojects.com/en/3.0.x/api/&lt;a href=&#34;/tags/jinja2/&#34; class=&#34;hashtag-tag&#34; data-tag=&#34;jinja2&#34; data-count=&#34;1&#34; data-reading-time=&#34;1&#34; data-reading-time-text=&#34;1 minute&#34;&gt;#jinja2&lt;/a&gt;.FileSystemLoader](/static/https://jinja.palletsprojects.com/en/3.0.x/api/&lt;a href=&#34;/tags/jinja2/&#34; class=&#34;hashtag-tag&#34; data-tag=&#34;jinja2&#34; data-count=&#34;1&#34; data-reading-time=&#34;1&#34; data-reading-time-text=&#34;1 minute&#34;&gt;#jinja2&lt;/a&gt;.FileSystemLoader)&#xA;&lt;/figure&gt;&#xA;&lt;p&gt;I’ve definitely been missing out on setting up a proper jinja loader on a few projects, I need to lean on this a bit more.&lt;/p&gt;&#xA;&lt;pre class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;class&lt;/span&gt; &lt;span class=&#34;nc&#34;&gt;jinja2&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;FileSystemLoader&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;searchpath&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;encoding&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;utf-8&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;followlinks&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;kc&#34;&gt;False&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;):&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;s1&#34;&gt;&amp;#39;&amp;#39;&amp;#39;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;s1&#34;&gt;    Load templates from a directory in the file system.&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;s1&#34;&gt;    &amp;#39;&amp;#39;&amp;#39;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;blockquote&gt;&#xA;&lt;p&gt;The path can be relative or absolute. Relative paths are relative to the current working directory.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;pre class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;loader&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;FileSystemLoader&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;templates&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;# A list of paths can be given. The directories will be searched in order, stopping at the first matching template.&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;loader&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;FileSystemLoader&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;([&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;/override/templates&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;/default/templates&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;])&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&#34;admonition note&#34;&gt;&#xA;&lt;p class=&#34;admonition-title&#34;&gt;Note&lt;/p&gt;&#xA;&lt;p&gt;This post is a &lt;a href=&#34;/thoughts/&#34; class=&#34;wikilink&#34; data-title=&#34;Thoughts&#34; data-description=&#34;These are generally my thoughts on a web page or some sort of url, except a rare few don&amp;#39;t have a link. These are dual published off of my...&#34; data-date=&#34;2024-04-01&#34; data-preview=&#34;These are generally my thoughts on a web page or some sort of url, except a rare few don&amp;#39;t have a link. These are dual published off of my...&#34;&gt;thought&lt;/a&gt;. It’s a short note that I make&#xA;about someone else’s content online &lt;a href=&#34;/tags/thoughts/&#34; class=&#34;hashtag-tag&#34; data-tag=&#34;thoughts&#34; data-count=&#34;2&#34; data-reading-time=&#34;3&#34; data-reading-time-text=&#34;3 minutes&#34;&gt;#thoughts&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/div&gt;&#xA;</content>
    <author>
      <name>Waylon Walker</name>
      <email>hello@waylonwalker.com</email>
      <uri>https://waylonwalker.com</uri>
    </author>
  </entry>
</feed>