Using context variables in .mako files with Python code

130 views
Skip to first unread message

Abhishek Gupta

unread,
Oct 15, 2015, 3:01:57 PM10/15/15
to Mako Templates for Python
I currently have a context variable in a .mako file that represents a file name.
I want to break up the file name into two parts: the title and the extension. I want to do this to apply different html/css to the extension part.

Is there a way to do this in the .mako file using Python blocks because I couldn't figure it out? If not, what could I possibly do as a workaround?

Jonathan Vanasco

unread,
Oct 15, 2015, 4:31:46 PM10/15/15
to Mako Templates for Python
Mako has raw Python blocks:


Mako also has Defs:


You should be able to use one, or both, of those to achieve whatever you want.
Reply all
Reply to author
Forward
0 new messages