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
2
votes
2 answers

How can python return the filename currently being processed under Windows

I am new to python, and just want to make a simple change. We are generating a template file via mako under Windows 7 and I want to change the comments at the start of the output file…
Noah
  • 15,080
  • 13
  • 104
  • 148
2
votes
1 answer

Custom C preprocessor format in Emacs cc-mode

I'm generating a C source file from a Mako template. Mako templates have directives similar to C preprocessor directives, except that they start with % instead of #. For example: %if some_condition: /* Condition is true */ %else: /* Condition…
Jmb
  • 18,893
  • 2
  • 28
  • 55
2
votes
3 answers

Is there a possible way to assign the src of images inside a Mako template by using POST variables?

I'm currently stuck on this issue and I can't seem to figure it out... I've created a small webapp using CherryPy and I've used Mako for the html templates. Everything is tied to a MySQL database which contains a car list pretty much. My issue is…
2
votes
0 answers

How to step into mako template rendering

I'm using python's mako.template module to render certain .tmpl files to have parametrized code injection, but I would like to be able to step in to the rendering process to see how my parametrized variables are evaluating. SO basically watching how…
gisil
  • 71
  • 1
  • 4
2
votes
0 answers

How to use Nikola tag variables out side of tag page

I'm working on a Nikola site and want to display tags in a template other than the Tags template. I'm wondering if there is a way without add-ons to get access to the list of tags in the items variable. ## -*- coding: utf-8 -*- <%namespace…
9716278
  • 2,044
  • 2
  • 14
  • 30
2
votes
1 answer

Avoid extra newlines after Mako blocks/tags

I have a Mako template with some blocks in it like this: <%page /> % for x in ["one", "two", "three"]: <% y = ''.join(reversed(x)) %> ${x} backwards is ${y} % endfor When I render this template I get something with a lot of extra blank…
augurar
  • 12,081
  • 6
  • 50
  • 65
2
votes
1 answer

How can I get a Django Template to render itself within a Mako Template?

We made the decision quite awhile ago to use Mako Templates in our Django project. We're also supporting Django Templates, since a lot of reusable apps (obviously) assume that Django Templating is available. I've found it possible to render Django…
Josh Smeaton
  • 47,939
  • 24
  • 129
  • 164
2
votes
1 answer

VS Code - using HTML extensions in another language

is there any option to work in mako templates (based on HTML it is something like Flask but very old) and use all extensions from HTML? I installed mako templates extension but that is just for a syntax highlighting. I used to work in Atom and…
2
votes
2 answers

Using Mako with Pyramid causes an error

When trying to use Mako with the Pyramid framework, by going into the development.ini file, and adding the line mako.directories = TestProject:templates in: [app:TestProject] and then creating a simple html file called template.mako in the…
sidewinder
  • 3,013
  • 6
  • 24
  • 33
2
votes
2 answers

Pylons mako templates: debugging "Internal Server Error" / "NoneType" errors

I frequently encounter this error in Mako templates using Pylons 0.9.7: AttributeError: 'NoneType' object has no attribute 'decode' Usually I've entered a variable name that doesn't exist, tried to use a linbebreak within a code line, or some other…
mrjf
  • 1,117
  • 1
  • 12
  • 22
2
votes
1 answer

Where to put Mako filters

I have written a Mako filter that adds HTML linebreaks: <%! def makelinebreaks(text): return text.replace("\r", "
") %> It works if I put it in the template file. But if I want to use it in several templates then I must redeclare…
Niklas Rosencrantz
  • 25,640
  • 75
  • 229
  • 424
2
votes
1 answer

Django integration with Mako Jinja2 template comparison using : render_to_response. Problem?

I am using Django to build up my web project. As known that mako and Jinja2 template are faster that the one Django's given, I start finding way to integrate mako and Jinja2 into Django with using the Django's way of render_to_response method. After…
chow
  • 33
  • 5
2
votes
1 answer

How to set id tag equal to URL name in django

I am trying to set dynamic id attribute to the tag in the HTML. Something like this -
Nishant Dixit
  • 543
  • 1
  • 4
  • 12
2
votes
1 answer

Mako Template 0.8 how to include file where the value is a variable?

I'm trying to do something like this - I have a function that needs to include another template - but dynamically from a variable and I can't seems to do it # include template A add_tmpl("a.html") # include template B add_tmpl("b.html") <%def…
Ricky Levi
  • 7,298
  • 1
  • 57
  • 65
2
votes
2 answers

Trying to use Mako template in python to render json data

I'm not understanding the documentation on using Mako templates in python. I have a python file and I have the following code: import json, requests, urllib2 from mako.template import Template from mako.lookup import TemplateLookup from…
Luisito
  • 895
  • 1
  • 7
  • 9