jp (output/template): initialize template rendered only if a rendering is actually needed

This commit is contained in:
Goffi 2017-05-21 15:52:23 +02:00
commit 40e764cab5

View file

@ -37,7 +37,6 @@ class Template(object):
def __init__(self, jp):
self.host = jp
jp.register_output(C.OUTPUT_COMPLEX, TEMPLATE, self.render)
self.renderer = template.Renderer(jp)
def render(self, data):
"""render output data using requested template
@ -49,6 +48,7 @@ class Template(object):
command's template_data_mapping attribute will be used if it exists to convert
data to a dict usable by the template.
"""
self.renderer = template.Renderer(self.host)
cmd = self.host.command
options = self.host.parse_output_options()
self.host.check_output_options(OPTIONS, options)