Why using mako templates?

462 views
Skip to first unread message

Claude Coulombe

unread,
May 1, 2014, 4:45:40 PM5/1/14
to edx-...@googlegroups.com
Greetings,

What are the motivation and advantages behind using Mako templates instead of regular Djangos templating engine?

Thanks

Claude Coulombe

Ned Batchelder

unread,
May 2, 2014, 7:23:30 AM5/2/14
to edx-...@googlegroups.com
The primary difference between Mako and Django is that Mako lets you use full Python syntax in your templates: you can define functions, use full expressions, and so on.  Some people view this as an advantage, some view it as a disadvantage.

--Ned.

David Ormsbee

unread,
May 2, 2014, 9:39:00 AM5/2/14
to edx-...@googlegroups.com
FWIW, I'm pretty sure that if we had it to do over again, we'd be using Django templates. Switching the templates over is something that's been contemplated in the past but that nobody really has time for right now.

Dave

Sébastien Hinderer

unread,
May 12, 2014, 9:20:06 AM5/12/14
to edx-...@googlegroups.com
Dear all,

David Ormsbee (2014/05/02 09:39 -0400):
> FWIW, I'm pretty sure that if we had it to do over again, we'd be using
> Django templates. Switching the templates over is something that's been
> contemplated in the past but that nobody really has time for right
> now.

But assuming someone would have time, is it at least clear howthat could
be achieved and which steps would be need to reach this?

Sébastien.

Ned Batchelder

unread,
May 12, 2014, 3:19:09 PM5/12/14
to edx-...@googlegroups.com
No, it isn't yet clear how we would get from a Mako/Django codebase to a pure Django codebase.  Mako templates allow nearly all of Python in the template, so converting a Mako template to a Django template can be a significant refactoring, not a simple matter of syntax conversion.

--Ned.

Sébastien Hinderer

unread,
May 13, 2014, 2:55:17 AM5/13/14
to edx-...@googlegroups.com
Ned Batchelder (2014/05/12 15:19 -0400):
> No, it isn't yet clear how we would get from a Mako/Django codebase to a
> pure Django codebase. Mako templates allow nearly all of Python in the
> template, so converting a Mako template to a Django template can be a
> significant refactoring, not a simple matter of syntax conversion.

For sure. I guess one possible starting point would be to just do it for
one template and see what happens? Can somebody see one potential
candidate for such an experiment?

Sébastien.

Ray Hooker

unread,
May 13, 2014, 3:45:56 PM5/13/14
to edx-...@googlegroups.com
BTW I just posted a question on responsive UI that ties into this issue.

Ray
--
Ray Hooker

Yarko Tymciurak

unread,
May 13, 2014, 4:05:14 PM5/13/14
to edx-...@googlegroups.com
The nuances of various templating engines are just that...

If you look at stock django templates, or what some people prefer - jinja2 templates (which is what's used in ansible), or mako templates, or even mustache - once a platform decision is made, it begs the question:   why would one propose the pain of change?

Sure, having "standard"  django templates would make less documentation, and make it easier for people who are in a steep learning curve already with all that there is to grasp w/ edx;

Sure, having jinja2 templates would offer benefits over django-templates which have been discussed at length outside of edx, and then it would be consistent w/ ansible (again - a potential w/ a little less of a learning curve, but ... not really);

Sure, mako templates make it easier since they are closer to python, and might make it easier to customize particular course experience at the page level without affecting django logic;

In any case, the decision was made.  The effort to change would be non-trivial.   The discussion for _why_ would you want to change (at least in a transparent way) hasn't been.

So, once you understand and know how to fully use two or more templating engines, what are the benefits you would see in making a change?

Curious,
- Yarko

Reply all
Reply to author
Forward
0 new messages