jp (output/template): check if there is a template before initializing Renderer
This commit is contained in:
parent
2801c01eca
commit
c9c34550df
1 changed files with 5 additions and 4 deletions
|
|
@ -48,18 +48,19 @@ 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)
|
||||
try:
|
||||
template_path = cmd.TEMPLATE
|
||||
except AttributeError:
|
||||
if not 'template' in cmd.args.output_opts:
|
||||
self.host.disp(u'no default template set for this command, '
|
||||
u'you need to specify a template using --oo template=[path/to/template.html',
|
||||
u'you need to specify a template using --oo template=[path/to/template.html]',
|
||||
error=True)
|
||||
self.host.quit(C.EXIT_BAD_ARG)
|
||||
|
||||
options = self.host.parse_output_options()
|
||||
self.host.check_output_options(OPTIONS, options)
|
||||
self.renderer = template.Renderer(self.host)
|
||||
try:
|
||||
template_path = options['template']
|
||||
except KeyError:
|
||||
|
|
|
|||
Loading…
Reference in a new issue