views:

547

answers:

7

What are some good templating engines for web designers? I definitely have my preferences as to what I'd prefer to work with as a programmer. But web designers seem to have a different way of thinking about things and thus may prefer a different system.

So:

  • Web designers: what templating engine do you prefer to work with?
  • programmers: what templating engines have you worked with that made working with web designers easy?
+2  A: 

I personally found Cheetah templates to be very designer-friendly. What needed some time was the idea of templates subclassing, and this was something hard to get at the beginning. But a designer creates a full template, duplicating his code... Then you can go clean things up a bit.

kender
+4  A: 

Django's templating engine is quite decent. It's pretty robust while not stepping on too many toes. If you're working with Python I would recommend it. I don't know how to divorce it from Django, but I doubt it would be very difficult seeing as Django is quite modular.

EDIT: Apparently the mini-guide to using Django's templating engine standalone was sitting in front of me already, thanks insin.

akdom
http://docs.djangoproject.com/en/dev/ref/templates/api/#configuring-the-template-system-in-standalone-mode
insin
+3  A: 

Look at Mako.

Here's how I cope with web designers.

  1. Ask them to mock up the page. In HTML.
  2. Use the HTML as the basis for the template, replacing the mocked-up content with ${...} replacements.
  3. Fold in loops to handle repeats.

The use of if-statements requires negotiation, since the mock-up is one version of the page, and there are usually some explanations for conditional presentation of some material.

S.Lott
+3  A: 

I had good votes when answering this same question's duplicate.

My answer was:

Jinja2.

Nice syntax, good customization possibilities.

Integrates well. Can be sandboxed, so you don't have to trust completely your template authors. (Mako can't).

It is also pretty fast, with the bonus of compiling your template to bytecode and cache it, as in the demonstration below:

>>> import jinja2
>>> print jinja2.Environment().compile('{% for row in data %}{{ row.name | upper }}{% endfor %}', raw=True) 
from __future__ import division
from jinja2.runtime import LoopContext, Context, TemplateReference, Macro, Markup, TemplateRuntimeError, missing, concat, escape, markup_join, unicode_join
name = None

def root(context, environment=environment):
    l_data = context.resolve('data')
    t_1 = environment.filters['upper']
    if 0: yield None
    for l_row in l_data:
        if 0: yield None
        yield unicode(t_1(environment.getattr(l_row, 'name')))

blocks = {}
debug_info = '1=9'

This code has been generated on the fly by Jinja2. Of course the compiler optmizes it further (e.g. removing if 0: yield None)

nosklo
This isn't a dupe. I asked what is a good engine for dealing with web designers, not what's the best one period. :)
Jason Baker
+1  A: 

Mi vote goes to Clearsilver, it is the template engine used in Trac before 0.11, it's also used in pages like Google Groups or Orkut. The main benefits of this template engine is that it's very fast and language-independent.

Jaime Soriano
+2  A: 

To add to @Jaime Soriano's comment, Genshi is the template engine used in Trac post- 0.11. It's can be used as a generic templating solution, but has a focus on HTML/XHTML. It has automatic escaping for reducing XSS vulnerabilities.

technomalogical
+1  A: 

I've played both roles and at heart I prefer more of a programmer's templating language. However, I freelance for a few graphic designers doing the "heavy lifting" backed and db programming and can tell you that I've had the best luck with XML templating languages (SimpleTAL, Genshi, etc).

When I'm trying to be web designer friendly I look for something that can be loaded into Dreamweaver and see results. This allows me to provide all the hooks in a template and let the designer tweak it without worrying about breaking what I've already written. It allows us to share the code and work better together where we're both comfortable with the format.

If the designer codes without a WYSIWYG editor, I think you're options are less limited and you could go with your own personal favorite.

chauncey