ncs.template Module
This module implements classes to simplify template processing.
Classes
class Template
Class to simplify applying of templates in a NCS service callback.
Template(service, path=None)
Initialize a Template object.
The 'service' argument is the 'service' variable received in decorated cb_create method in a service class. ('service' can in fact be any maagic.Node (except a Root node) instance with an underlying Transaction). It is also possible to provide a maapi.Transaction instance for the 'service' argument in which case 'path' must also be provided.
Example use:
vars = ncs.template.Variables()
vars.add('VAR1', 'foo')
vars.add('VAR2', 'bar')
vars.add('VAR3', 42)
template = ncs.template.Template(service)
template.apply('my-service-template', vars)
Members:
class Variables
Class to simplify passing of variables when applying a template.
Variables(init=None)
Initialize a Variables object.
The optional argument 'init' can be any iterable yielding a 2-tuple in the form (name, value).
Members:
Last updated
Was this helpful?