Synchronized build

This commit is contained in:
Lektor Bot 2022-05-02 22:53:59 +00:00
parent e904e2e598
commit f1792c9e0f
189 changed files with 389 additions and 389 deletions

View File

@ -196,7 +196,7 @@ instances.</p>
<p>The most important function of an artifact is <a href="open/" class="ref">open</a> which can
open the artifact for reading or writing. If the build goes well, Lektor
will commit those changes and persist them.</p>
<h2 id="example">Example</h2><div class="highlight"><pre><span></span><span class="n">ctx</span> <span class="o">=</span> <span class="n">get_ctx</span><span class="p">()</span>
<h2 id="example">Example</h2><div class="hll"><pre><span></span><span class="n">ctx</span> <span class="o">=</span> <span class="n">get_ctx</span><span class="p">()</span>
<span class="nd">@ctx</span><span class="o">.</span><span class="n">sub_artifact</span><span class="p">(</span><span class="s1">&#39;artifact.txt&#39;</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">build_stylesheet</span><span class="p">(</span><span class="n">artifact</span><span class="p">):</span>
<span class="k">with</span> <span class="n">artifact</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="s1">&#39;w&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>

View File

@ -196,7 +196,7 @@ automatically is created. This can be disabled or enabled with the
<p>If the artifact is opened for writing, a copy will be created and only
committed when the entire build process goes through smoothly and the
changes are committed by the builder.</p>
<h2 id="example">Example</h2><div class="highlight"><pre><span></span><span class="n">ctx</span> <span class="o">=</span> <span class="n">get_ctx</span><span class="p">()</span>
<h2 id="example">Example</h2><div class="hll"><pre><span></span><span class="n">ctx</span> <span class="o">=</span> <span class="n">get_ctx</span><span class="p">()</span>
<span class="nd">@ctx</span><span class="o">.</span><span class="n">sub_artifact</span><span class="p">(</span><span class="s1">&#39;artifact.txt&#39;</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">build_stylesheet</span><span class="p">(</span><span class="n">artifact</span><span class="p">):</span>
<span class="k">with</span> <span class="n">artifact</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="s1">&#39;w&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>

View File

@ -194,7 +194,7 @@ catch the error and render it into the template with a failure marker. This
can be changed with the <code>fail</code> parameter. This is similar to the behavior of
the <a href="../../../environment/render-template/" class="ref">render_template</a> method of the
environment.</p>
<h2 id="example">Example</h2><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">MyBuildProgram</span><span class="p">(</span><span class="n">BuildProgram</span><span class="p">):</span>
<h2 id="example">Example</h2><div class="hll"><pre><span></span><span class="k">class</span> <span class="nc">MyBuildProgram</span><span class="p">(</span><span class="n">BuildProgram</span><span class="p">):</span>
<span class="o">...</span>
<span class="k">def</span> <span class="nf">build_artifact</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">artifact</span><span class="p">):</span>

View File

@ -193,7 +193,7 @@
on commit. This is useful when you are dealing with external applications
that create temporaries. By default the file is moved as this is what's
common with temporaries but this can be changed into a copy with <code>copy=True</code>.</p>
<h2 id="example">Example</h2><div class="highlight"><pre><span></span><span class="n">ctx</span> <span class="o">=</span> <span class="n">get_ctx</span><span class="p">()</span>
<h2 id="example">Example</h2><div class="hll"><pre><span></span><span class="n">ctx</span> <span class="o">=</span> <span class="n">get_ctx</span><span class="p">()</span>
<span class="nd">@ctx</span><span class="o">.</span><span class="n">sub_artifact</span><span class="p">(</span><span class="s1">&#39;artifact.txt&#39;</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">build_stylesheet</span><span class="p">(</span><span class="n">artifact</span><span class="p">):</span>
<span class="n">temporary_file</span> <span class="o">=</span> <span class="n">invoke_external_program</span><span class="p">()</span>

View File

@ -199,7 +199,7 @@
but in some cases this can lead to issues when plugins attempt more complex
operations. In these cases the base URL can temporarily be overridden
with this method.</p>
<h2 id="example">Example</h2><div class="highlight"><pre><span></span><span class="k">with</span> <span class="n">get_ctx</span><span class="p">()</span><span class="o">.</span><span class="n">changed_base_url</span><span class="p">(</span><span class="s1">&#39;/downloads/&#39;</span><span class="p">):</span>
<h2 id="example">Example</h2><div class="hll"><pre><span></span><span class="k">with</span> <span class="n">get_ctx</span><span class="p">()</span><span class="o">.</span><span class="n">changed_base_url</span><span class="p">(</span><span class="s1">&#39;/downloads/&#39;</span><span class="p">):</span>
<span class="n">url</span> <span class="o">=</span> <span class="n">url_to</span><span class="p">(</span><span class="s1">&#39;/&#39;</span><span class="p">)</span>
</pre></div>

View File

@ -200,7 +200,7 @@ automatically track dependencies. However in some cases it might be
useful for a plugin to know exactly which dependencies are recorded.</p>
<p>In this case this method can be used as a context manager. Whenever Lektor
encounters a dependency it will invoke the passed function.</p>
<h2 id="example">Example</h2><div class="highlight"><pre><span></span><span class="n">deps</span> <span class="o">=</span> <span class="nb">set</span><span class="p">()</span>
<h2 id="example">Example</h2><div class="hll"><pre><span></span><span class="n">deps</span> <span class="o">=</span> <span class="nb">set</span><span class="p">()</span>
<span class="k">with</span> <span class="n">get_ctx</span><span class="p">()</span><span class="o">.</span><span class="n">gather_dependencies</span><span class="p">(</span><span class="n">deps</span><span class="o">.</span><span class="n">add</span><span class="p">):</span>
<span class="n">items</span> <span class="o">=</span> <span class="n">pad</span><span class="o">.</span><span class="n">query</span><span class="p">(</span><span class="s1">&#39;/path/to/some/pages&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">all</span><span class="p">()</span>
<span class="nb">print</span><span class="p">(</span><span class="s1">&#39;The dependencies are: </span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="n">deps</span><span class="p">)</span>

View File

@ -200,7 +200,7 @@ will look at the context to decide on further operations to perform.</p>
<p>The current context can be discovered by calling the <a href="../get-ctx/" class="ref">get_ctx</a>
function which will return it. If there is no artifact build ongoing then
the return value will be <code>None</code>.</p>
<h2 id="basic-example">Basic Example</h2><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">lektor.context</span> <span class="kn">import</span> <span class="n">get_ctx</span>
<h2 id="basic-example">Basic Example</h2><div class="hll"><pre><span></span><span class="kn">from</span> <span class="nn">lektor.context</span> <span class="kn">import</span> <span class="n">get_ctx</span>
<span class="n">ctx</span> <span class="o">=</span> <span class="n">get_ctx</span><span class="p">()</span>
<span class="nb">print</span><span class="p">(</span><span class="s1">&#39;The current source is </span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="n">ctx</span><span class="o">.</span><span class="n">source</span><span class="p">)</span>

View File

@ -200,7 +200,7 @@ term for language and territory) the context provides this information. It's
automatically resolved based on configuration from the current alt.</p>
<p>This is primarily useful for plugins that want to change their behavior based
on the current requested language.</p>
<h2 id="example">Example</h2><div class="highlight"><pre><span></span><span class="nb">print</span> <span class="n">get_ctx</span><span class="p">()</span><span class="o">.</span><span class="n">locale</span>
<h2 id="example">Example</h2><div class="hll"><pre><span></span><span class="nb">print</span> <span class="n">get_ctx</span><span class="p">()</span><span class="o">.</span><span class="n">locale</span>
</pre></div>

View File

@ -197,7 +197,7 @@
<p>To access the current pad from the context, this attribute can be used. It
refers to the active <a href="../../../db/pad/" class="ref">Pad</a>.</p>
<h2 id="example">Example</h2><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">lektor.context</span> <span class="kn">import</span> <span class="n">get_ctx</span>
<h2 id="example">Example</h2><div class="hll"><pre><span></span><span class="kn">from</span> <span class="nn">lektor.context</span> <span class="kn">import</span> <span class="n">get_ctx</span>
<span class="n">ctx</span> <span class="o">=</span> <span class="n">get_ctx</span><span class="p">()</span>
<span class="k">for</span> <span class="n">child</span> <span class="ow">in</span> <span class="n">ctx</span><span class="o">.</span><span class="n">pad</span><span class="o">.</span><span class="n">root</span><span class="o">.</span><span class="n">children</span><span class="p">:</span>

View File

@ -208,7 +208,7 @@ to record this as a dependency.</p>
is possible to dependend to things outside of it, but the automatic watch
system of the builder will not track files there so they will not show up
unless a manual build is instructed.</p>
<h2 id="example">Example</h2><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">os</span>
<h2 id="example">Example</h2><div class="hll"><pre><span></span><span class="kn">import</span> <span class="nn">os</span>
<span class="kn">from</span> <span class="nn">lektor.pluginsystem</span> <span class="kn">import</span> <span class="n">Plugin</span>
<span class="k">class</span> <span class="nc">IncludeFilePlugin</span><span class="p">(</span><span class="n">Plugin</span><span class="p">):</span>

View File

@ -198,7 +198,7 @@
<p>This works almost exactly like the <a href="../source/" class="ref">source</a> property but the
difference is that it is <code>None</code> if the source object is not a
<a href="../../../db/record/" class="ref">Record</a>.</p>
<h2 id="example">Example</h2><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">lektor.context</span> <span class="kn">import</span> <span class="n">get_ctx</span>
<h2 id="example">Example</h2><div class="hll"><pre><span></span><span class="kn">from</span> <span class="nn">lektor.context</span> <span class="kn">import</span> <span class="n">get_ctx</span>
<span class="n">ctx</span> <span class="o">=</span> <span class="n">get_ctx</span><span class="p">()</span>
<span class="nb">print</span> <span class="n">ctx</span><span class="o">.</span><span class="n">record</span><span class="o">.</span><span class="n">record_label</span>

View File

@ -199,7 +199,7 @@
created from <a href="../../../db/obj/" class="ref">Source Objects</a>, it's typically possible
to refer back to it. Note that there are situations in which artifacts are
created but no source is available. In this case the value will be <code>None</code>.</p>
<h2 id="example">Example</h2><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">lektor.context</span> <span class="kn">import</span> <span class="n">get_ctx</span>
<h2 id="example">Example</h2><div class="hll"><pre><span></span><span class="kn">from</span> <span class="nn">lektor.context</span> <span class="kn">import</span> <span class="n">get_ctx</span>
<span class="n">ctx</span> <span class="o">=</span> <span class="n">get_ctx</span><span class="p">()</span>
<span class="nb">print</span> <span class="n">ctx</span><span class="o">.</span><span class="n">source</span><span class="o">.</span><span class="n">source_filename</span>

View File

@ -213,7 +213,7 @@ artifact is already considered up to date.</p>
provided it can identify the configuration that the artifact was created
from. If the hash changes the artifact will be rebuilt. Such a hash
can for instance be generated with <a href="../../../utils/get-structure-hash/" class="ref">get_structure_hash</a>.</p>
<h2 id="example">Example</h2><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">os</span>
<h2 id="example">Example</h2><div class="hll"><pre><span></span><span class="kn">import</span> <span class="nn">os</span>
<span class="kn">from</span> <span class="nn">lektor.pluginsystem</span> <span class="kn">import</span> <span class="n">Plugin</span>
<span class="k">class</span> <span class="nc">IncludeFilePlugin</span><span class="p">(</span><span class="n">Plugin</span><span class="p">):</span>
@ -229,7 +229,7 @@ can for instance be generated with <a href="../../../utils/get-structure-hash/"
<span class="bp">self</span><span class="o">.</span><span class="n">env</span><span class="o">.</span><span class="n">jinja_env</span><span class="o">.</span><span class="n">globals</span><span class="p">[</span><span class="s1">&#39;get_demo_css&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">get_css</span>
</pre></div>
<p>Inside a template it can be used like this:</p>
<div class="highlight"><pre><span></span><span class="p">&lt;</span><span class="nt">link</span> <span class="na">rel</span><span class="o">=</span><span class="s">stylesheet</span> <span class="na">href</span><span class="o">=</span><span class="s">&quot;</span><span class="cp">{{</span> <span class="nv">get_demo_css</span><span class="o">()|</span><span class="nf">url</span> <span class="cp">}}</span><span class="s">&quot;</span><span class="p">&gt;</span>
<div class="hll"><pre><span></span><span class="p">&lt;</span><span class="nt">link</span> <span class="na">rel</span><span class="o">=</span><span class="s">stylesheet</span> <span class="na">href</span><span class="o">=</span><span class="s">&quot;</span><span class="cp">{{</span> <span class="nv">get_demo_css</span><span class="o">()|</span><span class="nf">url</span> <span class="cp">}}</span><span class="s">&quot;</span><span class="p">&gt;</span>
</pre></div>

View File

@ -174,7 +174,7 @@ if not. This means that if plugins only call that method in places where
they know a build is access it's not necessary to check if the context is
available.</p>
<p>For more information: <a href="../context/" class="ref">Context</a>.</p>
<h2 id="example">Example</h2><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">lektor.context</span> <span class="kn">import</span> <span class="n">get_ctx</span>
<h2 id="example">Example</h2><div class="hll"><pre><span></span><span class="kn">from</span> <span class="nn">lektor.context</span> <span class="kn">import</span> <span class="n">get_ctx</span>
<span class="n">ctx</span> <span class="o">=</span> <span class="n">get_ctx</span><span class="p">()</span>
</pre></div>

View File

@ -189,7 +189,7 @@
<p>Optionally a builder can yield further sources that are then picked up by the
builder and processed normally. This is how the recursive build process in
Lektor is implemented for normal records.</p>
<h2 id="example">Example</h2><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">iter_child_sources</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<h2 id="example">Example</h2><div class="hll"><pre><span></span><span class="k">def</span> <span class="nf">iter_child_sources</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="k">for</span> <span class="n">child</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">sources</span><span class="o">.</span><span class="n">children</span><span class="p">:</span>
<span class="k">yield</span> <span class="n">child</span>
</pre></div>

View File

@ -197,11 +197,11 @@ which can for instance be used with the <a href="../templates/filters/tojson/" c
filter.</p>
<h2 id="example-databag">Example Databag</h2><p>This is a basic example of a data bag that contains configuration values
for google maps. It's stored in <code>databags/gmaps.ini</code>:</p>
<div class="highlight"><pre><span></span><span class="na">key</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">1233456ABCDEFG</span><span class="w"></span>
<div class="hll"><pre><span></span><span class="na">key</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">1233456ABCDEFG</span><span class="w"></span>
<span class="na">api_url</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">https://www.google.com/maps/embed/v1/</span><span class="w"></span>
</pre></div>
<p>This can then be usde to good effect in templates:</p>
<div class="highlight"><pre><span></span><span class="cp">{%</span> <span class="k">macro</span> <span class="nv">render_map</span><span class="o">(</span><span class="nv">location</span><span class="o">,</span> <span class="nv">width</span><span class="o">=</span><span class="m">600</span><span class="o">,</span> <span class="nv">height</span><span class="o">=</span><span class="m">450</span><span class="o">)</span> <span class="cp">%}</span>
<div class="hll"><pre><span></span><span class="cp">{%</span> <span class="k">macro</span> <span class="nv">render_map</span><span class="o">(</span><span class="nv">location</span><span class="o">,</span> <span class="nv">width</span><span class="o">=</span><span class="m">600</span><span class="o">,</span> <span class="nv">height</span><span class="o">=</span><span class="m">450</span><span class="o">)</span> <span class="cp">%}</span>
<span class="p">&lt;</span><span class="nt">iframe</span>
<span class="na">width</span><span class="o">=</span><span class="s">&quot;</span><span class="cp">{{</span> <span class="nv">width</span> <span class="cp">}}</span><span class="s">&quot;</span> <span class="na">height</span><span class="o">=</span><span class="s">&quot;</span><span class="cp">{{</span> <span class="nv">height</span> <span class="cp">}}</span><span class="s">&quot;</span>
<span class="na">frameborder</span><span class="o">=</span><span class="s">&quot;0&quot;</span> <span class="na">style</span><span class="o">=</span><span class="s">&quot;border:0&quot;</span>

View File

@ -167,7 +167,7 @@
Python code. Within templates you can also use the <a href="../../templates/globals/bag/" class="ref">bag</a> function which is easier to call.</p>
<p>The key is in dotted notation. For more information about this refer
to the main <a href="../" class="ref">databags</a> documentation.</p>
<h2 id="example">Example</h2><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">translate</span><span class="p">(</span><span class="n">pad</span><span class="p">,</span> <span class="n">alt</span><span class="p">,</span> <span class="n">key</span><span class="p">):</span>
<h2 id="example">Example</h2><div class="hll"><pre><span></span><span class="k">def</span> <span class="nf">translate</span><span class="p">(</span><span class="n">pad</span><span class="p">,</span> <span class="n">alt</span><span class="p">,</span> <span class="n">key</span><span class="p">):</span>
<span class="k">return</span> <span class="n">pad</span><span class="o">.</span><span class="n">databags</span><span class="o">.</span><span class="n">lookup</span><span class="p">(</span><span class="s1">&#39;i18n.</span><span class="si">%s</span><span class="s1">.</span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="n">alt</span><span class="p">,</span> <span class="n">key</span><span class="p">),</span> <span class="n">key</span><span class="p">)</span>
</pre></div>

View File

@ -237,7 +237,7 @@
expression on the right are true. This is one of the few operators that
differs between Python and templates. In templates you have to use the
<code>and</code> method whereas in Python have to use the <code>&amp;</code> operator.</p>
<h2 id="template-example">Template Example</h2><div class="highlight"><pre><span></span><span class="p">&lt;</span><span class="nt">h3</span><span class="p">&gt;</span>3 Star or Higher<span class="p">&lt;/</span><span class="nt">h3</span><span class="p">&gt;</span>
<h2 id="template-example">Template Example</h2><div class="hll"><pre><span></span><span class="p">&lt;</span><span class="nt">h3</span><span class="p">&gt;</span>3 Star or Higher<span class="p">&lt;/</span><span class="nt">h3</span><span class="p">&gt;</span>
<span class="p">&lt;</span><span class="nt">ul</span><span class="p">&gt;</span>
<span class="cp">{%</span> <span class="k">for</span> <span class="nv">item</span> <span class="k">in</span> <span class="nv">this.children.filter</span><span class="o">(</span>
<span class="o">(</span><span class="nv">F.type</span> <span class="o">==</span> <span class="s1">&#39;hotel&#39;</span><span class="o">)</span><span class="nv">.and</span><span class="o">(</span><span class="nv">F.stars</span> <span class="o">&gt;=</span> <span class="m">3</span><span class="o">))</span> <span class="cp">%}</span>
@ -245,7 +245,7 @@ differs between Python and templates. In templates you have to use the
<span class="cp">{%</span> <span class="k">endfor</span> <span class="cp">%}</span>
<span class="p">&lt;/</span><span class="nt">ul</span><span class="p">&gt;</span>
</pre></div>
<h2 id="python-example">Python Example</h2><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">get_hotels</span><span class="p">(</span><span class="n">page</span><span class="p">):</span>
<h2 id="python-example">Python Example</h2><div class="hll"><pre><span></span><span class="k">def</span> <span class="nf">get_hotels</span><span class="p">(</span><span class="n">page</span><span class="p">):</span>
<span class="k">return</span> <span class="n">page</span><span class="o">.</span><span class="n">children</span><span class="o">.</span><span class="n">filter</span><span class="p">(</span>
<span class="p">(</span><span class="n">F</span><span class="o">.</span><span class="n">type</span> <span class="o">==</span> <span class="s1">&#39;hotel&#39;</span><span class="p">)</span> <span class="o">&amp;</span> <span class="p">(</span><span class="n">F</span><span class="o">.</span><span class="n">stars</span> <span class="o">&gt;=</span> <span class="mi">3</span><span class="p">))</span>
</pre></div>

View File

@ -234,7 +234,7 @@
<p>This expression evaluates to true if an item is contained within a field.
This works with fields that are lists in nature or <a href="../../types/string/" class="ref">strings</a>. For instance a string can be
contained in another string or a item can be contained within a list.</p>
<h2 id="template-example">Template Example</h2><div class="highlight"><pre><span></span><span class="p">&lt;</span><span class="nt">h3</span><span class="p">&gt;</span>Projects Tagged &#39;amazing&#39;<span class="p">&lt;/</span><span class="nt">h3</span><span class="p">&gt;</span>
<h2 id="template-example">Template Example</h2><div class="hll"><pre><span></span><span class="p">&lt;</span><span class="nt">h3</span><span class="p">&gt;</span>Projects Tagged &#39;amazing&#39;<span class="p">&lt;/</span><span class="nt">h3</span><span class="p">&gt;</span>
<span class="p">&lt;</span><span class="nt">ul</span><span class="p">&gt;</span>
<span class="cp">{%</span> <span class="k">for</span> <span class="nv">item</span> <span class="k">in</span> <span class="nv">this.children.filter</span><span class="o">(</span><span class="nv">F.tags.contains</span><span class="o">(</span><span class="s1">&#39;amazing&#39;</span><span class="o">))</span> <span class="cp">%}</span>
<span class="p">&lt;</span><span class="nt">li</span><span class="p">&gt;</span><span class="cp">{{</span> <span class="nv">item.name</span> <span class="cp">}}</span><span class="p">&lt;/</span><span class="nt">li</span><span class="p">&gt;</span>

View File

@ -235,7 +235,7 @@
on the left side ends with the string on the right side. This method
operates in a case-sensitive manner. For the case-insensitive method
see <a href="../endswith/" class="ref">endswith</a>.</p>
<h2 id="example">Example</h2><div class="highlight"><pre><span></span><span class="p">&lt;</span><span class="nt">ul</span><span class="p">&gt;</span>
<h2 id="example">Example</h2><div class="hll"><pre><span></span><span class="p">&lt;</span><span class="nt">ul</span><span class="p">&gt;</span>
<span class="cp">{%</span> <span class="k">for</span> <span class="nv">item</span> <span class="k">in</span> <span class="nv">this.children.filter</span><span class="o">(</span><span class="nv">F.name.endswith_cs</span><span class="o">(</span><span class="s1">&#39;House&#39;</span><span class="o">))</span> <span class="cp">%}</span>
<span class="p">&lt;</span><span class="nt">li</span><span class="p">&gt;</span><span class="cp">{{</span> <span class="nv">item.name</span> <span class="cp">}}</span><span class="p">&lt;/</span><span class="nt">li</span><span class="p">&gt;</span>
<span class="cp">{%</span> <span class="k">endfor</span> <span class="cp">%}</span>

View File

@ -235,7 +235,7 @@
on the left side ends with the string on the right side. This method
operates in a case-insensitive manner. For the case-sensitive method
see <a href="../endswith-cs/" class="ref">endswith_cs</a>.</p>
<h2 id="example">Example</h2><div class="highlight"><pre><span></span><span class="p">&lt;</span><span class="nt">ul</span><span class="p">&gt;</span>
<h2 id="example">Example</h2><div class="hll"><pre><span></span><span class="p">&lt;</span><span class="nt">ul</span><span class="p">&gt;</span>
<span class="cp">{%</span> <span class="k">for</span> <span class="nv">item</span> <span class="k">in</span> <span class="nv">this.children.filter</span><span class="o">(</span><span class="nv">F.name.endswith</span><span class="o">(</span><span class="s1">&#39;house&#39;</span><span class="o">))</span> <span class="cp">%}</span>
<span class="p">&lt;</span><span class="nt">li</span><span class="p">&gt;</span><span class="cp">{{</span> <span class="nv">item.name</span> <span class="cp">}}</span><span class="p">&lt;/</span><span class="nt">li</span><span class="p">&gt;</span>
<span class="cp">{%</span> <span class="k">endfor</span> <span class="cp">%}</span>

View File

@ -233,7 +233,7 @@
<p>This checks if the left side of the expression matches the right side.
Typically it compares if a value matches a specific value exactly:</p>
<h2 id="example">Example</h2><div class="highlight"><pre><span></span><span class="p">&lt;</span><span class="nt">h2</span><span class="p">&gt;</span>Our Houses<span class="p">&lt;/</span><span class="nt">h2</span><span class="p">&gt;</span>
<h2 id="example">Example</h2><div class="hll"><pre><span></span><span class="p">&lt;</span><span class="nt">h2</span><span class="p">&gt;</span>Our Houses<span class="p">&lt;/</span><span class="nt">h2</span><span class="p">&gt;</span>
<span class="p">&lt;</span><span class="nt">ul</span><span class="p">&gt;</span>
<span class="cp">{%</span> <span class="k">for</span> <span class="nv">project</span> <span class="k">in</span> <span class="nv">this.children.filter</span><span class="o">(</span><span class="nv">F.type</span> <span class="o">==</span> <span class="s1">&#39;house&#39;</span><span class="o">)</span> <span class="cp">%}</span>
<span class="p">&lt;</span><span class="nt">li</span><span class="p">&gt;</span><span class="cp">{{</span> <span class="nv">project.name</span> <span class="cp">}}</span><span class="p">&lt;/</span><span class="nt">li</span><span class="p">&gt;</span>

View File

@ -233,7 +233,7 @@
<p>This evaluates to true if the left side compares larger than the right side
or equal to it. This behavior works best with <a href="../../types/integer/" class="ref">integers</a> or <a href="../../types/float/" class="ref">floats</a>.</p>
<h2 id="template-example">Template Example</h2><div class="highlight"><pre><span></span><span class="p">&lt;</span><span class="nt">h3</span><span class="p">&gt;</span>3 or more Stars<span class="p">&lt;/</span><span class="nt">h3</span><span class="p">&gt;</span>
<h2 id="template-example">Template Example</h2><div class="hll"><pre><span></span><span class="p">&lt;</span><span class="nt">h3</span><span class="p">&gt;</span>3 or more Stars<span class="p">&lt;/</span><span class="nt">h3</span><span class="p">&gt;</span>
<span class="p">&lt;</span><span class="nt">ul</span><span class="p">&gt;</span>
<span class="cp">{%</span> <span class="k">for</span> <span class="nv">item</span> <span class="k">in</span> <span class="nv">this.children.filter</span><span class="o">(</span><span class="nv">F.stars</span> <span class="o">&gt;=</span> <span class="m">3</span><span class="o">)</span> <span class="cp">%}</span>
<span class="p">&lt;</span><span class="nt">li</span><span class="p">&gt;</span><span class="cp">{{</span> <span class="nv">item.name</span> <span class="cp">}}</span>: <span class="cp">{{</span> <span class="nv">item.stars</span> <span class="cp">}}</span> stars<span class="p">&lt;/</span><span class="nt">li</span><span class="p">&gt;</span>

View File

@ -234,7 +234,7 @@
<p>This evaluates to true if the left side compares larger than the right side.
This behavior works best with <a href="../../types/integer/" class="ref">integers</a>
or <a href="../../types/float/" class="ref">floats</a>.</p>
<h2 id="template-example">Template Example</h2><div class="highlight"><pre><span></span><span class="p">&lt;</span><span class="nt">h3</span><span class="p">&gt;</span>Well Rated Items<span class="p">&lt;/</span><span class="nt">h3</span><span class="p">&gt;</span>
<h2 id="template-example">Template Example</h2><div class="hll"><pre><span></span><span class="p">&lt;</span><span class="nt">h3</span><span class="p">&gt;</span>Well Rated Items<span class="p">&lt;/</span><span class="nt">h3</span><span class="p">&gt;</span>
<span class="p">&lt;</span><span class="nt">ul</span><span class="p">&gt;</span>
<span class="cp">{%</span> <span class="k">for</span> <span class="nv">item</span> <span class="k">in</span> <span class="nv">this.children.filter</span><span class="o">(</span><span class="nv">F.stars</span> <span class="o">&gt;</span> <span class="m">3</span><span class="o">)</span> <span class="cp">%}</span>
<span class="p">&lt;</span><span class="nt">li</span><span class="p">&gt;</span><span class="cp">{{</span> <span class="nv">item.name</span> <span class="cp">}}</span>: <span class="cp">{{</span> <span class="nv">item.stars</span> <span class="cp">}}</span> stars<span class="p">&lt;/</span><span class="nt">li</span><span class="p">&gt;</span>

View File

@ -235,7 +235,7 @@ of it can create more expressive expressions. <code>F.name</code> literally jus
that a field by that name exists and is set to a value.</p>
<p>The query syntax is mostly the same in Python as well as in the Jinja 2
templates, the main difference are <a href="and/" class="ref">and</a> and <a href="or/" class="ref">or</a>.</p>
<h2 id="example">Example</h2><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="o">.</span><span class="n">children</span><span class="o">.</span><span class="n">filter</span><span class="p">((</span><span class="n">F</span><span class="o">.</span><span class="n">name</span> <span class="o">==</span> <span class="s1">&#39;foo&#39;</span><span class="p">)</span> <span class="o">|</span> <span class="p">(</span><span class="n">F</span><span class="o">.</span><span class="n">name</span> <span class="o">==</span> <span class="s1">&#39;bar&#39;</span><span class="p">))</span><span class="o">.</span><span class="n">all</span><span class="p">()</span>
<h2 id="example">Example</h2><div class="hll"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="o">.</span><span class="n">children</span><span class="o">.</span><span class="n">filter</span><span class="p">((</span><span class="n">F</span><span class="o">.</span><span class="n">name</span> <span class="o">==</span> <span class="s1">&#39;foo&#39;</span><span class="p">)</span> <span class="o">|</span> <span class="p">(</span><span class="n">F</span><span class="o">.</span><span class="n">name</span> <span class="o">==</span> <span class="s1">&#39;bar&#39;</span><span class="p">))</span><span class="o">.</span><span class="n">all</span><span class="p">()</span>
<span class="go">[&lt;Page model=u&#39;page&#39; id=u&#39;bar&#39;&gt;, &lt;Page model=u&#39;page&#39; id=u&#39;foo&#39;&gt;]</span>
</pre></div>

View File

@ -233,7 +233,7 @@
<p>This evaluates to true if the left side compares smaller than the right side
or equal to it. This behavior works best with <a href="../../types/integer/" class="ref">integers</a> or <a href="../../types/float/" class="ref">floats</a>.</p>
<h2 id="template-example">Template Example</h2><div class="highlight"><pre><span></span><span class="p">&lt;</span><span class="nt">h3</span><span class="p">&gt;</span>Projects From Before Including 2000<span class="p">&lt;/</span><span class="nt">h3</span><span class="p">&gt;</span>
<h2 id="template-example">Template Example</h2><div class="hll"><pre><span></span><span class="p">&lt;</span><span class="nt">h3</span><span class="p">&gt;</span>Projects From Before Including 2000<span class="p">&lt;/</span><span class="nt">h3</span><span class="p">&gt;</span>
<span class="p">&lt;</span><span class="nt">ul</span><span class="p">&gt;</span>
<span class="cp">{%</span> <span class="k">for</span> <span class="nv">item</span> <span class="k">in</span> <span class="nv">this.children.filter</span><span class="o">(</span><span class="nv">F.year</span> <span class="o">&lt;=</span> <span class="m">2000</span><span class="o">)</span> <span class="cp">%}</span>
<span class="p">&lt;</span><span class="nt">li</span><span class="p">&gt;</span><span class="cp">{{</span> <span class="nv">item.name</span> <span class="cp">}}</span> (<span class="cp">{{</span> <span class="nv">item.year</span> <span class="cp">}}</span>)<span class="p">&lt;/</span><span class="nt">li</span><span class="p">&gt;</span>

View File

@ -233,7 +233,7 @@
<p>This evaluates to true if the left side compares smaller than the right side
or equal to it. This behavior works best with <a href="../../types/integer/" class="ref">integers</a> or <a href="../../types/float/" class="ref">floats</a>.</p>
<h2 id="template-example">Template Example</h2><div class="highlight"><pre><span></span><span class="p">&lt;</span><span class="nt">h3</span><span class="p">&gt;</span>Projects From Before 2000<span class="p">&lt;/</span><span class="nt">h3</span><span class="p">&gt;</span>
<h2 id="template-example">Template Example</h2><div class="hll"><pre><span></span><span class="p">&lt;</span><span class="nt">h3</span><span class="p">&gt;</span>Projects From Before 2000<span class="p">&lt;/</span><span class="nt">h3</span><span class="p">&gt;</span>
<span class="p">&lt;</span><span class="nt">ul</span><span class="p">&gt;</span>
<span class="cp">{%</span> <span class="k">for</span> <span class="nv">item</span> <span class="k">in</span> <span class="nv">this.children.filter</span><span class="o">(</span><span class="nv">F.year</span> <span class="o">&lt;</span> <span class="m">2000</span><span class="o">)</span> <span class="cp">%}</span>
<span class="p">&lt;</span><span class="nt">li</span><span class="p">&gt;</span><span class="cp">{{</span> <span class="nv">item.name</span> <span class="cp">}}</span> (<span class="cp">{{</span> <span class="nv">item.year</span> <span class="cp">}}</span>)<span class="p">&lt;/</span><span class="nt">li</span><span class="p">&gt;</span>

View File

@ -233,7 +233,7 @@
<p>This checks if the left side of the expression does not match the right side
by doing an exact comparison:</p>
<h2 id="example">Example</h2><div class="highlight"><pre><span></span><span class="p">&lt;</span><span class="nt">h2</span><span class="p">&gt;</span>Everything Other Than Houses<span class="p">&lt;/</span><span class="nt">h2</span><span class="p">&gt;</span>
<h2 id="example">Example</h2><div class="hll"><pre><span></span><span class="p">&lt;</span><span class="nt">h2</span><span class="p">&gt;</span>Everything Other Than Houses<span class="p">&lt;/</span><span class="nt">h2</span><span class="p">&gt;</span>
<span class="p">&lt;</span><span class="nt">ul</span><span class="p">&gt;</span>
<span class="cp">{%</span> <span class="k">for</span> <span class="nv">project</span> <span class="k">in</span> <span class="nv">this.children.filter</span><span class="o">(</span><span class="nv">F.type</span> <span class="o">!=</span> <span class="s1">&#39;house&#39;</span><span class="o">)</span> <span class="cp">%}</span>
<span class="p">&lt;</span><span class="nt">li</span><span class="p">&gt;</span><span class="cp">{{</span> <span class="nv">project.name</span> <span class="cp">}}</span><span class="p">&lt;/</span><span class="nt">li</span><span class="p">&gt;</span>

View File

@ -237,7 +237,7 @@
expression on the right are true. This is one of the few operators that
differs between Python and templates. In templates you have to use the
<code>or</code> method whereas in Python have to use the <code>|</code> operator.</p>
<h2 id="template-example">Template Example</h2><div class="highlight"><pre><span></span><span class="p">&lt;</span><span class="nt">h3</span><span class="p">&gt;</span>Hotels or Apartments<span class="p">&lt;/</span><span class="nt">h3</span><span class="p">&gt;</span>
<h2 id="template-example">Template Example</h2><div class="hll"><pre><span></span><span class="p">&lt;</span><span class="nt">h3</span><span class="p">&gt;</span>Hotels or Apartments<span class="p">&lt;/</span><span class="nt">h3</span><span class="p">&gt;</span>
<span class="p">&lt;</span><span class="nt">ul</span><span class="p">&gt;</span>
<span class="cp">{%</span> <span class="k">for</span> <span class="nv">item</span> <span class="k">in</span> <span class="nv">this.children.filter</span><span class="o">(</span>
<span class="o">(</span><span class="nv">F.type</span> <span class="o">==</span> <span class="s1">&#39;hotel&#39;</span><span class="o">)</span><span class="nv">.or</span><span class="o">(</span><span class="nv">F.type</span> <span class="o">==</span> <span class="s1">&#39;apartment&#39;</span><span class="o">))</span> <span class="cp">%}</span>
@ -245,7 +245,7 @@ differs between Python and templates. In templates you have to use the
<span class="cp">{%</span> <span class="k">endfor</span> <span class="cp">%}</span>
<span class="p">&lt;/</span><span class="nt">ul</span><span class="p">&gt;</span>
</pre></div>
<h2 id="python-example">Python Example</h2><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">get_hotels_or_apartments</span><span class="p">(</span><span class="n">page</span><span class="p">):</span>
<h2 id="python-example">Python Example</h2><div class="hll"><pre><span></span><span class="k">def</span> <span class="nf">get_hotels_or_apartments</span><span class="p">(</span><span class="n">page</span><span class="p">):</span>
<span class="k">return</span> <span class="n">page</span><span class="o">.</span><span class="n">children</span><span class="o">.</span><span class="n">filter</span><span class="p">(</span>
<span class="p">(</span><span class="n">F</span><span class="o">.</span><span class="n">type</span> <span class="o">==</span> <span class="s1">&#39;hotel&#39;</span><span class="p">)</span> <span class="o">|</span> <span class="p">(</span><span class="n">F</span><span class="o">.</span><span class="n">type</span> <span class="o">==</span> <span class="s1">&#39;apartment&#39;</span><span class="p">))</span>
</pre></div>

View File

@ -235,7 +235,7 @@
on the left side starts with the string on the right side. This method
operates in a case-sensitive manner. For the case-insensitive method
see <a href="../startswith/" class="ref">startswith</a>.</p>
<h2 id="example">Example</h2><div class="highlight"><pre><span></span><span class="p">&lt;</span><span class="nt">h1</span><span class="p">&gt;</span>A<span class="p">&lt;/</span><span class="nt">h1</span><span class="p">&gt;</span>
<h2 id="example">Example</h2><div class="hll"><pre><span></span><span class="p">&lt;</span><span class="nt">h1</span><span class="p">&gt;</span>A<span class="p">&lt;/</span><span class="nt">h1</span><span class="p">&gt;</span>
<span class="p">&lt;</span><span class="nt">ul</span><span class="p">&gt;</span>
<span class="cp">{%</span> <span class="k">for</span> <span class="nv">item</span> <span class="k">in</span> <span class="nv">this.children.filter</span><span class="o">(</span><span class="nv">F.name.startswith_cs</span><span class="o">(</span><span class="s1">&#39;A&#39;</span><span class="o">))</span> <span class="cp">%}</span>
<span class="p">&lt;</span><span class="nt">li</span><span class="p">&gt;</span><span class="cp">{{</span> <span class="nv">item.name</span> <span class="cp">}}</span><span class="p">&lt;/</span><span class="nt">li</span><span class="p">&gt;</span>

View File

@ -235,7 +235,7 @@
on the left side starts with the string on the right side. This method
operates in a case-insensitive manner. For the case-sensitive method
see <a href="../startswith-cs/" class="ref">startswith_cs</a>.</p>
<h2 id="example">Example</h2><div class="highlight"><pre><span></span><span class="p">&lt;</span><span class="nt">h1</span><span class="p">&gt;</span>A<span class="p">&lt;/</span><span class="nt">h1</span><span class="p">&gt;</span>
<h2 id="example">Example</h2><div class="hll"><pre><span></span><span class="p">&lt;</span><span class="nt">h1</span><span class="p">&gt;</span>A<span class="p">&lt;/</span><span class="nt">h1</span><span class="p">&gt;</span>
<span class="p">&lt;</span><span class="nt">ul</span><span class="p">&gt;</span>
<span class="cp">{%</span> <span class="k">for</span> <span class="nv">item</span> <span class="k">in</span> <span class="nv">this.children.filter</span><span class="o">(</span><span class="nv">F.name.startswith</span><span class="o">(</span><span class="s1">&#39;a&#39;</span><span class="o">))</span> <span class="cp">%}</span>
<span class="p">&lt;</span><span class="nt">li</span><span class="p">&gt;</span><span class="cp">{{</span> <span class="nv">item.name</span> <span class="cp">}}</span><span class="p">&lt;/</span><span class="nt">li</span><span class="p">&gt;</span>

View File

@ -195,7 +195,7 @@ field of an arbitrary record. This can be achieved with the <code>F</code> obje
attribute of it refers to a field in the record. To make this clearer, have a
look at the example below.</p>
<p>Accessing an attributes creates an <a href="../expression/" class="ref">Expression</a>.</p>
<h2 id="example">Example</h2><div class="highlight"><pre><span></span><span class="p">&lt;</span><span class="nt">ul</span><span class="p">&gt;</span>
<h2 id="example">Example</h2><div class="hll"><pre><span></span><span class="p">&lt;</span><span class="nt">ul</span><span class="p">&gt;</span>
<span class="cp">{%</span> <span class="k">for</span> <span class="nv">item</span> <span class="k">in</span> <span class="nv">this.children.filter</span><span class="o">(</span><span class="nv">F.status</span> <span class="o">==</span> <span class="s1">&#39;published&#39;</span><span class="o">)</span> <span class="cp">%}</span>
<span class="p">&lt;</span><span class="nt">li</span><span class="p">&gt;</span><span class="cp">{{</span> <span class="nv">item.title</span> <span class="cp">}}</span><span class="p">&lt;/</span><span class="nt">li</span><span class="p">&gt;</span>
<span class="cp">{%</span> <span class="k">endfor</span> <span class="cp">%}</span>

View File

@ -197,7 +197,7 @@ value is an empty list.</p>
<p>This returns only the list of alt short IDs. Access to the configured name
of the alt within the project config is not available. Databags should be
used to provide alts with a humand readable title.</p>
<h2 id="example">Example</h2><div class="highlight"><pre><span></span><span class="p">&lt;</span><span class="nt">p</span><span class="p">&gt;</span>Other languages:
<h2 id="example">Example</h2><div class="hll"><pre><span></span><span class="p">&lt;</span><span class="nt">p</span><span class="p">&gt;</span>Other languages:
<span class="p">&lt;</span><span class="nt">ul</span><span class="p">&gt;</span>
<span class="cp">{%</span> <span class="k">for</span> <span class="nv">alt</span> <span class="k">in</span> <span class="nv">get_alts</span><span class="o">(</span><span class="nv">this</span><span class="o">)</span> <span class="cp">%}</span>
<span class="p">&lt;</span><span class="nt">li</span><span class="p">&gt;&lt;</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">&quot;</span><span class="cp">{{</span> <span class="s1">&#39;.&#39;</span><span class="o">|</span><span class="nf">url</span><span class="o">(</span><span class="nv">alt</span><span class="o">=</span><span class="nv">alt</span><span class="o">)</span> <span class="cp">}}</span><span class="s">&quot;</span><span class="p">&gt;</span><span class="cp">{{</span> <span class="nv">alt</span><span class="o">|</span><span class="nf">title</span> <span class="cp">}}</span><span class="p">&lt;/</span><span class="nt">a</span><span class="p">&gt;&lt;/</span><span class="nt">li</span><span class="p">&gt;</span>

View File

@ -230,7 +230,7 @@
<p>For most source records there will be an associated <a href="../../../../content/alts/" class="ref">alt</a>. This attribute points to it. If the content
is not associated with an alt this can be <code>None</code>.</p>
<h2 id="example">Example</h2><div class="highlight"><pre><span></span><span class="cm">&lt;!-- generated from alt </span><span class="cp">{{</span> <span class="nv">this.alt</span> <span class="cp">}}</span><span class="cm"> --&gt;</span>
<h2 id="example">Example</h2><div class="hll"><pre><span></span><span class="cm">&lt;!-- generated from alt </span><span class="cp">{{</span> <span class="nv">this.alt</span> <span class="cp">}}</span><span class="cm"> --&gt;</span>
</pre></div>

View File

@ -248,7 +248,7 @@ in the path. The part after the at sign is called the “virtual path”.</p>
the record's path + <code>@source</code>. So if the record was <code>/hello</code> then the
path would be <code>/hello@source</code>. The true base record it belongs to can be
referenced from the <a href="record/" class="ref">record</a> property.</p>
<div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">lektor.sourceobj</span> <span class="kn">import</span> <span class="n">VirtualSourceObject</span>
<div class="hll"><pre><span></span><span class="kn">from</span> <span class="nn">lektor.sourceobj</span> <span class="kn">import</span> <span class="n">VirtualSourceObject</span>
<span class="kn">from</span> <span class="nn">lektor.utils</span> <span class="kn">import</span> <span class="n">build_url</span>
<span class="k">class</span> <span class="nc">Source</span><span class="p">(</span><span class="n">VirtualSourceObject</span><span class="p">):</span>

View File

@ -233,7 +233,7 @@ page or not. The default behavior is to consider a page to be a child of
itself as this is more convenient in most situations but this can be
changed with the <code>strict</code> parameter. This method is particularly useful
when building a navigation.</p>
<h2 id="example">Example</h2><div class="highlight"><pre><span></span><span class="p">&lt;</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">&quot;</span><span class="cp">{{</span> <span class="s1">&#39;/projects&#39;</span><span class="o">|</span><span class="nf">url</span> <span class="cp">}}</span><span class="s">&quot;</span><span class="cp">{%</span> <span class="k">if</span> <span class="nv">this.is_child_of</span><span class="o">(</span><span class="s1">&#39;/projects&#39;</span><span class="o">)</span>
<h2 id="example">Example</h2><div class="hll"><pre><span></span><span class="p">&lt;</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">&quot;</span><span class="cp">{{</span> <span class="s1">&#39;/projects&#39;</span><span class="o">|</span><span class="nf">url</span> <span class="cp">}}</span><span class="s">&quot;</span><span class="cp">{%</span> <span class="k">if</span> <span class="nv">this.is_child_of</span><span class="o">(</span><span class="s1">&#39;/projects&#39;</span><span class="o">)</span>
<span class="cp">%}</span> <span class="na">class</span><span class="o">=</span><span class="s">&quot;active&quot;</span><span class="cp">{%</span> <span class="k">endif</span> <span class="cp">%}</span><span class="p">&gt;</span>Projects<span class="p">&lt;/</span><span class="nt">a</span><span class="p">&gt;</span>
</pre></div>

View File

@ -241,7 +241,7 @@ to implement drafts of blog posts or similar things.</p>
<p>This property is implemented on the level of source objects to make it
possible to use this API in all cases. The default implementation of
source objects will always return <code>true</code> for discoverability checks.</p>
<h2 id="example">Example</h2><div class="highlight"><pre><span></span><span class="cp">{%</span> <span class="k">set</span> <span class="nv">downloads</span> <span class="o">=</span> <span class="nv">site.get</span><span class="o">(</span><span class="s1">&#39;/downloads&#39;</span><span class="o">)</span> <span class="cp">%}</span>
<h2 id="example">Example</h2><div class="hll"><pre><span></span><span class="cp">{%</span> <span class="k">set</span> <span class="nv">downloads</span> <span class="o">=</span> <span class="nv">site.get</span><span class="o">(</span><span class="s1">&#39;/downloads&#39;</span><span class="o">)</span> <span class="cp">%}</span>
<span class="cp">{%</span> <span class="k">if</span> <span class="nv">downloads.is_discoverable</span> <span class="cp">%}</span>
<span class="p">&lt;</span><span class="nt">p</span><span class="p">&gt;&lt;</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">&quot;</span><span class="cp">{{</span> <span class="nv">downloads</span><span class="o">|</span><span class="nf">url</span> <span class="cp">}}</span><span class="s">&quot;</span><span class="p">&gt;</span>Go to downloads<span class="p">&lt;/</span><span class="nt">a</span><span class="p">&gt;</span>
<span class="cp">{%</span> <span class="k">endif</span> <span class="cp">%}</span>

View File

@ -238,7 +238,7 @@ instance hidden pages can be used to store configuration values.</p>
<p>This property is implemented on the level of source objects to make it
possible to use this API in all cases though the default implementation for
source objects is that they are always visible.</p>
<h2 id="example">Example</h2><div class="highlight"><pre><span></span><span class="cp">{%</span> <span class="k">set</span> <span class="nv">downloads</span> <span class="o">=</span> <span class="nv">site.get</span><span class="o">(</span><span class="s1">&#39;/downloads&#39;</span><span class="o">)</span> <span class="cp">%}</span>
<h2 id="example">Example</h2><div class="hll"><pre><span></span><span class="cp">{%</span> <span class="k">set</span> <span class="nv">downloads</span> <span class="o">=</span> <span class="nv">site.get</span><span class="o">(</span><span class="s1">&#39;/downloads&#39;</span><span class="o">)</span> <span class="cp">%}</span>
<span class="cp">{%</span> <span class="k">if</span> <span class="nv">downloads.is_hidden</span> <span class="cp">%}</span>
<span class="p">&lt;</span><span class="nt">p</span><span class="p">&gt;</span>Downloads are currently unavailable
<span class="cp">{%</span> <span class="k">endif</span> <span class="cp">%}</span>

View File

@ -229,7 +229,7 @@
</ul>
<p>This is exactly the opposite of <a href="../is-hidden/" class="ref">is_hidden</a>.</p>
<h2 id="example">Example</h2><div class="highlight"><pre><span></span><span class="cp">{%</span> <span class="k">set</span> <span class="nv">downloads</span> <span class="o">=</span> <span class="nv">site.get</span><span class="o">(</span><span class="s1">&#39;/downloads&#39;</span><span class="o">)</span> <span class="cp">%}</span>
<h2 id="example">Example</h2><div class="hll"><pre><span></span><span class="cp">{%</span> <span class="k">set</span> <span class="nv">downloads</span> <span class="o">=</span> <span class="nv">site.get</span><span class="o">(</span><span class="s1">&#39;/downloads&#39;</span><span class="o">)</span> <span class="cp">%}</span>
<span class="cp">{%</span> <span class="k">if</span> <span class="nv">downloads.is_visible</span> <span class="cp">%}</span>
<span class="p">&lt;</span><span class="nt">p</span><span class="p">&gt;&lt;</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">&quot;</span><span class="cp">{{</span> <span class="nv">downloads</span><span class="o">|</span><span class="nf">url</span> <span class="cp">}}</span><span class="s">&quot;</span><span class="p">&gt;</span>go to downloads<span class="p">&lt;/</span><span class="nt">a</span><span class="p">&gt;</span>
<span class="cp">{%</span> <span class="k">endif</span> <span class="cp">%}</span>

View File

@ -232,7 +232,7 @@
this property. It's not a requirement that this property is implemented but
most will have it. In particular it's useful for virtual source objects
where this property can be used to discover the associated parent object.</p>
<h2 id="example">Example</h2><div class="highlight"><pre><span></span><span class="p">&lt;</span><span class="nt">p</span><span class="p">&gt;</span>My parent is: <span class="cp">{{</span> <span class="nv">this.parent.path</span> <span class="cp">}}</span>
<h2 id="example">Example</h2><div class="hll"><pre><span></span><span class="p">&lt;</span><span class="nt">p</span><span class="p">&gt;</span>My parent is: <span class="cp">{{</span> <span class="nv">this.parent.path</span> <span class="cp">}}</span>
</pre></div>

View File

@ -239,7 +239,7 @@ for virtual sources this refers back to the record that was associated with
the virtual source. Most of the time this matches <code>parent</code> but for nested
source objects it's useful to be able to refer back to the base in all cases
without having to walk up the parents.</p>
<h2 id="example">Example</h2><div class="highlight"><pre><span></span><span class="cp">{%</span> <span class="k">if</span> <span class="nv">this</span> <span class="o">!=</span> <span class="nv">this.record</span> <span class="cp">%}</span>
<h2 id="example">Example</h2><div class="hll"><pre><span></span><span class="cp">{%</span> <span class="k">if</span> <span class="nv">this</span> <span class="o">!=</span> <span class="nv">this.record</span> <span class="cp">%}</span>
<span class="p">&lt;</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">&quot;</span><span class="cp">{{</span> <span class="nv">this.record</span><span class="o">|</span><span class="nf">url</span> <span class="cp">}}</span><span class="s">&quot;</span><span class="p">&gt;</span>go back to overview<span class="p">&lt;/</span><span class="nt">a</span><span class="p">&gt;</span>
<span class="cp">{%</span> <span class="k">endif</span> <span class="cp">%}</span>
</pre></div>

View File

@ -232,7 +232,7 @@
instance if this is an asset it will be the path to it, if it is a record
it will be the path to the lektor contents file. The path is relative
to the project folder.</p>
<h2 id="example">Example</h2><div class="highlight"><pre><span></span><span class="p">&lt;</span><span class="nt">p</span><span class="p">&gt;</span>
<h2 id="example">Example</h2><div class="hll"><pre><span></span><span class="p">&lt;</span><span class="nt">p</span><span class="p">&gt;</span>
Generated from <span class="cp">{{</span> <span class="nv">this.source_filename</span> <span class="cp">}}</span>
<span class="p">&lt;/</span><span class="nt">p</span><span class="p">&gt;</span>
</pre></div>

View File

@ -239,7 +239,7 @@ domain part to the URL (if configured). The default behavior is to use the
configured URL style (which is <code>relative</code>) unless absolute or external were
explicitly provided. For more information read about this in the
<a href="../../../../project/file/#project" class="ref">Project Configuration</a>.</p>
<h2 id="example">Example</h2><div class="highlight"><pre><span></span><span class="cp">{%</span> <span class="k">set</span> <span class="nv">downloads</span> <span class="o">=</span> <span class="nv">site.get</span><span class="o">(</span><span class="s1">&#39;/downloads&#39;</span><span class="o">)</span> <span class="cp">%}</span>
<h2 id="example">Example</h2><div class="hll"><pre><span></span><span class="cp">{%</span> <span class="k">set</span> <span class="nv">downloads</span> <span class="o">=</span> <span class="nv">site.get</span><span class="o">(</span><span class="s1">&#39;/downloads&#39;</span><span class="o">)</span> <span class="cp">%}</span>
Path from downloads to here: <span class="cp">{{</span> <span class="nv">downloads.url_to</span><span class="o">(</span><span class="nv">this</span><span class="o">)</span> <span class="cp">}}</span>
</pre></div>

View File

@ -214,7 +214,7 @@
<a href="../../../../content/alts/" class="ref">Alternatives</a>. This method can be used
to target the root page of a specific one. If no alt is provided, then the
primary alt is loaded.</p>
<h2 id="example">Example</h2><div class="highlight"><pre><span></span><span class="cp">{%</span> <span class="k">set</span> <span class="nv">root</span> <span class="o">=</span> <span class="nv">site.get_root</span><span class="o">(</span><span class="nv">alt</span><span class="o">=</span><span class="s1">&#39;de&#39;</span><span class="o">)</span> <span class="cp">%}</span>
<h2 id="example">Example</h2><div class="hll"><pre><span></span><span class="cp">{%</span> <span class="k">set</span> <span class="nv">root</span> <span class="o">=</span> <span class="nv">site.get_root</span><span class="o">(</span><span class="nv">alt</span><span class="o">=</span><span class="s1">&#39;de&#39;</span><span class="o">)</span> <span class="cp">%}</span>
<span class="p">&lt;</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">&quot;</span><span class="cp">{{</span> <span class="nv">root</span><span class="o">|</span><span class="nf">url</span> <span class="cp">}}</span><span class="s">&quot;</span><span class="p">&gt;</span>Go to German Page<span class="p">&lt;/</span><span class="nt">a</span><span class="p">&gt;</span>
</pre></div>

View File

@ -222,17 +222,17 @@ want to select a specific page for pagination, then you need to pass
<code>page_num</code> with a valid page number or you use the virtual path (<code>@1</code> for the
first page for instance).</p>
<h2 id="examples">Examples</h2><p>This is a simple example that shows how to use the method in a template:</p>
<div class="highlight"><pre><span></span><span class="cp">{%</span> <span class="k">set</span> <span class="nv">root</span> <span class="o">=</span> <span class="nv">site.get</span><span class="o">(</span><span class="s1">&#39;/&#39;</span><span class="o">)</span> <span class="cp">%}</span>
<div class="hll"><pre><span></span><span class="cp">{%</span> <span class="k">set</span> <span class="nv">root</span> <span class="o">=</span> <span class="nv">site.get</span><span class="o">(</span><span class="s1">&#39;/&#39;</span><span class="o">)</span> <span class="cp">%}</span>
<span class="p">&lt;</span><span class="nt">title</span><span class="p">&gt;</span><span class="cp">{{</span> <span class="nv">this.title</span> <span class="cp">}}</span> | <span class="cp">{{</span> <span class="nv">root.title</span> <span class="cp">}}</span><span class="p">&lt;/</span><span class="nt">title</span><span class="p">&gt;</span>
</pre></div>
<p>Here another example that loads the current page but in another language:</p>
<div class="highlight"><pre><span></span><span class="cp">{%</span> <span class="k">set</span> <span class="nv">other_lang</span> <span class="o">=</span> <span class="nv">site.get</span><span class="o">(</span><span class="nv">this._path</span><span class="o">,</span> <span class="nv">alt</span><span class="o">=</span><span class="s1">&#39;ru&#39;</span><span class="o">)</span> <span class="cp">%}</span>
<div class="hll"><pre><span></span><span class="cp">{%</span> <span class="k">set</span> <span class="nv">other_lang</span> <span class="o">=</span> <span class="nv">site.get</span><span class="o">(</span><span class="nv">this._path</span><span class="o">,</span> <span class="nv">alt</span><span class="o">=</span><span class="s1">&#39;ru&#39;</span><span class="o">)</span> <span class="cp">%}</span>
<span class="p">&lt;</span><span class="nt">p</span><span class="p">&gt;</span>This page in Russian: <span class="cp">{{</span> <span class="nv">other_lang.title</span> <span class="cp">}}</span>
</pre></div>
<h2 id="virtual-paths">Virtual Paths</h2><p>This method can also be used to look up <a href="../../../../content/paths/" class="ref">virtual paths</a>. For instance to fetch a specific version of a
pagination you can use a virtual path instead of using the <code>page_num</code>
parameter:</p>
<div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">pad</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;/blog@3&#39;</span><span class="p">)</span>
<div class="hll"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">pad</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;/blog@3&#39;</span><span class="p">)</span>
<span class="go">&lt;Page model=u&#39;blog&#39; path=&#39;/blog&#39; page_num=3&gt;</span>
</pre></div>

View File

@ -227,12 +227,12 @@ command line scripts.</p>
<h2 id="template-usage">Template Usage</h2><p>A ready-configured pad is always available under the <code>site</code> name which
allows you to easily discover other pages. Here is a basic example of
how to do this through the <a href="get/" class="ref">get</a> method:</p>
<div class="highlight"><pre><span></span><span class="cp">{%</span> <span class="k">set</span> <span class="nv">root</span> <span class="o">=</span> <span class="nv">site.get</span><span class="o">(</span><span class="s1">&#39;/&#39;</span><span class="o">)</span> <span class="cp">%}</span>
<div class="hll"><pre><span></span><span class="cp">{%</span> <span class="k">set</span> <span class="nv">root</span> <span class="o">=</span> <span class="nv">site.get</span><span class="o">(</span><span class="s1">&#39;/&#39;</span><span class="o">)</span> <span class="cp">%}</span>
<span class="p">&lt;</span><span class="nt">title</span><span class="p">&gt;</span><span class="cp">{{</span> <span class="nv">this.title</span> <span class="cp">}}</span> | <span class="cp">{{</span> <span class="nv">root.title</span> <span class="cp">}}</span><span class="p">&lt;/</span><span class="nt">title</span><span class="p">&gt;</span>
</pre></div>
<h2 id="plugin-usage">Plugin Usage</h2><p>Within plugins it's typically not a good idea to construct a new Pad.
Instead you can get access to the current pad from the active context:</p>
<div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">lektor.context</span> <span class="kn">import</span> <span class="n">get_ctx</span>
<div class="hll"><pre><span></span><span class="kn">from</span> <span class="nn">lektor.context</span> <span class="kn">import</span> <span class="n">get_ctx</span>
<span class="n">ctx</span> <span class="o">=</span> <span class="n">get_ctx</span><span class="p">()</span>
<span class="k">if</span> <span class="n">ctx</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
@ -244,7 +244,7 @@ instance.</p>
<h2 id="manual-pad-creation">Manual Pad Creation</h2><p>If you want to work with the database from a script, you can create a
pad from the <a href="../../environment/" class="ref">Environment</a> with the help of
the <a href="../../environment/new-pad/" class="ref">new_pad</a> method:</p>
<div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">lektor.project</span> <span class="kn">import</span> <span class="n">Project</span>
<div class="hll"><pre><span></span><span class="kn">from</span> <span class="nn">lektor.project</span> <span class="kn">import</span> <span class="n">Project</span>
<span class="n">project</span> <span class="o">=</span> <span class="n">Project</span><span class="o">.</span><span class="n">discover</span><span class="p">()</span>
<span class="n">env</span> <span class="o">=</span> <span class="n">project</span><span class="o">.</span><span class="n">make_env</span><span class="p">()</span>

View File

@ -214,7 +214,7 @@
Lektor. It creates a query at a specific path and alt. This is an
alternative to accessing the children of the <a href="../root/" class="ref">root</a> record
and will also include hidden pages.</p>
<h2 id="example">Example</h2><div class="highlight"><pre><span></span><span class="p">&lt;</span><span class="nt">ul</span><span class="p">&gt;</span>
<h2 id="example">Example</h2><div class="hll"><pre><span></span><span class="p">&lt;</span><span class="nt">ul</span><span class="p">&gt;</span>
<span class="cp">{%</span> <span class="k">for</span> <span class="nv">project</span> <span class="k">in</span> <span class="nv">site.query</span><span class="o">(</span><span class="s1">&#39;/projects&#39;</span><span class="o">)</span> <span class="cp">%}</span>
<span class="p">&lt;</span><span class="nt">li</span><span class="p">&gt;</span><span class="cp">{{</span> <span class="nv">project.name</span> <span class="cp">}}</span>: <span class="cp">{{</span> <span class="nv">project.year</span> <span class="cp">}}</span><span class="p">&lt;/</span><span class="nt">li</span><span class="p">&gt;</span>
<span class="cp">{%</span> <span class="k">endfor</span> <span class="cp">%}</span>

View File

@ -218,7 +218,7 @@ happening in Lektor.</p>
want to resolve to records you can pass <code>include_assets=False</code> and only
records will be included.</p>
<h2 id="examples">Examples</h2><p>Shows an example of how to resolve paths into assets:</p>
<div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">pad</span><span class="o">.</span><span class="n">resolve_url_path</span><span class="p">(</span><span class="s1">&#39;/docs/api&#39;</span><span class="p">)</span>
<div class="hll"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">pad</span><span class="o">.</span><span class="n">resolve_url_path</span><span class="p">(</span><span class="s1">&#39;/docs/api&#39;</span><span class="p">)</span>
<span class="go">&lt;Page model=u&#39;doc-page&#39; path=u&#39;/docs/api&#39;&gt;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">pad</span><span class="o">.</span><span class="n">resolve_url_path</span><span class="p">(</span><span class="s1">&#39;/header.jpg&#39;</span><span class="p">)</span>
<span class="go">&lt;Image model=&#39;none&#39; path=u&#39;/header.jpg&#39;&gt;</span>

View File

@ -212,7 +212,7 @@
<p>This works exactly like <a href="../get-root/" class="ref">get_root</a> but always returns
the primary alternative and is implemented as a property.</p>
<h2 id="example">Example</h2><div class="highlight"><pre><span></span><span class="p">&lt;</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">&quot;</span><span class="cp">{{</span> <span class="nv">site.root</span><span class="o">|</span><span class="nf">url</span> <span class="cp">}}</span><span class="s">&quot;</span><span class="p">&gt;</span>Go to Index<span class="p">&lt;/</span><span class="nt">a</span><span class="p">&gt;</span>
<h2 id="example">Example</h2><div class="hll"><pre><span></span><span class="p">&lt;</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">&quot;</span><span class="cp">{{</span> <span class="nv">site.root</span><span class="o">|</span><span class="nf">url</span> <span class="cp">}}</span><span class="s">&quot;</span><span class="p">&gt;</span>Go to Index<span class="p">&lt;/</span><span class="nt">a</span><span class="p">&gt;</span>
</pre></div>

View File

@ -235,7 +235,7 @@
the query as a list. In many cases just iterating over the query achieve
the same result, but if you want an actual list this method comes in
handy.</p>
<h2 id="example">Example</h2><div class="highlight"><pre><span></span><span class="cp">{%</span> <span class="k">items</span> <span class="o">=</span> <span class="nv">site.query</span><span class="o">(</span><span class="s1">&#39;/projects&#39;</span><span class="o">)</span><span class="nv">.include_hidden</span><span class="o">(</span><span class="kp">false</span><span class="o">)</span><span class="nv">.all</span><span class="o">()</span> <span class="cp">%}</span>
<h2 id="example">Example</h2><div class="hll"><pre><span></span><span class="cp">{%</span> <span class="k">items</span> <span class="o">=</span> <span class="nv">site.query</span><span class="o">(</span><span class="s1">&#39;/projects&#39;</span><span class="o">)</span><span class="nv">.include_hidden</span><span class="o">(</span><span class="kp">false</span><span class="o">)</span><span class="nv">.all</span><span class="o">()</span> <span class="cp">%}</span>
<span class="cp">{%</span> <span class="k">if</span> <span class="nv">items</span> <span class="cp">%}</span>
<span class="p">&lt;</span><span class="nt">ul</span><span class="p">&gt;</span>
<span class="cp">{%</span> <span class="k">for</span> <span class="nv">item</span> <span class="k">in</span> <span class="nv">items</span> <span class="cp">%}</span>

View File

@ -232,7 +232,7 @@
</ul>
<p>This is a simple way to count the total number of items a query matches.</p>
<h2 id="example">Example</h2><div class="highlight"><pre><span></span><span class="cp">{%</span> <span class="k">set</span> <span class="nv">project_count</span> <span class="o">=</span> <span class="nv">site.query</span><span class="o">(</span><span class="s1">&#39;/projects&#39;</span><span class="o">)</span><span class="nv">.count</span><span class="o">()</span> <span class="cp">%}</span>
<h2 id="example">Example</h2><div class="hll"><pre><span></span><span class="cp">{%</span> <span class="k">set</span> <span class="nv">project_count</span> <span class="o">=</span> <span class="nv">site.query</span><span class="o">(</span><span class="s1">&#39;/projects&#39;</span><span class="o">)</span><span class="nv">.count</span><span class="o">()</span> <span class="cp">%}</span>
<span class="p">&lt;</span><span class="nt">p</span><span class="p">&gt;</span>We built <span class="cp">{{</span> <span class="nv">project_count</span> <span class="cp">}}</span> projects.
</pre></div>

View File

@ -236,14 +236,14 @@
<p>Returns a <code>set</code> with all values for <code>field_name</code> of all
<a href="../../record/" class="ref">Records</a> in this query.</p>
<h2 id="example">Example</h2><p>If your blog posts have a field called <code>tags</code>:</p>
<div class="highlight"><pre><span></span><span class="c1"># blog-post.ini</span><span class="w"></span>
<div class="hll"><pre><span></span><span class="c1"># blog-post.ini</span><span class="w"></span>
<span class="k">[field.tags]</span><span class="w"></span>
<span class="na">name</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">Tags</span><span class="w"></span>
<span class="na">type</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">strings</span><span class="w"></span>
</pre></div>
<p>You can display all your blog posts' tags with:</p>
<div class="highlight"><pre><span></span><span class="cp">{%</span> <span class="k">set</span> <span class="nv">tags</span> <span class="o">=</span> <span class="nv">site.query</span><span class="o">(</span><span class="s1">&#39;/blog&#39;</span><span class="o">)</span><span class="nv">.distinct</span><span class="o">(</span><span class="s1">&#39;tags&#39;</span><span class="o">)</span> <span class="cp">%}</span>
<div class="hll"><pre><span></span><span class="cp">{%</span> <span class="k">set</span> <span class="nv">tags</span> <span class="o">=</span> <span class="nv">site.query</span><span class="o">(</span><span class="s1">&#39;/blog&#39;</span><span class="o">)</span><span class="nv">.distinct</span><span class="o">(</span><span class="s1">&#39;tags&#39;</span><span class="o">)</span> <span class="cp">%}</span>
<span class="cp">{%</span> <span class="k">if</span> <span class="nv">tags</span> <span class="cp">%}</span>
<span class="p">&lt;</span><span class="nt">ul</span><span class="p">&gt;</span>
<span class="cp">{%</span> <span class="k">for</span> <span class="nv">tag</span> <span class="k">in</span> <span class="nv">tags</span><span class="o">|</span><span class="nf">sort</span> <span class="cp">%}</span>

View File

@ -237,7 +237,7 @@ which allows you to perform comparisons with values that fields have.</p>
<p>Multiple filter calls can be chained as an alternative to using an <code>and</code>
expression.</p>
<h2 id="example">Example</h2><p>Here a basic example of how to filter something in a template:</p>
<div class="highlight"><pre><span></span><span class="p">&lt;</span><span class="nt">ul</span><span class="p">&gt;</span>
<div class="hll"><pre><span></span><span class="p">&lt;</span><span class="nt">ul</span><span class="p">&gt;</span>
<span class="cp">{%</span> <span class="k">for</span> <span class="nv">item</span> <span class="k">in</span> <span class="nv">this.children.filter</span><span class="o">(</span><span class="nv">F.status</span> <span class="o">==</span> <span class="s1">&#39;published&#39;</span><span class="o">)</span> <span class="cp">%}</span>
<span class="p">&lt;</span><span class="nt">li</span><span class="p">&gt;</span><span class="cp">{{</span> <span class="nv">item.title</span> <span class="cp">}}</span><span class="p">&lt;/</span><span class="nt">li</span><span class="p">&gt;</span>
<span class="cp">{%</span> <span class="k">endfor</span> <span class="cp">%}</span>

View File

@ -233,7 +233,7 @@
<p>This method returns the first <a href="../../record/" class="ref">Record</a> that matches the
query. If no such record can be produced, <code>None</code> is returned.</p>
<h2 id="example">Example</h2><div class="highlight"><pre><span></span><span class="cp">{%</span> <span class="k">set</span> <span class="nv">first_visible</span> <span class="o">=</span> <span class="nv">this.children.first</span><span class="o">()</span> <span class="cp">%}</span>
<h2 id="example">Example</h2><div class="hll"><pre><span></span><span class="cp">{%</span> <span class="k">set</span> <span class="nv">first_visible</span> <span class="o">=</span> <span class="nv">this.children.first</span><span class="o">()</span> <span class="cp">%}</span>
<span class="cp">{%</span> <span class="k">if</span> <span class="nv">first_visible</span> <span class="cp">%}</span>
<span class="p">&lt;</span><span class="nt">h2</span><span class="p">&gt;</span>Explore More ...<span class="p">&lt;/</span><span class="nt">h2</span><span class="p">&gt;</span>
<span class="p">&lt;</span><span class="nt">p</span><span class="p">&gt;</span><span class="cp">{{</span> <span class="nv">first_visible.title</span> <span class="cp">}}</span>

View File

@ -235,7 +235,7 @@
the <a href="../../pad/get/" class="ref">get</a> method of the pad but respects the currently
applied filtering. If <code>page_num</code> is provided it overrides the currently
requested page number from the query for pagination.</p>
<h2 id="example">Example</h2><div class="highlight"><pre><span></span><span class="cp">{%</span> <span class="k">set</span> <span class="nv">p1</span> <span class="o">=</span> <span class="nv">this.children.get</span><span class="o">(</span><span class="s1">&#39;project-1&#39;</span><span class="o">)</span> <span class="cp">%}</span>
<h2 id="example">Example</h2><div class="hll"><pre><span></span><span class="cp">{%</span> <span class="k">set</span> <span class="nv">p1</span> <span class="o">=</span> <span class="nv">this.children.get</span><span class="o">(</span><span class="s1">&#39;project-1&#39;</span><span class="o">)</span> <span class="cp">%}</span>
<span class="p">&lt;</span><span class="nt">h2</span><span class="p">&gt;</span><span class="cp">{{</span> <span class="nv">p1.name</span> <span class="cp">}}</span><span class="p">&lt;/</span><span class="nt">h2</span><span class="p">&gt;</span>
<span class="p">&lt;</span><span class="nt">p</span><span class="p">&gt;</span>Our favorite!
</pre></div>

View File

@ -239,7 +239,7 @@ method of the pad.</p>
<p>The parameter can be set to <code>True</code> to include hidden or <code>False</code> to exclude
hidden records.</p>
<h2 id="example">Example</h2><p>Here a basic example of how to filter something in a template:</p>
<div class="highlight"><pre><span></span><span class="p">&lt;</span><span class="nt">ul</span><span class="p">&gt;</span>
<div class="hll"><pre><span></span><span class="p">&lt;</span><span class="nt">ul</span><span class="p">&gt;</span>
<span class="cp">{%</span> <span class="k">for</span> <span class="nv">item</span> <span class="k">in</span> <span class="nv">this.children.include_hidden</span><span class="o">(</span><span class="kp">true</span><span class="o">)</span> <span class="cp">%}</span>
<span class="p">&lt;</span><span class="nt">li</span><span class="p">&gt;</span><span class="cp">{{</span> <span class="nv">item.title</span> <span class="cp">}}{%</span> <span class="k">if</span> <span class="nv">item.is_hidden</span> <span class="cp">%}</span> (hidden)<span class="cp">{%</span> <span class="k">endif</span> <span class="cp">%}</span><span class="p">&lt;/</span><span class="nt">li</span><span class="p">&gt;</span>
<span class="cp">{%</span> <span class="k">endfor</span> <span class="cp">%}</span>

View File

@ -240,7 +240,7 @@ include undiscoverable records by default.</p>
<p>If undiscoverable records should included this method needs to be used.
Set it to <code>True</code> to include hidden or <code>False</code> to exclude them (default).</p>
<h2 id="example">Example</h2><p>Here a basic example of how to filter something in a template:</p>
<div class="highlight"><pre><span></span><span class="p">&lt;</span><span class="nt">ul</span><span class="p">&gt;</span>
<div class="hll"><pre><span></span><span class="p">&lt;</span><span class="nt">ul</span><span class="p">&gt;</span>
<span class="cp">{%</span> <span class="k">for</span> <span class="nv">item</span> <span class="k">in</span> <span class="nv">this.children.include_undiscoverable</span><span class="o">(</span><span class="kp">true</span><span class="o">)</span> <span class="cp">%}</span>
<span class="p">&lt;</span><span class="nt">li</span><span class="p">&gt;</span><span class="cp">{{</span> <span class="nv">item.title</span> <span class="cp">}}</span><span class="p">&lt;/</span><span class="nt">li</span><span class="p">&gt;</span>
<span class="cp">{%</span> <span class="k">endfor</span> <span class="cp">%}</span>

View File

@ -233,7 +233,7 @@ through either the <a href="../pad/" class="ref">Pad</a> or through things like
<p>Most operations on a query object return another one which will return a
more filtered result.</p>
<h2 id="example">Example</h2><p>Here a basic example of how to filter something in a template:</p>
<div class="highlight"><pre><span></span><span class="p">&lt;</span><span class="nt">ul</span><span class="p">&gt;</span>
<div class="hll"><pre><span></span><span class="p">&lt;</span><span class="nt">ul</span><span class="p">&gt;</span>
<span class="cp">{%</span> <span class="k">for</span> <span class="nv">item</span> <span class="k">in</span> <span class="nv">this.children.filter</span><span class="o">(</span><span class="nv">F.status</span> <span class="o">==</span> <span class="s1">&#39;published&#39;</span><span class="o">)</span> <span class="cp">%}</span>
<span class="p">&lt;</span><span class="nt">li</span><span class="p">&gt;</span><span class="cp">{{</span> <span class="nv">item.title</span> <span class="cp">}}</span><span class="p">&lt;/</span><span class="nt">li</span><span class="p">&gt;</span>
<span class="cp">{%</span> <span class="k">endfor</span> <span class="cp">%}</span>

View File

@ -233,7 +233,7 @@
<p>The offset method can be used to limit the return value to a certain number
of matching records.</p>
<h2 id="example">Example</h2><div class="highlight"><pre><span></span><span class="p">&lt;</span><span class="nt">h3</span><span class="p">&gt;</span>Our Top 3<span class="p">&lt;/</span><span class="nt">h3</span><span class="p">&gt;</span>
<h2 id="example">Example</h2><div class="hll"><pre><span></span><span class="p">&lt;</span><span class="nt">h3</span><span class="p">&gt;</span>Our Top 3<span class="p">&lt;/</span><span class="nt">h3</span><span class="p">&gt;</span>
<span class="p">&lt;</span><span class="nt">ul</span><span class="p">&gt;</span>
<span class="cp">{%</span> <span class="k">for</span> <span class="nv">item</span> <span class="k">in</span> <span class="nv">this.children.order_by</span><span class="o">(</span><span class="s1">&#39;-rating&#39;</span><span class="o">)</span><span class="nv">.limit</span><span class="o">(</span><span class="m">3</span><span class="o">)</span> <span class="cp">%}</span>
<span class="p">&lt;</span><span class="nt">li</span><span class="p">&gt;</span><span class="cp">{{</span> <span class="nv">item.title</span> <span class="cp">}}</span><span class="p">&lt;/</span><span class="nt">li</span><span class="p">&gt;</span>

View File

@ -235,7 +235,7 @@
this is not useful as pagination comes built-in, but it can be helpful in
some manual scenarios when working with data from the <code>shell</code>.</p>
<p>This is typically combined with <a href="../limit/" class="ref">limit</a>.</p>
<h2 id="example">Example</h2><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">pad</span><span class="o">.</span><span class="n">query</span><span class="p">(</span><span class="s1">&#39;/projects&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">limit</span><span class="p">(</span><span class="mi">5</span><span class="p">)</span><span class="o">.</span><span class="n">offset</span><span class="p">(</span><span class="mi">10</span><span class="p">)</span><span class="o">.</span><span class="n">all</span><span class="p">()</span>
<h2 id="example">Example</h2><div class="hll"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">pad</span><span class="o">.</span><span class="n">query</span><span class="p">(</span><span class="s1">&#39;/projects&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">limit</span><span class="p">(</span><span class="mi">5</span><span class="p">)</span><span class="o">.</span><span class="n">offset</span><span class="p">(</span><span class="mi">10</span><span class="p">)</span><span class="o">.</span><span class="n">all</span><span class="p">()</span>
<span class="go">[...]</span>
</pre></div>

View File

@ -239,7 +239,7 @@ order is reversed.</p>
<p>If two records have the same value for a field, then the ordering is defined on
the next argument given. So if you order by (<code>'year', 'name'</code>) it will first
order by year and within a year it will order by name.</p>
<h2 id="example">Example</h2><div class="highlight"><pre><span></span><span class="p">&lt;</span><span class="nt">ul</span><span class="p">&gt;</span>
<h2 id="example">Example</h2><div class="hll"><pre><span></span><span class="p">&lt;</span><span class="nt">ul</span><span class="p">&gt;</span>
<span class="cp">{%</span> <span class="k">for</span> <span class="nv">project</span> <span class="k">in</span> <span class="nv">this.children.order_by</span><span class="o">(</span><span class="s1">&#39;-year&#39;</span><span class="o">,</span> <span class="s1">&#39;name&#39;</span><span class="o">)</span> <span class="cp">%}</span>
<span class="p">&lt;</span><span class="nt">li</span><span class="p">&gt;</span><span class="cp">{{</span> <span class="nv">project.year</span> <span class="cp">}}</span>: <span class="cp">{{</span> <span class="nv">project.name</span> <span class="cp">}}</span><span class="p">&lt;/</span><span class="nt">li</span><span class="p">&gt;</span>
<span class="cp">{%</span> <span class="k">endif</span> <span class="cp">%}</span>

View File

@ -238,7 +238,7 @@ this parameter it's possible to change this. The parameter is the number
of the page to access.</p>
<p>Truth be told: this method exists mostly for consistency and less because
there is a good reason to use it.</p>
<h2 id="example">Example</h2><div class="highlight"><pre><span></span><span class="p">&lt;</span><span class="nt">ul</span><span class="p">&gt;</span>
<h2 id="example">Example</h2><div class="hll"><pre><span></span><span class="p">&lt;</span><span class="nt">ul</span><span class="p">&gt;</span>
<span class="cp">{%</span> <span class="k">for</span> <span class="nv">child</span> <span class="k">in</span> <span class="nv">this.children.request_page</span><span class="o">(</span><span class="m">1</span><span class="o">)</span> <span class="cp">%}</span>
<span class="p">&lt;</span><span class="nt">li</span><span class="p">&gt;</span>
Items on the first page of <span class="cp">{{</span> <span class="nv">child.title</span> <span class="cp">}}</span>:

View File

@ -234,7 +234,7 @@
<p>Because a query object filters "downwards" there this is a way access the item
at the level of the query object. It's particularly useful for debugging
in the <code>shell</code>:</p>
<h2 id="example">Example</h2><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">root</span> <span class="o">=</span> <span class="n">pad</span><span class="o">.</span><span class="n">root</span>
<h2 id="example">Example</h2><div class="hll"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">root</span> <span class="o">=</span> <span class="n">pad</span><span class="o">.</span><span class="n">root</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">root</span><span class="o">.</span><span class="n">children</span><span class="o">.</span><span class="n">query</span><span class="o">.</span><span class="n">self</span> <span class="o">==</span> <span class="n">root</span>
<span class="go">True</span>
</pre></div>

View File

@ -240,7 +240,7 @@
<p>This returns a <a href="../../query/" class="ref">Query</a> to all attachments of a page. This
query can be further filtered to access specific types of attachments if
needed.</p>
<h2 id="example">Example</h2><div class="highlight"><pre><span></span><span class="p">&lt;</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">&quot;images&quot;</span><span class="p">&gt;</span>
<h2 id="example">Example</h2><div class="hll"><pre><span></span><span class="p">&lt;</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">&quot;images&quot;</span><span class="p">&gt;</span>
<span class="cp">{%</span> <span class="k">for</span> <span class="nv">image</span> <span class="k">in</span> <span class="nv">this.attachments.images</span> <span class="cp">%}</span>
<span class="p">&lt;</span><span class="nt">img</span> <span class="na">src</span><span class="o">=</span><span class="s">&quot;</span><span class="cp">{{</span> <span class="nv">image.thumbnail</span><span class="o">(</span><span class="m">240</span><span class="o">)</span> <span class="cp">}}</span><span class="s">&quot;</span><span class="p">&gt;</span>
<span class="cp">{%</span> <span class="k">endfor</span> <span class="cp">%}</span>

View File

@ -249,7 +249,7 @@ available.</p>
<p>What's important to know about children is that the default query will
exclude hidden children. This is different from creating a query object
via the <a href="../../pad/query/" class="ref">query</a> method of the pad.</p>
<h2 id="example">Example</h2><div class="highlight"><pre><span></span><span class="p">&lt;</span><span class="nt">ul</span><span class="p">&gt;</span>
<h2 id="example">Example</h2><div class="hll"><pre><span></span><span class="p">&lt;</span><span class="nt">ul</span><span class="p">&gt;</span>
<span class="cp">{%</span> <span class="k">for</span> <span class="nv">child</span> <span class="k">in</span> <span class="nv">this.children</span> <span class="cp">%}</span>
<span class="p">&lt;</span><span class="nt">li</span><span class="p">&gt;</span><span class="cp">{{</span> <span class="nv">child.title</span> <span class="cp">}}</span><span class="p">&lt;/</span><span class="nt">li</span><span class="p">&gt;</span>
<span class="cp">{%</span> <span class="k">endfor</span> <span class="cp">%}</span>

View File

@ -305,7 +305,7 @@ contents of that file:</p>
</tbody>
</table>
<h2 id="example">Example</h2><p>Here are some ideas of what you can do with it:</p>
<div class="highlight"><pre><span></span><span class="p">&lt;</span><span class="nt">img</span> <span class="na">src</span><span class="o">=</span><span class="s">&quot;</span><span class="cp">{{</span> <span class="nv">image.contents.as_data_url</span><span class="o">()</span> <span class="cp">}}</span><span class="s">&quot;</span> <span class="na">alt</span><span class="o">=</span><span class="s">&quot;&quot;</span><span class="p">&gt;</span>
<div class="hll"><pre><span></span><span class="p">&lt;</span><span class="nt">img</span> <span class="na">src</span><span class="o">=</span><span class="s">&quot;</span><span class="cp">{{</span> <span class="nv">image.contents.as_data_url</span><span class="o">()</span> <span class="cp">}}</span><span class="s">&quot;</span> <span class="na">alt</span><span class="o">=</span><span class="s">&quot;&quot;</span><span class="p">&gt;</span>
</pre></div>

View File

@ -348,7 +348,7 @@ into a dictionary that can be dumped to JSON for instance.</p>
</tr>
</tbody>
</table>
<h2 id="example">Example</h2><div class="highlight"><pre><span></span><span class="cp">{%</span> <span class="k">if</span> <span class="nv">image.exif.location</span> <span class="cp">%}</span>
<h2 id="example">Example</h2><div class="hll"><pre><span></span><span class="cp">{%</span> <span class="k">if</span> <span class="nv">image.exif.location</span> <span class="cp">%}</span>
<span class="p">&lt;</span><span class="nt">h2</span><span class="p">&gt;</span>Picture Location<span class="p">&lt;/</span><span class="nt">h2</span><span class="p">&gt;</span>
<span class="p">&lt;</span><span class="nt">iframe</span> <span class="na">width</span><span class="o">=</span><span class="s">&quot;600&quot;</span> <span class="na">height</span><span class="o">=</span><span class="s">&quot;450&quot;</span> <span class="na">frameborder</span><span class="o">=</span><span class="s">&quot;0&quot;</span> <span class="na">style</span><span class="o">=</span><span class="s">&quot;border:0&quot;</span>
<span class="na">src</span><span class="o">=</span><span class="s">&quot;https://www.google.com/maps/embed/v1/place?q=</span><span class="cp">{{</span>

View File

@ -239,7 +239,7 @@
<p>This returns the format of the attachment as a string. This is currently
only implemented for attachments that are images.</p>
<h2 id="example">Example</h2><div class="highlight"><pre><span></span><span class="cp">{%</span> <span class="k">for</span> <span class="nv">image</span> <span class="k">in</span> <span class="nv">this.attachments.images</span> <span class="cp">%}</span>
<h2 id="example">Example</h2><div class="hll"><pre><span></span><span class="cp">{%</span> <span class="k">for</span> <span class="nv">image</span> <span class="k">in</span> <span class="nv">this.attachments.images</span> <span class="cp">%}</span>
<span class="p">&lt;</span><span class="nt">p</span><span class="p">&gt;</span><span class="cp">{{</span> <span class="nv">image._id</span> <span class="cp">}}</span>: <span class="cp">{{</span> <span class="nv">image.format</span> <span class="cp">}}</span>
<span class="cp">{%</span> <span class="k">endfor</span> <span class="cp">%}</span>
</pre></div>

View File

@ -245,7 +245,7 @@ filter and order the children. Otherwise, the parent's standard configuration
for children is used.
See <a href="../../../../guides/pagination/" class="ref">the pagination guide</a> and the
<a href="../../../../guides/page-order/" class="ref">page order guide</a>.</p>
<h2 id="example">Example</h2><div class="highlight"><pre><span></span><span class="cp">{%</span> <span class="k">set</span> <span class="nv">siblings</span> <span class="o">=</span> <span class="nv">this.get_siblings</span><span class="o">()</span> <span class="cp">%}</span>
<h2 id="example">Example</h2><div class="hll"><pre><span></span><span class="cp">{%</span> <span class="k">set</span> <span class="nv">siblings</span> <span class="o">=</span> <span class="nv">this.get_siblings</span><span class="o">()</span> <span class="cp">%}</span>
<span class="cp">{%</span> <span class="k">if</span> <span class="nv">siblings.prev_page</span> <span class="cp">%}</span>
<span class="p">&lt;</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">&quot;</span><span class="cp">{{</span> <span class="nv">siblings.prev_page</span><span class="o">|</span><span class="nf">url</span> <span class="cp">}}</span><span class="s">&quot;</span><span class="p">&gt;</span>previous<span class="p">&lt;/</span><span class="nt">a</span><span class="p">&gt;</span>

View File

@ -243,7 +243,7 @@ is why you can typically access <code>foo.bar</code> instead of <code>foo['bar']
conflict with a record property exists.</p>
<p>All available fields can be accessed this way (model defined fields as well
as system fields which are prefixed by an underscore).</p>
<h2 id="example">Example</h2><div class="highlight"><pre><span></span><span class="k">for</span> <span class="n">child</span> <span class="ow">in</span> <span class="n">this</span><span class="o">.</span><span class="n">children</span><span class="p">:</span>
<h2 id="example">Example</h2><div class="hll"><pre><span></span><span class="k">for</span> <span class="n">child</span> <span class="ow">in</span> <span class="n">this</span><span class="o">.</span><span class="n">children</span><span class="p">:</span>
<span class="nb">print</span><span class="p">(</span><span class="s1">&#39;ID: </span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="n">child</span><span class="p">[</span><span class="s1">&#39;_id&#39;</span><span class="p">])</span>
</pre></div>

View File

@ -243,7 +243,7 @@ filter and order the children. Otherwise, the parent's standard configuration
for children is used.
See <a href="../../../../guides/pagination/" class="ref">the pagination guide</a> and the
<a href="../../../../guides/page-order/" class="ref">page order guide</a>.</p>
<h2 id="example">Example</h2><div class="highlight"><pre><span></span><span class="cp">{%</span> <span class="k">if</span> <span class="nv">this.has_next</span><span class="o">()</span> <span class="cp">%}</span>
<h2 id="example">Example</h2><div class="hll"><pre><span></span><span class="cp">{%</span> <span class="k">if</span> <span class="nv">this.has_next</span><span class="o">()</span> <span class="cp">%}</span>
<span class="p">&lt;</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">&quot;</span><span class="cp">{{</span> <span class="nv">this.get_siblings</span><span class="o">()</span><span class="nv">.next_page</span><span class="o">|</span><span class="nf">url</span> <span class="cp">}}</span><span class="s">&quot;</span><span class="p">&gt;</span>next<span class="p">&lt;/</span><span class="nt">a</span><span class="p">&gt;</span>
<span class="cp">{%</span> <span class="k">else</span> <span class="cp">%}</span>
<span class="p">&lt;</span><span class="nt">p</span><span class="p">&gt;</span>This is the last entry.

View File

@ -243,7 +243,7 @@ filter and order the children. Otherwise, the parent's standard configuration
for children is used.
See <a href="../../../../guides/pagination/" class="ref">the pagination guide</a> and the
<a href="../../../../guides/page-order/" class="ref">page order guide</a>.</p>
<h2 id="example">Example</h2><div class="highlight"><pre><span></span><span class="cp">{%</span> <span class="k">if</span> <span class="nv">this.has_prev</span><span class="o">()</span> <span class="cp">%}</span>
<h2 id="example">Example</h2><div class="hll"><pre><span></span><span class="cp">{%</span> <span class="k">if</span> <span class="nv">this.has_prev</span><span class="o">()</span> <span class="cp">%}</span>
<span class="p">&lt;</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">&quot;</span><span class="cp">{{</span> <span class="nv">this.get_siblings</span><span class="o">()</span><span class="nv">.prev_page</span><span class="o">|</span><span class="nf">url</span> <span class="cp">}}</span><span class="s">&quot;</span><span class="p">&gt;</span>previous<span class="p">&lt;/</span><span class="nt">a</span><span class="p">&gt;</span>
<span class="cp">{%</span> <span class="k">else</span> <span class="cp">%}</span>
<span class="p">&lt;</span><span class="nt">p</span><span class="p">&gt;</span>This is the first entry.

View File

@ -240,7 +240,7 @@
<p>If you are dealing with an attachment that is an image, this property becomes
available and indicates the height of the image in pixels if that information
is available.</p>
<h2 id="example">Example</h2><div class="highlight"><pre><span></span><span class="cp">{%</span> <span class="k">for</span> <span class="nv">image</span> <span class="k">in</span> <span class="nv">this.attachments.images</span> <span class="cp">%}</span>
<h2 id="example">Example</h2><div class="hll"><pre><span></span><span class="cp">{%</span> <span class="k">for</span> <span class="nv">image</span> <span class="k">in</span> <span class="nv">this.attachments.images</span> <span class="cp">%}</span>
<span class="p">&lt;</span><span class="nt">img</span> <span class="na">src</span><span class="o">=</span><span class="s">&quot;</span><span class="cp">{{</span> <span class="nv">image</span><span class="o">|</span><span class="nf">url</span> <span class="cp">}}</span><span class="s">&quot;</span>
<span class="na">height</span><span class="o">=</span><span class="s">&quot;</span><span class="cp">{{</span> <span class="nv">image.height</span> <span class="cp">}}</span><span class="s">&quot;</span>
<span class="na">height</span><span class="o">=</span><span class="s">&quot;</span><span class="cp">{{</span> <span class="nv">image.height</span> <span class="cp">}}</span><span class="s">&quot;</span><span class="p">&gt;</span>

View File

@ -244,7 +244,7 @@ objects from templates they give access to their built-in attributes as well
as custom fields through the attribute syntax. If however a built-in
attribute overlaps with your custom field, you need to access the fields
with the subscript syntax (<code>[]</code>):</p>
<div class="highlight"><pre><span></span><span class="p">&lt;</span><span class="nt">p</span><span class="p">&gt;</span>Built-in Path: <span class="cp">{{</span> <span class="nv">obj.path</span> <span class="cp">}}</span>
<div class="hll"><pre><span></span><span class="p">&lt;</span><span class="nt">p</span><span class="p">&gt;</span>Built-in Path: <span class="cp">{{</span> <span class="nv">obj.path</span> <span class="cp">}}</span>
<span class="p">&lt;</span><span class="nt">p</span><span class="p">&gt;</span>Path field: <span class="cp">{{</span> <span class="nv">obj</span><span class="o">[</span><span class="s1">&#39;path&#39;</span><span class="o">]</span> <span class="cp">}}</span>
</pre></div>

View File

@ -241,7 +241,7 @@
an attachment this will be <code>true</code>. Because some functionality only exists
on one type but not the other this can be useful in some utility code to
change the behavior.</p>
<h2 id="example">Example</h2><div class="highlight"><pre><span></span><span class="cp">{%</span> <span class="k">macro</span> <span class="nv">render_record_link</span><span class="o">(</span><span class="nv">record</span><span class="o">)</span> <span class="cp">%}</span>
<h2 id="example">Example</h2><div class="hll"><pre><span></span><span class="cp">{%</span> <span class="k">macro</span> <span class="nv">render_record_link</span><span class="o">(</span><span class="nv">record</span><span class="o">)</span> <span class="cp">%}</span>
<span class="p">&lt;</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">&quot;</span><span class="cp">{{</span> <span class="nv">record</span><span class="o">|</span><span class="nf">url</span> <span class="cp">}}</span><span class="s">&quot;</span><span class="p">&gt;</span><span class="cp">{{</span> <span class="nv">record.record_label</span> <span class="cp">}}</span><span class="p">&lt;/</span><span class="nt">a</span><span class="p">&gt;</span>
<span class="cp">{%</span> <span class="k">if</span> <span class="nv">record.is_attachment</span> <span class="cp">%}</span> (<span class="cp">{{</span> <span class="nv">record._attachment_type</span> <span class="cp">}}</span>)<span class="cp">{%</span> <span class="k">endif</span> <span class="cp">%}</span>
<span class="cp">{%</span> <span class="k">endmacro</span> <span class="cp">%}</span>

View File

@ -302,7 +302,7 @@ the other page. For more information also see the virtual path example
below.</p>
<div class="admonition admonition-info"><p><em>Changed in Lektor 2.0:</em> The <code>for_page()</code> method was added.</p></div><h2 id="item-query-example">Item Query Example</h2><p>Simple example that shows how to iterate over the items specific to a
page:</p>
<div class="highlight"><pre><span></span><span class="p">&lt;</span><span class="nt">ul</span><span class="p">&gt;</span>
<div class="hll"><pre><span></span><span class="p">&lt;</span><span class="nt">ul</span><span class="p">&gt;</span>
<span class="cp">{%</span> <span class="k">for</span> <span class="nv">child</span> <span class="k">in</span> <span class="nv">this.pagination.items</span> <span class="cp">%}</span>
<span class="p">&lt;</span><span class="nt">li</span><span class="p">&gt;</span><span class="cp">{{</span> <span class="nv">child.title</span> <span class="cp">}}</span><span class="p">&lt;/</span><span class="nt">li</span><span class="p">&gt;</span>
<span class="cp">{%</span> <span class="k">endfor</span> <span class="cp">%}</span>
@ -310,7 +310,7 @@ page:</p>
</pre></div>
<h2 id="pagination-example">Pagination Example</h2><p>This example shows how to render a basic pagination with a previous and
next page link as well as the number of the current page:</p>
<div class="highlight"><pre><span></span><span class="p">&lt;</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">&quot;pagination&quot;</span><span class="p">&gt;</span>
<div class="hll"><pre><span></span><span class="p">&lt;</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">&quot;pagination&quot;</span><span class="p">&gt;</span>
<span class="cp">{%</span> <span class="k">if</span> <span class="nv">this.pagination.has_prev</span> <span class="cp">%}</span>
<span class="p">&lt;</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">&quot;</span><span class="cp">{{</span> <span class="nv">this.pagination.prev_page</span><span class="o">|</span><span class="nf">url</span> <span class="cp">}}</span><span class="s">&quot;</span><span class="p">&gt;</span><span class="ni">&amp;laquo;</span><span class="p">&lt;/</span><span class="nt">a</span><span class="p">&gt;</span>
<span class="cp">{%</span> <span class="k">else</span> <span class="cp">%}</span>
@ -328,11 +328,11 @@ next page link as well as the number of the current page:</p>
a virtual path below the record itself. The value of the path is just the
number of the page. So for instance to link to the second page you can just
do this:</p>
<div class="highlight"><pre><span></span><span class="p">&lt;</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">&quot;</span><span class="cp">{{</span> <span class="s1">&#39;@2&#39;</span><span class="o">|</span><span class="nf">url</span> <span class="cp">}}</span><span class="s">&quot;</span><span class="p">&gt;</span>Go to Page 2<span class="p">&lt;/</span><span class="nt">a</span><span class="p">&gt;</span>
<div class="hll"><pre><span></span><span class="p">&lt;</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">&quot;</span><span class="cp">{{</span> <span class="s1">&#39;@2&#39;</span><span class="o">|</span><span class="nf">url</span> <span class="cp">}}</span><span class="s">&quot;</span><span class="p">&gt;</span>Go to Page 2<span class="p">&lt;/</span><span class="nt">a</span><span class="p">&gt;</span>
</pre></div>
<p>Alternatively you can also use the <code>for_path()</code> function which returns the
entire pagination for a page:</p>
<div class="highlight"><pre><span></span><span class="p">&lt;</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">&quot;</span><span class="cp">{{</span> <span class="nv">this.pagination.for_page</span><span class="o">(</span><span class="m">2</span><span class="o">)|</span><span class="nf">url</span> <span class="cp">}}</span><span class="s">&quot;</span><span class="p">&gt;</span>Go to Page 2<span class="p">&lt;/</span><span class="nt">a</span><span class="p">&gt;</span>
<div class="hll"><pre><span></span><span class="p">&lt;</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">&quot;</span><span class="cp">{{</span> <span class="nv">this.pagination.for_page</span><span class="o">(</span><span class="m">2</span><span class="o">)|</span><span class="nf">url</span> <span class="cp">}}</span><span class="s">&quot;</span><span class="p">&gt;</span>Go to Page 2<span class="p">&lt;/</span><span class="nt">a</span><span class="p">&gt;</span>
</pre></div>

View File

@ -242,7 +242,7 @@ admin interface to show a human readable version of it. Typically this is
the title or something similar. This functionality can also be used outside
of the admin panel. This is particularly useful when rendering children of
a page that might use different independent models.</p>
<h2 id="example">Example</h2><div class="highlight"><pre><span></span><span class="p">&lt;</span><span class="nt">ul</span><span class="p">&gt;</span>
<h2 id="example">Example</h2><div class="hll"><pre><span></span><span class="p">&lt;</span><span class="nt">ul</span><span class="p">&gt;</span>
<span class="cp">{%</span> <span class="k">for</span> <span class="nv">child</span> <span class="k">in</span> <span class="nv">this.children</span> <span class="cp">%}</span>
<span class="p">&lt;</span><span class="nt">li</span><span class="p">&gt;&lt;</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">&quot;</span><span class="cp">{{</span> <span class="nv">child</span><span class="o">|</span><span class="nf">url</span> <span class="cp">}}</span><span class="s">&quot;</span><span class="p">&gt;</span><span class="cp">{{</span> <span class="nv">child.record_label</span> <span class="cp">}}</span><span class="p">&lt;/</span><span class="nt">a</span><span class="p">&gt;&lt;/</span><span class="nt">li</span><span class="p">&gt;</span>
<span class="cp">{%</span> <span class="k">endfor</span> <span class="cp">%}</span>

View File

@ -263,15 +263,15 @@ image. In this case the original is returned instead.
<li><code>url_path</code> the URL path of the thumbnail. This is absolute and needs to
be made relative with the <code>|url</code> filter.</li>
</ul>
<h2 id="example">Example</h2><div class="highlight"><pre><span></span><span class="cp">{%</span> <span class="k">for</span> <span class="nv">image</span> <span class="k">in</span> <span class="nv">this.attachments.images</span> <span class="cp">%}</span>
<h2 id="example">Example</h2><div class="hll"><pre><span></span><span class="cp">{%</span> <span class="k">for</span> <span class="nv">image</span> <span class="k">in</span> <span class="nv">this.attachments.images</span> <span class="cp">%}</span>
<span class="p">&lt;</span><span class="nt">img</span> <span class="na">src</span><span class="o">=</span><span class="s">&quot;</span><span class="cp">{{</span> <span class="nv">image.thumbnail</span><span class="o">(</span><span class="m">64</span><span class="o">)|</span><span class="nf">url</span> <span class="cp">}}</span><span class="s">&quot;</span><span class="p">&gt;</span>
<span class="cp">{%</span> <span class="k">endfor</span> <span class="cp">%}</span>
</pre></div>
<div class="highlight"><pre><span></span><span class="cp">{%</span> <span class="k">for</span> <span class="nv">image</span> <span class="k">in</span> <span class="nv">this.attachments.images</span> <span class="cp">%}</span>
<div class="hll"><pre><span></span><span class="cp">{%</span> <span class="k">for</span> <span class="nv">image</span> <span class="k">in</span> <span class="nv">this.attachments.images</span> <span class="cp">%}</span>
<span class="p">&lt;</span><span class="nt">img</span> <span class="na">src</span><span class="o">=</span><span class="s">&quot;</span><span class="cp">{{</span> <span class="nv">image.thumbnail</span><span class="o">(</span><span class="nv">height</span><span class="o">=</span><span class="m">64</span><span class="o">)|</span><span class="nf">url</span> <span class="cp">}}</span><span class="s">&quot;</span><span class="p">&gt;</span>
<span class="cp">{%</span> <span class="k">endfor</span> <span class="cp">%}</span>
</pre></div>
<div class="highlight"><pre><span></span><span class="p">&lt;</span><span class="nt">img</span> <span class="na">src</span><span class="o">=</span><span class="s">&quot;</span><span class="cp">{{</span> <span class="nv">image.thumbnail</span><span class="o">(</span><span class="m">1920</span><span class="o">,</span> <span class="m">1080</span><span class="o">,</span> <span class="nv">mode</span><span class="o">=</span><span class="s2">&quot;crop&quot;</span><span class="o">,</span> <span class="nv">quality</span><span class="o">=</span><span class="m">40</span><span class="o">)|</span><span class="nf">url</span> <span class="cp">}}</span><span class="s">&quot;</span><span class="p">&gt;</span>
<div class="hll"><pre><span></span><span class="p">&lt;</span><span class="nt">img</span> <span class="na">src</span><span class="o">=</span><span class="s">&quot;</span><span class="cp">{{</span> <span class="nv">image.thumbnail</span><span class="o">(</span><span class="m">1920</span><span class="o">,</span> <span class="m">1080</span><span class="o">,</span> <span class="nv">mode</span><span class="o">=</span><span class="s2">&quot;crop&quot;</span><span class="o">,</span> <span class="nv">quality</span><span class="o">=</span><span class="m">40</span><span class="o">)|</span><span class="nf">url</span> <span class="cp">}}</span><span class="s">&quot;</span><span class="p">&gt;</span>
</pre></div>

View File

@ -240,7 +240,7 @@
<p>If you are dealing with an attachment that is an image, this property becomes
available and indicates the width of the image in pixels if that information
is available.</p>
<h2 id="example">Example</h2><div class="highlight"><pre><span></span><span class="cp">{%</span> <span class="k">for</span> <span class="nv">image</span> <span class="k">in</span> <span class="nv">this.attachments.images</span> <span class="cp">%}</span>
<h2 id="example">Example</h2><div class="hll"><pre><span></span><span class="cp">{%</span> <span class="k">for</span> <span class="nv">image</span> <span class="k">in</span> <span class="nv">this.attachments.images</span> <span class="cp">%}</span>
<span class="p">&lt;</span><span class="nt">img</span> <span class="na">src</span><span class="o">=</span><span class="s">&quot;</span><span class="cp">{{</span> <span class="nv">image</span><span class="o">|</span><span class="nf">url</span> <span class="cp">}}</span><span class="s">&quot;</span>
<span class="na">width</span><span class="o">=</span><span class="s">&quot;</span><span class="cp">{{</span> <span class="nv">image.width</span> <span class="cp">}}</span><span class="s">&quot;</span>
<span class="na">height</span><span class="o">=</span><span class="s">&quot;</span><span class="cp">{{</span> <span class="nv">image.height</span> <span class="cp">}}</span><span class="s">&quot;</span><span class="p">&gt;</span>

View File

@ -227,7 +227,7 @@
is useful in situations where a stable ID is needed that follows a certain
format. For instance it can come in useful when a ID is needed for a DOM
element.</p>
<h2 id="example">Example</h2><div class="highlight"><pre><span></span><span class="p">&lt;</span><span class="nt">body</span> <span class="na">class</span><span class="o">=</span><span class="s">&quot;page-</span><span class="cp">{{</span> <span class="nv">this._gid</span> <span class="cp">}}</span><span class="s">&quot;</span><span class="p">&gt;</span>
<h2 id="example">Example</h2><div class="hll"><pre><span></span><span class="p">&lt;</span><span class="nt">body</span> <span class="na">class</span><span class="o">=</span><span class="s">&quot;page-</span><span class="cp">{{</span> <span class="nv">this._gid</span> <span class="cp">}}</span><span class="s">&quot;</span><span class="p">&gt;</span>
...
<span class="p">&lt;/</span><span class="nt">body</span><span class="p">&gt;</span>
</pre></div>

View File

@ -233,7 +233,7 @@ filename of the attachment: <code>screenshot.jpg</code>.</p>
<p>Note that IDs are not globally unique! There is also the <code>_path</code> which is
the entire path if the record.</p>
<p>The <code>_id</code> is automatically set and cannot be overridden.</p>
<h2 id="example">Example</h2><div class="highlight"><pre><span></span><span class="p">&lt;</span><span class="nt">ul</span> <span class="na">class</span><span class="o">=</span><span class="s">&quot;nav&quot;</span><span class="p">&gt;</span>
<h2 id="example">Example</h2><div class="hll"><pre><span></span><span class="p">&lt;</span><span class="nt">ul</span> <span class="na">class</span><span class="o">=</span><span class="s">&quot;nav&quot;</span><span class="p">&gt;</span>
<span class="cp">{%</span> <span class="k">for</span> <span class="nv">item</span> <span class="k">in</span> <span class="nv">site.query</span><span class="o">(</span><span class="s1">&#39;/projects&#39;</span><span class="o">)</span> <span class="cp">%}</span>
<span class="p">&lt;</span><span class="nt">li</span><span class="cp">{%</span> <span class="k">if</span> <span class="nv">item._id</span> <span class="o">==</span> <span class="nv">this._id</span> <span class="cp">%}</span> <span class="na">class</span><span class="o">=</span><span class="s">&quot;active&quot;</span><span class="cp">{%</span>
<span class="k">endif</span> <span class="cp">%}</span><span class="p">&gt;</span><span class="cp">{{</span> <span class="nv">item.name</span> <span class="cp">}}</span><span class="p">&lt;/</span><span class="nt">li</span><span class="p">&gt;</span>

View File

@ -227,7 +227,7 @@
many situations the model is picked automatically but for equally many
situations it needs to be selected manually.</p>
<p>This field is most useful for filtering when operating on mixed collections.</p>
<h2 id="example">Example</h2><div class="highlight"><pre><span></span><span class="p">&lt;</span><span class="nt">ul</span> <span class="na">class</span><span class="o">=</span><span class="s">&quot;projects&quot;</span><span class="p">&gt;</span>
<h2 id="example">Example</h2><div class="hll"><pre><span></span><span class="p">&lt;</span><span class="nt">ul</span> <span class="na">class</span><span class="o">=</span><span class="s">&quot;projects&quot;</span><span class="p">&gt;</span>
<span class="cp">{%</span> <span class="k">for</span> <span class="nv">child</span> <span class="k">in</span> <span class="nv">this.children.filter</span><span class="o">(</span><span class="nv">F._model</span> <span class="o">==</span> <span class="s1">&#39;project&#39;</span><span class="o">)</span> <span class="cp">%}</span>
<span class="p">&lt;</span><span class="nt">li</span><span class="p">&gt;</span><span class="cp">{{</span> <span class="nv">child.name</span> <span class="cp">}}</span><span class="p">&lt;/</span><span class="nt">li</span><span class="p">&gt;</span>
<span class="cp">{%</span> <span class="k">endfor</span> <span class="cp">%}</span>

View File

@ -230,7 +230,7 @@ would be <code>docs/api/db</code>.</p>
<p>The path can be used to uniquely identify a page but for that purpose the
<a href="../gid/"><code>_gid</code></a> can also be used which is a hashed hexadecimal version of
the page.</p>
<h2 id="example">Example</h2><div class="highlight"><pre><span></span><span class="cm">&lt;!-- generated from </span><span class="cp">{{</span> <span class="nv">this._path</span> <span class="cp">}}</span><span class="cm"> --&gt;</span>
<h2 id="example">Example</h2><div class="hll"><pre><span></span><span class="cm">&lt;!-- generated from </span><span class="cp">{{</span> <span class="nv">this._path</span> <span class="cp">}}</span><span class="cm"> --&gt;</span>
</pre></div>

View File

@ -228,7 +228,7 @@ to support the builder. In particular the difference to the <code>_alt</code> f
that this one will indicate if an alt falls back to a different alternative.
At present pages can only fall back to the <code>_primary</code> alternative which will
be reflected by this field.</p>
<h2 id="example">Example</h2><div class="highlight"><pre><span></span><span class="cm">&lt;!-- generated from language </span><span class="cp">{{</span> <span class="nv">this._source_alt</span> <span class="cp">}}</span><span class="cm"> --&gt;</span>
<h2 id="example">Example</h2><div class="hll"><pre><span></span><span class="cm">&lt;!-- generated from language </span><span class="cp">{{</span> <span class="nv">this._source_alt</span> <span class="cp">}}</span><span class="cm"> --&gt;</span>
</pre></div>

View File

@ -201,7 +201,7 @@ method and set the <code>widget</code> property as a very basic requirement.</p>
to match the type name. If you want to name your type <code>mything</code> then it
needs to be called <code>MyThingType</code>. Afterwards you can register it with the
environment in <a href="../../plugins/events/setup-env/" class="ref">setup_env</a>:</p>
<div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">lektor.types</span> <span class="kn">import</span> <span class="n">Type</span>
<div class="hll"><pre><span></span><span class="kn">from</span> <span class="nn">lektor.types</span> <span class="kn">import</span> <span class="n">Type</span>
<span class="k">class</span> <span class="nc">MyThingType</span><span class="p">(</span><span class="n">Type</span><span class="p">):</span>
<span class="n">widget</span> <span class="o">=</span> <span class="s1">&#39;singleline-text&#39;</span>

View File

@ -211,7 +211,7 @@ database layer. This can be any Python type for as long as it makes sense.
It must either return a valid value or a special value that indicates a bad
value. For more information see the raw value information below and the
example provided.</p>
<h2 id="example">Example</h2><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">lektor.types</span> <span class="kn">import</span> <span class="n">Type</span>
<h2 id="example">Example</h2><div class="hll"><pre><span></span><span class="kn">from</span> <span class="nn">lektor.types</span> <span class="kn">import</span> <span class="n">Type</span>
<span class="k">class</span> <span class="nc">LocationType</span><span class="p">(</span><span class="n">Type</span><span class="p">):</span>
<span class="n">widget</span> <span class="o">=</span> <span class="s1">&#39;singleline-text&#39;</span>

View File

@ -210,7 +210,7 @@ but you can select one of the built-in widgets for your own type. Note that
not all widgets will necessarily will work directly with your type as such.
For instance the <code>select</code> widget and some others will currently require some
extra values be supplied in the <a href="../to-json/" class="ref">to_json</a> method.</p>
<h2 id="example">Example</h2><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">lektor.types</span> <span class="kn">import</span> <span class="n">Type</span>
<h2 id="example">Example</h2><div class="hll"><pre><span></span><span class="kn">from</span> <span class="nn">lektor.types</span> <span class="kn">import</span> <span class="n">Type</span>
<span class="k">class</span> <span class="nc">MyThingType</span><span class="p">(</span><span class="n">Type</span><span class="p">):</span>
<span class="n">widget</span> <span class="o">=</span> <span class="s1">&#39;singleline-text&#39;</span>

View File

@ -264,13 +264,13 @@ It's most useful for representing flags that can be enabled or disabled.</p>
</table>
<p>The <code>checkbox_label</code> attribute can be used to give a description to the
checkbox which otherwise looks a little bit lonely in the admin panel.</p>
<h2 id="field-usage">Field Usage</h2><div class="highlight"><pre><span></span><span class="k">[fields.render_big]</span><span class="w"></span>
<h2 id="field-usage">Field Usage</h2><div class="hll"><pre><span></span><span class="k">[fields.render_big]</span><span class="w"></span>
<span class="na">label</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">Render big</span><span class="w"></span>
<span class="na">type</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">boolean</span><span class="w"></span>
<span class="na">checkbox_label</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">If true, then the page will be rendered larger.</span><span class="w"></span>
<span class="na">default</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">false</span><span class="w"></span>
</pre></div>
<h2 id="template-usage">Template Usage</h2><div class="highlight"><pre><span></span><span class="p">&lt;</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">&quot;page</span><span class="cp">{%</span> <span class="k">if</span> <span class="nv">this.render_big</span> <span class="cp">%}</span><span class="s"> page-large</span><span class="cp">{%</span> <span class="k">endif</span> <span class="cp">%}</span><span class="s">&quot;</span><span class="p">&gt;</span>
<h2 id="template-usage">Template Usage</h2><div class="hll"><pre><span></span><span class="p">&lt;</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">&quot;page</span><span class="cp">{%</span> <span class="k">if</span> <span class="nv">this.render_big</span> <span class="cp">%}</span><span class="s"> page-large</span><span class="cp">{%</span> <span class="k">endif</span> <span class="cp">%}</span><span class="s">&quot;</span><span class="p">&gt;</span>
...
<span class="p">&lt;/</span><span class="nt">div</span><span class="p">&gt;</span>
</pre></div>

View File

@ -258,13 +258,13 @@ default which means that the record's configured title will be used as
label.</li>
</ul>
<p>In the contents file the values are stored as comma separated list.</p>
<h2 id="field-usage">Field Usage</h2><div class="highlight"><pre><span></span><span class="k">[fields.slideshow]</span><span class="w"></span>
<h2 id="field-usage">Field Usage</h2><div class="hll"><pre><span></span><span class="k">[fields.slideshow]</span><span class="w"></span>
<span class="na">label</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">Slideshow</span><span class="w"></span>
<span class="na">type</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">checkboxes</span><span class="w"></span>
<span class="na">description</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">Attached images to include in the slidehow</span><span class="w"></span>
<span class="na">source</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">record.attachments.images</span><span class="w"></span>
</pre></div>
<h2 id="template-usage">Template Usage</h2><div class="highlight"><pre><span></span><span class="cp">{%</span> <span class="k">for</span> <span class="nv">image</span> <span class="k">in</span> <span class="nv">this.attachments.images</span> <span class="cp">%}</span>
<h2 id="template-usage">Template Usage</h2><div class="hll"><pre><span></span><span class="cp">{%</span> <span class="k">for</span> <span class="nv">image</span> <span class="k">in</span> <span class="nv">this.attachments.images</span> <span class="cp">%}</span>
<span class="cp">{%</span> <span class="k">if</span> <span class="nv">image._id</span> <span class="k">in</span> <span class="nv">this.slideshow</span> <span class="cp">%}</span>
<span class="p">&lt;</span><span class="nt">img</span> <span class="na">src</span><span class="o">=</span><span class="s">&quot;</span><span class="cp">{{</span> <span class="nv">image.thumbnail</span><span class="o">(</span><span class="m">500</span><span class="o">)</span> <span class="cp">}}</span><span class="s">&quot;</span> <span class="na">class</span><span class="o">=</span><span class="s">&quot;slide&quot;</span><span class="p">&gt;</span>
<span class="cp">{%</span> <span class="k">endif</span> <span class="cp">%}</span>

View File

@ -241,11 +241,11 @@
than a plain old <code>string</code> some basic operations can be provided in the
templates.</p>
<p>The canonical format for the type in text form is <code>YYYY-MM-DD</code>.</p>
<h2 id="field-usage">Field Usage</h2><div class="highlight"><pre><span></span><span class="k">[fields.pub_date]</span><span class="w"></span>
<h2 id="field-usage">Field Usage</h2><div class="hll"><pre><span></span><span class="k">[fields.pub_date]</span><span class="w"></span>
<span class="na">label</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">Publication date</span><span class="w"></span>
<span class="na">type</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">date</span><span class="w"></span>
</pre></div>
<h2 id="template-usage">Template Usage</h2><div class="highlight"><pre><span></span><span class="p">&lt;</span><span class="nt">p</span><span class="p">&gt;</span>Published: <span class="cp">{{</span> <span class="nv">this.pub_date.strftime</span><span class="o">(</span><span class="s1">&#39;%d/%m/%Y&#39;</span><span class="o">)</span> <span class="cp">}}</span>
<h2 id="template-usage">Template Usage</h2><div class="hll"><pre><span></span><span class="p">&lt;</span><span class="nt">p</span><span class="p">&gt;</span>Published: <span class="cp">{{</span> <span class="nv">this.pub_date.strftime</span><span class="o">(</span><span class="s1">&#39;%d/%m/%Y&#39;</span><span class="o">)</span> <span class="cp">}}</span>
</pre></div>

View File

@ -271,11 +271,11 @@ or
pub_date: 2016-01-13 07:53:22 +0900
</code></pre>
<h2 id="field-usage">Field Usage</h2><div class="highlight"><pre><span></span><span class="k">[fields.pub_date]</span><span class="w"></span>
<h2 id="field-usage">Field Usage</h2><div class="hll"><pre><span></span><span class="k">[fields.pub_date]</span><span class="w"></span>
<span class="na">label</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">Publication date</span><span class="w"></span>
<span class="na">type</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">datetime</span><span class="w"></span>
</pre></div>
<h2 id="template-usage">Template Usage</h2><div class="highlight"><pre><span></span><span class="p">&lt;</span><span class="nt">p</span><span class="p">&gt;</span>Published: <span class="cp">{{</span> <span class="nv">this.pub_date.strftime</span><span class="o">(</span><span class="s1">&#39;%Y-%m-%d %H:%M:%S&#39;</span><span class="o">)</span> <span class="cp">}}</span>
<h2 id="template-usage">Template Usage</h2><div class="hll"><pre><span></span><span class="p">&lt;</span><span class="nt">p</span><span class="p">&gt;</span>Published: <span class="cp">{{</span> <span class="nv">this.pub_date.strftime</span><span class="o">(</span><span class="s1">&#39;%Y-%m-%d %H:%M:%S&#39;</span><span class="o">)</span> <span class="cp">}}</span>
</pre></div>

View File

@ -239,13 +239,13 @@
<p>The <code>float</code> type is similar to the <a href="../integer/" class="ref">integer</a> one but it
can store floating points instead of just integer values.</p>
<h2 id="field-usage">Field Usage</h2><div class="highlight"><pre><span></span><span class="k">[fields.percentage]</span><span class="w"></span>
<h2 id="field-usage">Field Usage</h2><div class="hll"><pre><span></span><span class="k">[fields.percentage]</span><span class="w"></span>
<span class="na">label</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">Percentage</span><span class="w"></span>
<span class="na">type</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">float</span><span class="w"></span>
<span class="na">description</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">Just a percentage of a progress bar.</span><span class="w"></span>
<span class="na">addon_label</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">%</span><span class="w"></span>
</pre></div>
<h2 id="template-usage">Template Usage</h2><div class="highlight"><pre><span></span><span class="p">&lt;</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">&quot;progress-bar&quot;</span><span class="p">&gt;</span>
<h2 id="template-usage">Template Usage</h2><div class="hll"><pre><span></span><span class="p">&lt;</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">&quot;progress-bar&quot;</span><span class="p">&gt;</span>
<span class="p">&lt;</span><span class="nt">span</span> <span class="na">class</span><span class="o">=</span><span class="s">&quot;progress&quot;</span> <span class="na">style</span><span class="o">=</span><span class="s">&quot;width: </span><span class="cp">{{</span> <span class="nv">this.percentage</span> <span class="cp">}}</span><span class="s">%&quot;</span><span class="p">&gt;&lt;/</span><span class="nt">span</span><span class="p">&gt;</span>
<span class="p">&lt;</span><span class="nt">span</span> <span class="na">class</span><span class="o">=</span><span class="s">&quot;label&quot;</span><span class="p">&gt;</span><span class="cp">{{</span> <span class="nv">this.percentage</span> <span class="cp">}}</span>%<span class="p">&lt;/</span><span class="nt">span</span><span class="p">&gt;</span>
<span class="p">&lt;/</span><span class="nt">div</span><span class="p">&gt;</span>

View File

@ -267,17 +267,17 @@ field-2: value 2
within it, but the blocks can be individually accessed through the
<code>blocks</code> attribute. Each block's attributes are the individual fields which
you are free to access if so desired.</p>
<h2 id="field-usage">Field Usage</h2><div class="highlight"><pre><span></span><span class="k">[fields.body]</span><span class="w"></span>
<h2 id="field-usage">Field Usage</h2><div class="hll"><pre><span></span><span class="k">[fields.body]</span><span class="w"></span>
<span class="na">label</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">Body</span><span class="w"></span>
<span class="na">type</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">flow</span><span class="w"></span>
<span class="na">flow_blocks</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">text, image</span><span class="w"></span>
</pre></div>
<h2 id="template-usage">Template Usage</h2><div class="highlight"><pre><span></span><span class="p">&lt;</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">&quot;body&quot;</span><span class="p">&gt;</span>
<h2 id="template-usage">Template Usage</h2><div class="hll"><pre><span></span><span class="p">&lt;</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">&quot;body&quot;</span><span class="p">&gt;</span>
<span class="cp">{{</span> <span class="nv">this.body</span> <span class="cp">}}</span>
<span class="p">&lt;/</span><span class="nt">div</span><span class="p">&gt;</span>
</pre></div>
<p>or more complex:</p>
<div class="highlight"><pre><span></span><span class="p">&lt;</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">&quot;body&quot;</span><span class="p">&gt;</span>
<div class="hll"><pre><span></span><span class="p">&lt;</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">&quot;body&quot;</span><span class="p">&gt;</span>
<span class="cp">{%</span> <span class="k">for</span> <span class="nv">item</span> <span class="k">in</span> <span class="nv">this.body.blocks</span> <span class="cp">%}</span>
<span class="p">&lt;</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">&quot;block&quot;</span><span class="p">&gt;</span><span class="cp">{{</span> <span class="nv">item</span> <span class="cp">}}</span><span class="p">&lt;/</span><span class="nt">div</span><span class="p">&gt;</span>
<span class="cp">{%</span> <span class="k">endfor</span> <span class="cp">%}</span>

View File

@ -240,12 +240,12 @@
<p>The <code>html</code> type is basically the same as the <a href="../text/" class="ref">text</a> type but
in templates it's rendered directly as HTML instead of being escaped.</p>
<p>It renders as a multi-line input field in the admin interface.</p>
<h2 id="field-usage">Field Usage</h2><div class="highlight"><pre><span></span><span class="k">[fields.tracking_code]</span><span class="w"></span>
<h2 id="field-usage">Field Usage</h2><div class="hll"><pre><span></span><span class="k">[fields.tracking_code]</span><span class="w"></span>
<span class="na">label</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">Tracking Code</span><span class="w"></span>
<span class="na">description</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">raw HTML that is inserted for ad tracking purposes.</span><span class="w"></span>
<span class="na">type</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">html</span><span class="w"></span>
</pre></div>
<h2 id="template-usage">Template Usage</h2><div class="highlight"><pre><span></span><span class="cp">{{</span> <span class="nv">this.tracking_code</span> <span class="cp">}}</span>
<h2 id="template-usage">Template Usage</h2><div class="hll"><pre><span></span><span class="cp">{{</span> <span class="nv">this.tracking_code</span> <span class="cp">}}</span>
</pre></div>

View File

@ -241,13 +241,13 @@
arbitrary natural numbers both negative and positive. It should be used
instead of a string when a real number with such behavior is wanted as it
sorts numbers correctly and the numbers can be manipulated.</p>
<h2 id="field-usage">Field Usage</h2><div class="highlight"><pre><span></span><span class="k">[fields.image_width]</span><span class="w"></span>
<h2 id="field-usage">Field Usage</h2><div class="hll"><pre><span></span><span class="k">[fields.image_width]</span><span class="w"></span>
<span class="na">label</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">Image width</span><span class="w"></span>
<span class="na">type</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">integer</span><span class="w"></span>
<span class="na">description</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">The intended image width in pixels.</span><span class="w"></span>
<span class="na">addon_label</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">px</span><span class="w"></span>
</pre></div>
<h2 id="template-usage">Template Usage</h2><div class="highlight"><pre><span></span><span class="p">&lt;</span><span class="nt">img</span>
<h2 id="template-usage">Template Usage</h2><div class="hll"><pre><span></span><span class="p">&lt;</span><span class="nt">img</span>
<span class="na">src</span><span class="o">=</span><span class="s">&quot;</span><span class="cp">{{</span> <span class="nv">this.image.thumbnail</span><span class="o">(</span><span class="nv">this.image_width</span> <span class="o">-</span> <span class="m">10</span><span class="o">)</span> <span class="cp">}}</span><span class="s">&quot;</span>
<span class="na">alt</span><span class="o">=</span><span class="s">&quot;a thumbnail of that image&quot;</span>
<span class="na">style</span><span class="o">=</span><span class="s">&quot;border: 5px;&quot;</span><span class="p">&gt;</span>

View File

@ -261,11 +261,11 @@ there are some special attributes on it to access more information:</p>
</tbody>
</table>
<p>Additional attributes can become available through the use of plugins.</p>
<h2 id="field-usage">Field Usage</h2><div class="highlight"><pre><span></span><span class="k">[fields.body]</span><span class="w"></span>
<h2 id="field-usage">Field Usage</h2><div class="hll"><pre><span></span><span class="k">[fields.body]</span><span class="w"></span>
<span class="na">label</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">Body</span><span class="w"></span>
<span class="na">type</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">markdown</span><span class="w"></span>
</pre></div>
<h2 id="template-usage">Template Usage</h2><div class="highlight"><pre><span></span><span class="p">&lt;</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">&quot;body&quot;</span><span class="p">&gt;</span>
<h2 id="template-usage">Template Usage</h2><div class="hll"><pre><span></span><span class="p">&lt;</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">&quot;body&quot;</span><span class="p">&gt;</span>
<span class="cp">{{</span> <span class="nv">this.body</span> <span class="cp">}}</span>
<span class="p">&lt;/</span><span class="nt">div</span><span class="p">&gt;</span>
</pre></div>

View File

@ -241,13 +241,13 @@
but unlike it you can only select a single item. For configuration options
refer directly to the checkboxes type.</p>
<p>In the contents file the values are stored as a single textual item.</p>
<h2 id="field-usage">Field Usage</h2><div class="highlight"><pre><span></span><span class="k">[fields.class]</span><span class="w"></span>
<h2 id="field-usage">Field Usage</h2><div class="hll"><pre><span></span><span class="k">[fields.class]</span><span class="w"></span>
<span class="na">label</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">Class</span><span class="w"></span>
<span class="na">type</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">select</span><span class="w"></span>
<span class="na">choices</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">full-width, pull-left, pull-right</span><span class="w"></span>
<span class="na">choice_labels</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">Full Width, Pull Left, Pull Right</span><span class="w"></span>
</pre></div>
<h2 id="template-usage">Template Usage</h2><div class="highlight"><pre><span></span><span class="p">&lt;</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">&quot;</span><span class="cp">{{</span> <span class="nv">this.class</span> <span class="cp">}}</span><span class="s">&quot;</span><span class="p">&gt;</span>
<h2 id="template-usage">Template Usage</h2><div class="hll"><pre><span></span><span class="p">&lt;</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">&quot;</span><span class="cp">{{</span> <span class="nv">this.class</span> <span class="cp">}}</span><span class="s">&quot;</span><span class="p">&gt;</span>
...
<span class="p">&lt;/</span><span class="nt">div</span><span class="p">&gt;</span>
</pre></div>

View File

@ -240,7 +240,7 @@ basic ones in Lektor. It can store arbitrary natural numbers both negative and
positive. It's intended for giving pages a sort order. The reason it's a
special type is that future versions of Lektor can take advantage of this to
implement a widget for ordering.</p>
<h2 id="field-usage">Field Usage</h2><div class="highlight"><pre><span></span><span class="k">[fields.sort_key]</span><span class="w"></span>
<h2 id="field-usage">Field Usage</h2><div class="hll"><pre><span></span><span class="k">[fields.sort_key]</span><span class="w"></span>
<span class="na">label</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">Sort order</span><span class="w"></span>
<span class="na">type</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">sort_key</span><span class="w"></span>
</pre></div>

View File

@ -241,14 +241,14 @@
arbitrary text. It's useful for many places where you want to show a bit of
text without any special formatting (titles, basic summaries and more).</p>
<p>It renders as a basic input field in the admin interface.</p>
<h2 id="field-usage">Field Usage</h2><div class="highlight"><pre><span></span><span class="k">[fields.title]</span><span class="w"></span>
<h2 id="field-usage">Field Usage</h2><div class="hll"><pre><span></span><span class="k">[fields.title]</span><span class="w"></span>
<span class="na">label</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">Title</span><span class="w"></span>
<span class="na">type</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">string</span><span class="w"></span>
<span class="na">size</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">large</span><span class="w"></span>
<span class="na">description</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">The title of the page</span><span class="w"></span>
<span class="na">addon_label</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">[[header]]</span><span class="w"></span>
</pre></div>
<h2 id="template-usage">Template Usage</h2><div class="highlight"><pre><span></span><span class="p">&lt;</span><span class="nt">h1</span><span class="p">&gt;</span><span class="cp">{{</span> <span class="nv">this.title</span> <span class="cp">}}</span><span class="p">&lt;/</span><span class="nt">h1</span><span class="p">&gt;</span>
<h2 id="template-usage">Template Usage</h2><div class="hll"><pre><span></span><span class="p">&lt;</span><span class="nt">h1</span><span class="p">&gt;</span><span class="cp">{{</span> <span class="nv">this.title</span> <span class="cp">}}</span><span class="p">&lt;/</span><span class="nt">h1</span><span class="p">&gt;</span>
</pre></div>

View File

@ -242,12 +242,12 @@ and <a href="../text/" class="ref">text</a> type. It renders as a multi-line te
admin but the template will see each line of text separately. It's primarily
useful for some advanced scenarios where enumerations and other things
should be rendered.</p>
<h2 id="field-usage">Field Usage</h2><div class="highlight"><pre><span></span><span class="k">[fields.things_to_buy]</span><span class="w"></span>
<h2 id="field-usage">Field Usage</h2><div class="hll"><pre><span></span><span class="k">[fields.things_to_buy]</span><span class="w"></span>
<span class="na">label</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">Things to buy</span><span class="w"></span>
<span class="na">type</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">strings</span><span class="w"></span>
<span class="na">description</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">A list of things that would be good to buy</span><span class="w"></span>
</pre></div>
<h2 id="template-usage">Template Usage</h2><div class="highlight"><pre><span></span><span class="p">&lt;</span><span class="nt">h2</span><span class="p">&gt;</span>Shopping List<span class="p">&lt;/</span><span class="nt">h2</span><span class="p">&gt;</span>
<h2 id="template-usage">Template Usage</h2><div class="hll"><pre><span></span><span class="p">&lt;</span><span class="nt">h2</span><span class="p">&gt;</span>Shopping List<span class="p">&lt;/</span><span class="nt">h2</span><span class="p">&gt;</span>
<span class="p">&lt;</span><span class="nt">ul</span><span class="p">&gt;</span>
<span class="cp">{%</span> <span class="k">for</span> <span class="nv">item</span> <span class="k">in</span> <span class="nv">this.things_to_buy</span> <span class="cp">%}</span>
<span class="p">&lt;</span><span class="nt">li</span><span class="p">&gt;</span><span class="cp">{{</span> <span class="nv">item</span> <span class="cp">}}</span><span class="p">&lt;/</span><span class="nt">li</span><span class="p">&gt;</span>

Some files were not shown because too many files have changed in this diff Show More