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:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | 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:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title> This is a sample page </title> <link rel="stylesheet" type="text/css" href="css/style.css"/> <script type="text/javascript" src="js/jquery.js"> </script> </head> <body> <div class="blog-post"> <h1> Lorem Ipsum </h1> <p> Lorem ipsum dolor sit amet... </p> <p> Ullamcorper suscipit lobortis... </p> </div> <div class="blog-post"> <h1> Magna aliquam </h1> <p> Erat volutpat. Ut wisi enim ad minim veniam... </p> <p> Ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat... </p> <p> Dolore magna aliquam erat volutpat... </p> </div> </body> </html> |
- Download latest version.
- Browse the documentation.
- Collaborate on its development at the github repository.
* Requires Ply (Python Lex – Yacc.)