Skip to content

Commit

Permalink
Merge pull request #98 from minrk/finish-71
Browse files Browse the repository at this point in the history
Make 'element' available for JS output to add to document

closes #71
  • Loading branch information
minrk committed Sep 13, 2015
2 parents f45c011 + 5b3f6ba commit e111266
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions nbconvert/exporters/templateexporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

# Stdlib imports
import os
import uuid

# other libs/dependencies are imported at runtime
# to move ImportErrors to runtime when the requirement is actually needed
Expand Down Expand Up @@ -293,6 +294,8 @@ def _create_environment(self):
extensions=JINJA_EXTENSIONS
)

environment.globals['uuid4'] = uuid.uuid4

# Add default filters to the Jinja2 environment
for key, value in self.default_filters():
self._register_filter(environment, key, value)
Expand Down
3 changes: 3 additions & 0 deletions nbconvert/templates/html/basic.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,11 @@ height={{output.metadata['image/jpeg']['height']}}
{%- endblock -%}
{%- block data_javascript scoped %}
{% set div_id = uuid4() %}
<div id="{{ div_id }}"></div>
<div class="output_subarea output_javascript {{extra_class}}">
<script type="text/javascript">
var element = $('#{{ div_id }}');
{{ output.data['application/javascript'] }}
</script>
</div>
Expand Down

0 comments on commit e111266

Please sign in to comment.