5

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.

1.01pm
  • 841
  • 1
  • 12
  • 23

4 Answers4

3

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
  • 1,441
  • 10
  • 12
2

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

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

Eli Bendersky
  • 263,248
  • 89
  • 350
  • 412
1

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

Dana the Sane
  • 14,762
  • 8
  • 58
  • 80
1

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
  • 161,647
  • 65
  • 194
  • 231