Questions tagged [mako]

Mako is a template library written in Python. It provides a familiar, non-XML syntax which compiles into Python modules for maximum performance. Conceptually, Mako is an embedded Python (i.e. Python Server Page) language.

Mako is a template library written in Python. It provides a familiar, non-XML syntax which compiles into Python modules for maximum performance. Mako's syntax and API borrows from the best ideas of many others, including Django templates, Cheetah, Myghty, and Genshi. Conceptually, Mako is an embedded Python (i.e. Python Server Page) language, which refines the familiar ideas of componentized layout and inheritance to produce one of the most straightforward and flexible models available, while also maintaining close ties to Python calling and scoping semantics.

Mako is used by the python.org website as well as reddit.com. It is the default template language included with the Pylons web framework.

422 questions
55
votes
5 answers

What is the fastest template system for Python?

Jinja2 and Mako are both apparently pretty fast. How do these compare to (the less featured but probably good enough for what I'm doing) string.Template ?
Josh Gibson
  • 21,808
  • 28
  • 67
  • 63
51
votes
2 answers

Mako or Jinja2?

I didn't find a good comparison of jinja2 and Mako. What would you use for what tasks ? I personnaly was satisfied by mako (in a pylons web app context) but am curious to know if jinja2 has some nice features/improvements that mako doesn't ? -or…
ychaouche
  • 4,922
  • 2
  • 44
  • 52
44
votes
6 answers

How do you debug Mako templates?

So far I've found it impossible to produce usable tracebacks when Mako templates aren't coded correctly. Is there any way to debug templates besides iterating for every line of code?
Nikhil
  • 5,705
  • 1
  • 32
  • 30
25
votes
2 answers

OpenERP font-family: 'Free 3 of 9' for barcode is not working in report webkit

I have a problem with WebKit report .mako file. when I use: % for o in objects:

${o.name}

Pooja
  • 575
  • 10
  • 28
17
votes
2 answers

Mako templates inline if statement

I have a template variable, c.is_friend, that I would like to use to determine whether or not a class is applied. For example: if c.is_friend is True link if c.is_friend is False link Is there some…
ensnare
  • 40,069
  • 64
  • 158
  • 224
13
votes
3 answers

how to deal with unicode in mako?

I constantly get this error using mako: UnicodeEncodeError: 'ascii' codec can't encode character u'\xe0' in position 6: ordinal not in range(128) I've told mako I'm using unicode in any possible way: mylookup = TemplateLookup( …
Giorgio Gelardi
  • 993
  • 4
  • 13
  • 29
13
votes
1 answer

How to avoid repetitive filter specification in mako %def's?

I find myself repeating the same filter attribute over all the %def's in my mako code: <%def name="mydef1(a,b)" filter="trim"> # something something something ... <%def name="mydef2(b)" filter="trim"> # something something…
zr.
  • 7,528
  • 11
  • 50
  • 84
12
votes
7 answers

Syntax Highlight for Mako in Eclipse or TextMate?

Does anyone know of a syntax highlight for Mako templates for Eclipse or for TextMate? I know that there is a .mako syntax highlighter for the default text editor in Ubuntu.
Claudio Acciaresi
  • 31,951
  • 5
  • 33
  • 43
12
votes
3 answers

how do I specify extended ascii (i.e. range(256)) in the python magic encoding specifier line?

I'm using mako templates to generate specialized config files. Some of these files contain extended ASCII chars (>127), but mako chokes saying that the chars are out of range when I use: ## -*- coding: ascii -*- So I'm wondering if perhaps there's…
gred
  • 612
  • 1
  • 8
  • 15
11
votes
2 answers

Mark string as safe in Mako

I'm using Pylons with Mako templates and I want to avoid typing this all the time: ${ h.some_function_that_outputs_html() | n } I want to somehow mark the function, or a variable as safe (you can do that in Django) so I don't have to pipe-en all…
disc0dancer
  • 9,185
  • 11
  • 36
  • 46
10
votes
5 answers

Insert javascript at top of including file in Jinja 2

In Jinja2, I would like the following to work as it looks like it should, by running: from jinja2 import Environment, FileSystemLoader env = Environment(loader=FileSystemLoader('.')) template = env.get_template('x.html') print…
Brian M. Hunt
  • 81,008
  • 74
  • 230
  • 343
10
votes
1 answer

Is it possible to pass variable arguments to the include tag in Mako?

I have a mako template A that includes mako template B more than once. Mako template B expects certain arguments and I need to set them to different values on include. In A.mak: <%include file="/components/B.mak" …
Sheena
  • 15,590
  • 14
  • 75
  • 113
10
votes
1 answer

Does python mako template support connitue/break in loop context?

Is it possible to use continue/break in a %control structure loop. For example: % for x in range(1): % continue % endfor Thanks,
kerwin
  • 941
  • 2
  • 12
  • 22
9
votes
2 answers

In Pyramid, how can I use a different renderer based on contents of context?

I have 3 different product page layouts that I would like to display dependent on the information available about the products. Using traversal I have a class called ProductFinder that grabs all the information. For example the user goes to…
jchysk
  • 1,538
  • 1
  • 15
  • 27
8
votes
1 answer

Using dictionaries in Mako templates

Instead of passing variables to a template like so: template.render(var1='hello', var2='world') How can I pass a dictionary to the template and have it render in the same manner vars = {'var1': 'hello', 'var2': 'world'} so in the template I can…
Adam Pointer
  • 1,492
  • 8
  • 17
1
2 3
28 29