Popular recipes tagged "template"http://code.activestate.com/recipes/tags/template/2013-06-21T14:47:21-07:00ActiveState Code RecipesEasy to use, easy to read, python based HTML generation (Python)
2013-06-21T14:47:21-07:00Pavloshttp://code.activestate.com/recipes/users/4185038/http://code.activestate.com/recipes/578436-easy-to-use-easy-to-read-python-based-html-generat/
<p style="color: grey">
Python
recipe 578436
by <a href="/recipes/users/4185038/">Pavlos</a>
(<a href="/recipes/tags/html/">html</a>, <a href="/recipes/tags/template/">template</a>, <a href="/recipes/tags/text/">text</a>).
Revision 4.
</p>
<p>I was looking for a simple way to generate HTML directly in python that does not require learning a new template 'language' nor requires the installation of a big complex package. Closest thing I found was James Casbon's attempt(https://gist.github.com/1461441). This is my version of the same idea. </p>
<p>(2013-04-21) added some simplifications and support for switching off string interpolation. Added to github:</p>
<p><a href="https://github.com/pavlos-christoforou/web" rel="nofollow">https://github.com/pavlos-christoforou/web</a></p>
Python Template Engine (Python)
2012-03-31T21:28:12-07:00Sunjay Varmahttp://code.activestate.com/recipes/users/4174115/http://code.activestate.com/recipes/578090-python-template-engine/
<p style="color: grey">
Python
recipe 578090
by <a href="/recipes/users/4174115/">Sunjay Varma</a>
(<a href="/recipes/tags/attributes/">attributes</a>, <a href="/recipes/tags/engine/">engine</a>, <a href="/recipes/tags/filter/">filter</a>, <a href="/recipes/tags/macro/">macro</a>, <a href="/recipes/tags/template/">template</a>).
</p>
<p>This is a simple template engine which allows you to replace macros within text. This engine allows for attributes and filters. The default implementation provides the entire string module as filters. Trying to use arguments will of course not work (since the framework supports no other arguments for the filter other than the filtered string itself).</p>
A Template for Crash-Resistant Toggle-Macros (JavaScript)
2010-10-07T00:51:42-07:00Eric Promislowhttp://code.activestate.com/recipes/users/4166930/http://code.activestate.com/recipes/577418-a-template-for-crash-resistant-toggle-macros/
<p style="color: grey">
JavaScript
recipe 577418
by <a href="/recipes/users/4166930/">Eric Promislow</a>
(<a href="/recipes/tags/komodo/">komodo</a>, <a href="/recipes/tags/macro/">macro</a>, <a href="/recipes/tags/snippet/">snippet</a>, <a href="/recipes/tags/template/">template</a>).
</p>
<p>If you've followed my postings here lately (<a href="http://code.activestate.com/recipes/users/4166930/" rel="nofollow">http://code.activestate.com/recipes/users/4166930/</a>), you'll see that I've been playing with what I call "toggle macros", macros that toggle a state on and off, with different behaviors for each state. Unfortunately I found that it was easy to get Komodo to crash on shutdown. Meanwhile I wanted to build a framework to make it easier to build these.</p>
<p>This recipe accomplishes both. It looks like putting a listener on a view object can trigger this crash, but so can storing a method on a view object, even with a unique name.
So while I wanted to use the "view.view_closing" event, I can't, and I notice no other core Komodo code is. The template instead uses a global hash, ko.extensions.togglers,
to store the code objects. And now I'm not getting a crash.</p>
Cheetah template processor for CSV and XML data (Python)
2010-05-21T10:00:14-07:00Raphaël Jolivethttp://code.activestate.com/recipes/users/4135673/http://code.activestate.com/recipes/577234-cheetah-template-processor-for-csv-and-xml-data/
<p style="color: grey">
Python
recipe 577234
by <a href="/recipes/users/4135673/">Raphaël Jolivet</a>
(<a href="/recipes/tags/cheetah/">cheetah</a>, <a href="/recipes/tags/csv/">csv</a>, <a href="/recipes/tags/merge/">merge</a>, <a href="/recipes/tags/populate/">populate</a>, <a href="/recipes/tags/template/">template</a>, <a href="/recipes/tags/xml/">xml</a>).
</p>
<p>This script allows to populate Cheetah text templates (<a href="http://www.cheetahtemplate.org/" rel="nofollow">http://www.cheetahtemplate.org/</a>) with XML or CSV input data.</p>
<p>This is useful in my day2day work, where I often need to quickly generate bunch of files based on a templates and data.</p>
<p>Cheetah template are very easy to write and understand, and I find it easy to use with CSV or XML data.</p>
Userfriendly Webpage Template (Python)
2010-05-04T07:38:03-07:00david.gaarenstroomhttp://code.activestate.com/recipes/users/4168848/http://code.activestate.com/recipes/577203-userfriendly-webpage-template/
<p style="color: grey">
Python
recipe 577203
by <a href="/recipes/users/4168848/">david.gaarenstroom</a>
(<a href="/recipes/tags/cgi/">cgi</a>, <a href="/recipes/tags/html/">html</a>, <a href="/recipes/tags/httpserver/">httpserver</a>, <a href="/recipes/tags/mvc/">mvc</a>, <a href="/recipes/tags/template/">template</a>, <a href="/recipes/tags/web/">web</a>, <a href="/recipes/tags/webdesign/">webdesign</a>, <a href="/recipes/tags/webpagetemplate/">webpagetemplate</a>).
Revision 5.
</p>
<p>User friendly template class targeted towards Web-page usage and optimized for speed and efficiency.</p>
<p>Tags can be inserted in a template HTML file in a non-intrusive way, by using specially formatted comment strings. Therefore, the template-file can be viewed in a browser, even with prototype data embedded in it, which will later be replaced by dynamic content.
Also, webdesigners can continue to work on the template and upload it without further
modification.</p>
Basic class code generator (Python)
2010-03-22T10:58:19-07:00Mateyuzohttp://code.activestate.com/recipes/users/4172453/http://code.activestate.com/recipes/577130-basic-class-code-generator/
<p style="color: grey">
Python
recipe 577130
by <a href="/recipes/users/4172453/">Mateyuzo</a>
(<a href="/recipes/tags/generator/">generator</a>, <a href="/recipes/tags/prototyping/">prototyping</a>, <a href="/recipes/tags/template/">template</a>).
Revision 5.
</p>
<p>This little script takes a yaml file as a class definition and generates code stubs and unit tests.</p>
Templite+ (Python)
2009-02-28T04:44:46-08:00Thimo Kraemerhttp://code.activestate.com/recipes/users/4169283/http://code.activestate.com/recipes/576663-templite/
<p style="color: grey">
Python
recipe 576663
by <a href="/recipes/users/4169283/">Thimo Kraemer</a>
(<a href="/recipes/tags/template/">template</a>, <a href="/recipes/tags/templating/">templating</a>, <a href="/recipes/tags/text/">text</a>).
Revision 13.
</p>
<p>Revised version of <a href="http://code.activestate.com/recipes/496702/">Templite</a>, a light-weight, fully functional, general purpose templating engine</p>