1

I would like to process templates which do not use '.' as a special character, so that parameter names like foo.bar are valid. For my purposes a parameter name like that should mean that the parameter named 'foo.bar' will be substituted into the template, and not, for example, that before substitution attribute bar will be looked up on the object referenced by parameter foo.

This is for a documentation application.

What is an appropriate Python library to do that?

Essential:

  • Ability to treat . as non-special in template parameter names -- because there is a flat key/value set of parameters to be substituted, whose names contain that character
  • Precise and convenient control over whitespace -- because may be generating e.g. markdown or ReST files
  • Ability to substitute some string for missing parameters rather than erroring or halting generation of output (the empty string would be OK, bonus points for customizable string) -- because the documentation authoring tool I am writing will make these missing parameters obvious, but an error would hinder the process of documentation writing
  • Good template error reporting (syntax errors and runtime errors)

Other useful features / qualities in approximate order of importance:

  • Robust / polished
  • {{}} syntax -- because we use this syntax in our codebase already
  • Good support for escaping
  • Relatively simple
  • Fast
  • Unicode support

Unimportant:

  • Sandboxing
  • Template inheritance

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.