<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.16"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Grantlee: Builtin tags and filters.</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="stylesheet.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">Grantlee
   &#160;<span id="projectnumber">5.2.0</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.16 -->
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',false,false,'search.php','Search');
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<div class="PageDoc"><div class="header">
  <div class="headertitle">
<div class="title">Builtin tags and filters. </div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><h1><a class="anchor" id="django_builtins"></a>
Tags and filters ported from Django</h1>
<p>See the <a href="https://docs.djangoproject.com/en/1.9/ref/templates/builtins/">Builtins documentation for Django 1.9</a> for an overview of the builtin tags and filters available in Grantlee. Almost all tags and filter in django are available in Grantlee. Exceptions are <a href="https://docs.djangoproject.com/en/1.9/ref/templates/builtins/#url">the <code>url tag</code></a>, because Grantlee does not have a views system. Additionally the <code>ssi</code> tag is disabled because of potential security risks. The <code>dictdort</code>, <code>dictsortreversed</code>, <code>filesizeformat</code>, <code>iriencode</code>, <code>phone2numeric</code>, <code>pluralize</code>, <code>pprint</code>, <code>title</code>, <code>truncatewords_html</code>, <code>urlencode</code>, <code>urlize</code> and <code>urlizetrunc</code> filters have not yet been ported due to time constraints.</p>
<h1><a class="anchor" id="grantlee_extras"></a>
Additional tags available in Grantlee</h1>
<p>Grantlee also provides some extra tags not available in Django.</p>
<h2><a class="anchor" id="media_finder_tag"></a>
media_finder</h2>
<p>Queries Grantlee for a complete URL, given a target name.</p>
<p>This tag can typically be used to insert a URL for an image, external script or CSS file, or other external media.</p>
<div class="fragment"><div class="line">&lt;img src=<span class="stringliteral">&quot;{% media_finder &quot;</span>someimage.png<span class="stringliteral">&quot; %}&quot;</span> /&gt;</div>
</div><!-- fragment --><p>The <code>media_finder</code> tag retrieves the result through <a class="el" href="classGrantlee_1_1Engine.html#a2e91c58ba9460b5a815a416f0cbaf697">Engine::mediaUri</a>, which in turn queries the TemplateLoaders for the URL to return via the <a class="el" href="classGrantlee_1_1AbstractTemplateLoader.html#a0999985cb7c78409af0614e85bdd1cc0">AbstractTemplateLoader::getMediaUri</a> interface.</p>
<p>It is possible to configure whether absolute or relative urls are created by using the <a class="el" href="classGrantlee_1_1Context.html#a6de6e0d43c3ba595c9d96494692a944c">Context::setUrlType</a> method. If the path to external media is not the same as the path to the template, the <a class="el" href="classGrantlee_1_1Context.html#a283ede44a1f7329a9dd9822d39551a98">Context::setRelativeMediaPath</a> method can be used to specify a relative base path. For example, if creating a template <code>/home/user/myoutput.html</code> which references <code>someimage.png</code>, the path <code>"myoutput_media/"</code> can be set so that the <code>{%&#160;media_finder&#160;%}</code> puts the path <code>myoutput_media/someimage.png</code> into the template. This way the output and the media it references are portable together.</p>
<p>It is the responsibility of the caller to copy the media to the <code>/home/user/myoutput_media/</code> directory.</p>
<p>with <code>media_prefix</code> defined to nothing when creating output with absolute urls, and something like <code>"media/"</code> if creating output with relative urls and external media should be available in the <code>media/</code> subdirectory.</p>
<h2><a class="anchor" id="range_tag"></a>
range</h2>
<p>Loops over a range in a manner similar to the <a href="http://docs.python.org/library/functions.html#range">python builtin of the same name</a>.</p>
<p>Create a list from 0 to 5: </p><div class="fragment"><div class="line">&lt;ul&gt;</div>
<div class="line">{% range 5 as num %}</div>
<div class="line">  &lt;li&gt;{{ num }}</div>
<div class="line">{% endrange %}</div>
<div class="line">&lt;/ul&gt;</div>
</div><!-- fragment --><p>Create a list from 5 to 10: </p><div class="fragment"><div class="line">&lt;ul&gt;</div>
<div class="line">{% range 5 10 as num %}</div>
<div class="line">  &lt;li&gt;{{ num }}</div>
<div class="line">{% endrange %}</div>
<div class="line">&lt;/ul&gt;</div>
</div><!-- fragment --><p>Create a list from 5 to 50 with a step of 5: </p><div class="fragment"><div class="line">&lt;ul&gt;</div>
<div class="line">{% range 5 50 5 as num %}</div>
<div class="line">  &lt;li&gt;{{ num }}</div>
<div class="line">{% endrange %}</div>
<div class="line">&lt;/ul&gt;</div>
</div><!-- fragment --><p>The range tag can also be used without arguments:</p>
<div class="fragment"><div class="line">{% range rating %}</div>
<div class="line">  &lt;img src=<span class="stringliteral">&quot;{% media_finder &quot;</span>star.png<span class="stringliteral">&quot; %}&quot;</span> /&gt;</div>
<div class="line">{% endrange %}</div>
</div><!-- fragment --> </div></div><!-- contents -->
</div><!-- PageDoc -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.16
</small></address>
</body>
</html>
