On Sat, Dec 17, 2011 at 5:28 AM, Joshua Partogi
<[email protected]> wrote:
> Hi there,
>
> I am left undecided whether to use mako or chameleon. From what I have
> observed, it seems that chameleon is the default template language in
> pyramid (CMIIW). Is there any case where chameleon is more preferred
> when using pyramid? I actually like mako but I am afraid there are
> some mako functionality that is not supported in pyramid.
The reason Chameleon seems first is that Pyramid's codebase is a
direct descendant of BFG, which had Chameleon. The Pylons-like parts
were added later, and the tutorial authors happened to be Chameleon
users. Mako was added to Pyramid with the intention that people would
use it, and that they *should* use it if they're more comfortable with
it.
All of Mako is supported in Pyramid. Overall I'd say Mako has more
features than Chameleon and is more flexible. However, one advantage
of Chameleon is that, because it's an XML-based language, the template
is guaranteed to be well-formed if the rendering doesn't raise an
exception. (That doesn't necessarily mean the output will be
well-formed, if your variables contain unbalanced tags and you output
them as literals rather than the default of escaping them.) Also, it
looks Pyramid supports internationalization better with Chameleon
(more documentation, more built-in support). That doesn't mean you
can't do internationalization with Mako, it just means you'd have to
do more of the structural work yourself. (Are there any tutorials on
this?)
One feature that may not be obvious if you're not using the Akhet
scaffold, is that you can define Mako options in the INI file
("mako.directories = line1 line2") or at the beginning of your main
function (``settings["mako.directories"] = [...]``).
I also have used Mako a lot, and have been trying out Chameleon to see
if I might want to use it. My impression is that Chameleon's syntax is
very different, and it takes time to map your Mako idioms to Chameleon
equivalents. So it's only worth doing if you have time to do it
slowly, or if your first Chameleon application requires only simple
templates.
Longer term, Chris has been talking about removing both Chameleon and
Mako from the Pyramid core, making them add-on packages
(pyramid_chameleon and pyramid_mako). They would then be application
dependencies like SQLAlchemy, rather than Pyramid core dependencies.
--
Mike Orr <[email protected]>
--
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/pylons-discuss?hl=en.