Skip to content
This repository has been archived by the owner on Apr 11, 2018. It is now read-only.

Commit

Permalink
pave way for custom filters in extending page
Browse files Browse the repository at this point in the history
  • Loading branch information
paularmstrong committed Aug 17, 2013
1 parent 1bbb8df commit ec8f4a0
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 84 deletions.
120 changes: 46 additions & 74 deletions docs/docs/extending.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,57 +4,57 @@

{% block content %}

{% macro description(el) %}
<p>{{ el.description|replace('\n', '</p><p>')|raw }}</p>
{% endmacro %}
{% macro description(el) %}
<p>{{ el.description|replace('\n', '</p><p>')|raw }}</p>
{% endmacro %}

<h1 id="extending">Extending Swig</h1>
<h1 id="extending">Extending Swig</h1>

<section class="doc" id="tags">
<h2>Custom Tags</h2>
<section class="doc" id="tags">
<h2>Custom Tags</h2>

<p>Swig can be extended to handle custom tags that will perform operations on full blocks of your templates. Use <a href="{{ baseurl }}/docs/api/#addTag"><code data-language="js">swig.addTag(name, parse, compile, ends)</code></a> to add your custom tag.</p>
<p>Swig can be extended to handle custom tags that will perform operations on full blocks of your templates. Use <a href="{{ baseurl }}/docs/api/#addTag"><code data-language="js">swig.addTag(name, parse, compile, ends)</code></a> to add your custom tag.</p>

<p>All of Swig's tags are written using the same api (with a few exceptions for core modules, like <var>extends</var> and <var>block</var>). View a tag's source to see more examples to write your own custom tags.</p>
<p>All of Swig's tags are written using the same api (with a few exceptions for core modules, like <var>extends</var> and <var>block</var>). View a tag's source to see more examples to write your own custom tags.</p>

{% for t in typedefs %}{% if t.name === 'parse' or t.name === 'compile' %}
<section id="{{ t.name }}" class="doc">
<h3>{{ t.name }}({% for p in t.params %}{{ p.name }}{% if not loop.last %}, {% endif %}{% endfor %})</h3>
{% for t in typedefs %}{% if t.name === 'parse' or t.name === 'compile' %}
<section id="{{ t.name }}" class="doc">
<h3>{{ t.name }}({% for p in t.params %}{{ p.name }}{% if not loop.last %}, {% endif %}{% endfor %})</h3>

<p>{{ description(t)|raw }}</p>
<p>{{ description(t)|raw }}</p>

<h4>Arguments</h4>
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Optional</th>
<th>Default</th>
<th>Description</th>
</tr>
</thead>
<tbody>
{% for p in t.params %}
<h4>Arguments</h4>
<table>
<thead>
<tr>
<td><var data-language="js">{{ p.name }}</var></td>
<td><code data-language="js">{{ p.type }}</code></td>
<td>{% if p.optional %}✔{% endif %}</td>
<td><samp data-language="js">{{ p.default }}</samp></td>
<td>{{ p.description|raw }}</td>
<th>Name</th>
<th>Type</th>
<th>Optional</th>
<th>Default</th>
<th>Description</th>
</tr>
{% endfor %}
</tbody>
</table>

{% for ex in t.examples %}
<pre><code data-language="js">{{ ex }}</code></pre>
</thead>
<tbody>
{% for p in t.params %}
<tr>
<td><var data-language="js">{{ p.name }}</var></td>
<td><code data-language="js">{{ p.type }}</code></td>
<td>{% if p.optional %}✔{% endif %}</td>
<td><samp data-language="js">{{ p.default }}</samp></td>
<td>{{ description(p)|raw }}</td>
</tr>
{% endfor %}
</tbody>
</table>

</section>
{% endif %}{% endfor %}
{% for ex in t.examples %}
<pre><code data-language="js">{{ ex }}</code></pre>
{% endfor %}

</section>
{% endif %}{% endfor %}

<section id="ends" class="doc">
<section id="ends" class="doc">
<h3>ends</h3>

<p>Controls whether or not a tag must have an <code data-language="swig">{% raw %}{% end[tagName] %}{% endraw %}</code> declared after usage in templates.</p>
Expand All @@ -64,13 +64,13 @@ <h3>ends</h3>

<pre><code data-language="js">exports.ends = false;
// => A template attempts close this tag will throw an Error.</code></pre>
</section>
</section>

{% for prop in properties %}
{% if prop.isEnum %}
<section id="{{ prop.name }}" class="doc">
<h3>{{ prop.name }}</h3>
<p>{{ prop.description|replace('\n', '</p><p>')|raw }}</p>
<p>{{ description(prop)|raw }}</p>
<table>
<thead>
<tr>
Expand Down Expand Up @@ -107,40 +107,11 @@ <h3>{{ prop.name }}</h3>
</section>
{% endif %}
{% endfor %}
</section>

{# % for typedef in typedefs %}
{% if typedef.type|lower === 'object' %}
<section id="{{ typedef.name }}" class="doc">
<h3>{{ typedef.name }}</h3>
<p>{{ description(typedef)|raw }}</p>

<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Optional</th>
<th>Default</th>
<th>Description</th>
</tr>
</thead>
<tbody>
{% for p in typedef.properties %}
<tr>
<td><var data-language="js">{{ p.name }}</var></td>
<td><code data-language="js">{{ p.type }}</code></td>
<td>{% if p.optional %}✔{% endif %}</td>
<td><samp data-language="js">{{ p.default }}</samp></td>
<td>{{ p.description|raw }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</section>
{% endif %}
{% endfor % #}

</section>
<section id="filters" class="doc">
<h2>Custom Filters</h2>
</section>
{% endblock %}

{% block extendingsubnav %}
Expand All @@ -154,5 +125,6 @@ <h3>{{ typedef.name }}</h3>
<li><a href="#TYPES">Token Types</a></li>
</ol>
</li>
<li><a href="#filters">Custom Filters</a></li>
</ol>
{% endblock %}
12 changes: 3 additions & 9 deletions docs/docs/filters.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,10 @@ <h3>Examples</h3>

{% block filtersubnav %}
<ol>
{% for fn in functions %}
<li>
<a href="#built-in">Built-In Filters</a>
<ol>
{% for fn in functions %}
<li>
<a href="#{{ fn.name }}">{{ fn.name }}</a>
</li>
{% endfor %}
</ol>
<a href="#{{ fn.name }}">{{ fn.name }}</a>
</li>
<li><a href="#custom">Custom Filters</a></li>
{% endfor %}
</ol>
{% endblock %}
2 changes: 1 addition & 1 deletion docs/docs/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
{% block clisubnav %}{% endblock %}
</li>
<li>
<a href="{{ baseurl }}//docs/extending/">Extending Swig</a>
<a href="{{ baseurl }}/docs/extending/">Extending Swig</a>
{% block extendingsubnav %}{% endblock %}
</li>
</ol>
Expand Down

0 comments on commit ec8f4a0

Please sign in to comment.