File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed
Filter options
Expand file tree Collapse file tree 1 file changed +37
-0
lines changed
Original file line number Diff line number Diff line change @@ -473,6 +473,43 @@ you can replace it with a more terse and readable syntax that uses the pattern
473
473
But keep in mind that the full `<span tal:replace="expression">Default Text</span> `
474
474
syntax also allows for default content in the unrendered template.
475
475
476
+ Mako
477
+ ----
478
+ `Mako <http://www.makotemplates.org/ >`_ is a template language that compiles to Python
479
+ for maximum performance. Its syntax and api is borrowed from the best parts of other
480
+ templating languages like Django and Jinja2 templates. It is the default template
481
+ language included with the `Pylons and Pyramid <http://www.pylonsproject.org/ >`_ web
482
+ frameworks.
483
+
484
+ An example template in Mako looks like:
485
+
486
+ .. code-block :: html
487
+
488
+ <%inherit file="base.html"/>
489
+ <%
490
+ rows = [[v for v in range(0,10)] for row in range(0,10)]
491
+ %>
492
+ <table >
493
+ % for row in rows:
494
+ ${makerow(row)}
495
+ % endfor
496
+ </table >
497
+
498
+ <%def name="makerow(row)">
499
+ <tr >
500
+ % for name in row:
501
+ <td >${name}</td >\
502
+ % endfor
503
+ </tr >
504
+ </%def>
505
+
506
+ To render a very basic template, you can do the following:
507
+
508
+ .. code-block :: python
509
+
510
+ from mako.template import Template
511
+ print (Template(" hello ${data} !" ).render(data = " world" ))
512
+
476
513
.. rubric :: References
477
514
478
515
.. [1 ] `The mod_python project is now officially dead <http://blog.dscpl.com.au/2010/06/modpython-project-is-now-officially.html >`_
You can’t perform that action at this time.
0 commit comments