The Naked Toolshed Ink Templating Module

Documentation is now available for the Ink text templating system.

Ink is a flexible text templating system that allows you to specify the opening and closing delimiters for your replacement tags. A Python dictionary is used as the key for text replacements. Here’s an example of the Ink Template and Renderer classes in action (with the default delimiters):

from Naked.toolshed.ink import Template, Renderer

template_string = "I like {{food}} and {{drink}}"
template = Template(template_string)
template_key = {'food': 'fries', 'drink': 'beer'}
renderer = Renderer(template, template_key)
rendered_text = renderer.render()
print(rendered_text)         # prints "I like fries and beer"

More details (and examples) are available in the documentation.

Advertisements