views:

269

answers:

4

Does anyone know of a Python equivalent for FMPP the text file preprocessor?

Follow up: I am reading the docs and looking at the examples for the suggestions given. Just to expand. My usage of FMPP is to read in a data file (csv) and use multiple templates depending on that data to create multi page reports in html all linked to a main index.

A: 

You could give Cheetah a try. I've used it before with some success.

Dana the Sane
+2  A: 

Python has lots of templating engines. It depends on your exact needs.

Jinja2 is a good one, for example. Kid is another.

Eli Bendersky
+1  A: 

Let me add Mako Fine fast tool (and it even uses ${var} syntax).

Note: Mako, Jinja and Cheetah are textual languages (they process and generate text). I'd order them Mako > Jinja > Cheetah (in term of features and readability), but people's preferences vary.

Kid and it's successor Genshi are HTML/XML aware attribute languages (<div py:if="variable"> ... </div> etc ). That's completely different methodology - and tools suitable for HTML or XML only.

Mekk
Thank you for pointing out Mako it seems to have everything I need.
1.01pm
+1  A: 

I'm not sure exactly what FMPP does, but from a quick glance it seems like a template language.

Jinja2 is an excellent template system for python.

sample:

<ul>
    {% for item in list %}
    <li> {{ item.title }} </li>
    {% endfor %}
</ul>

{% if user.is_admin() %}
    <a href="./edit">Edit this page</a>
{% endif %}
hasen j