isaacrivas.com

Magro

Magro is a template engine for python that uses a very lean and easy to learn syntax.

Take for example the following piece of code:

import 'web'
 
html4strict:
    head:
        title: "This is a sample page"
        css('css/style.css')
        js('js/jquery.js')
    body:
        [ posts ]:
            blog_post( $value )
 
def blog_post( entry ):
    div( class='blog-post'):
        h1: entry.title
        [ entry.paragraphs ]:
            p: $value

Will generate something like:

This is a sample page<script type="text/javascript" src="js/jquery.js">// <![CDATA[
 
// ]]></script>

Lorem Ipsum

Lorem ipsum dolor sit amet… Ullamcorper suscipit lobortis…

Magna aliquam

Erat volutpat. Ut wisi enim ad minim veniam… Ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat… Dolore magna aliquam erat volutpat…

* Requires Ply (Python Lex – Yacc.)

Please leave a Reply