charmhelpers.contrib.templating package

charmhelpers.contrib.templating.contexts module

A helper to create a yaml cache of config with namespaced relation data.

charmhelpers.contrib.templating.contexts.dict_keys_without_hyphens(a_dict)

Return the a new dict with underscores instead of hyphens in keys.

charmhelpers.contrib.templating.contexts.juju_state_to_yaml(yaml_path, namespace_separator=':', allow_hyphens_in_keys=True, mode=None)

Update the juju config and state in a yaml file.

This includes any current relation-get data, and the charm directory.

This function was created for the ansible and saltstack support, as those libraries can use a yaml file to supply context to templates, but it may be useful generally to create and update an on-disk cache of all the config, including previous relation data.

By default, hyphens are allowed in keys as this is supported by yaml, but for tools like ansible, hyphens are not valid [1].

[1] http://www.ansibleworks.com/docs/playbooks_variables.html#what-makes-a-valid-variable-name

charmhelpers.contrib.templating.contexts.update_relations(context, namespace_separator=':')

Update the context with the relation data.

charmhelpers.contrib.templating.pyformat module

Templating using standard Python str.format() method.

charmhelpers.contrib.templating.pyformat.render(template, extra={}, **kwargs)

Return the template rendered using Python’s str.format().