Задать вопрос

Тел: +7 965 3737 888

462

Просмотров

0

Ответов

Wiki-like markup for sub templates

<p>I wanted to have the possibility to use a wiki-like markup style in my flatpages for various purposes (embedding images, quoting, etc.)</p>
<p>After a few dead ends I came up with this, which is quite nice I think.</p>
<blockquote>
<p>It basically takes a named tag, loads the corresponding template, passes in all arguments, renders the template and replaces the named tag with the result.</p>
</blockquote>
<p><em>The markup looks like this:</em></p>
<blockquote>
<p>[[example:value to pass|option1=somevalue option2=values can have spaces too! without having to put them in quotes option3=some other value]]</p>
</blockquote>
<p><em>This results in:</em></p>
<ul><li>Filter tries to load wiki/wiki_example.html</li>
<li>If it is loaded, it passes an WikiElement containing the value and the options to the template, renders it and replaces the tag with the rendered template</li>
</ul><p><em>In the "wiki/wiki_example.html" template you can use it like this:</em></p>
{{param.value}}
{{param.opts.option1}}

<p>Or loop over param.opts.iteritems.</p>

Вопрос полезен? Да0/Нет0
file_3436.py(1.4Кб)
None