Export device to JS to allow pyqt to retrieve the information

This commit is contained in:
Julien Duponchelle 2015-07-16 15:57:25 +02:00
parent 3ef5cf875c
commit 21d28e2944
2 changed files with 2 additions and 1 deletions

View File

@ -46,6 +46,7 @@ def render(template_file, out, **kwargs):
log.info('Build %s', out)
env = Environment(loader=FileSystemLoader('templates'))
env.filters['jsonify'] = json.dumps
env.filters['escape_quote'] = lambda x: x.replace('"','\\"')
template = env.get_template(template_file)
template.stream(**kwargs).dump(os.path.join('build', out))

View File

@ -13,7 +13,7 @@
<h3>{{image["filename"]}}</h3>
Version: {{image["version"]}}<br />
Checksum: {{image["md5sum"]}}<br />
<button class="btn btn-primary btn-lg" type="button" onclick='gns3.install({{device|jsonify}}, "{{image["md5sum"]}}")'>Install</button>
<button class="btn btn-primary btn-lg" type="button" onclick='gns3.install("{{device|jsonify|escape_quote}}", "{{image["md5sum"]}}")'>Install</button>
{% endfor %}
</ul>
{% endfor %}