hieroglyph icon indicating copy to clipboard operation
hieroglyph copied to clipboard

Theme creation, unclear what is accessible when defining slide.html

Open jodygarnett opened this issue 7 years ago • 1 comments

Hesitant to report but since I have been stuck for a week on the some issue figured it was worth talking about. My goal is to define breadcrumbs or an "up" arrow for longer form content generated with auto slides.

The documentation indicates:

When creating links in layout.html (and other templates), it’s important to use the pathto function. The pathto function will ensure the link is generated with the correct path when the presentation is built.

Defining a custom slides theme, literally starting by extending slides:

[theme]
inherit = slides
stylesheet = my_slides.css

[options]
custom_css =
custom_js =

And then copying the original slides.html into my new theme.

parents

I note layout.html has defined up but I do not seem to be able to access it from slides.html:

    {%- if parents %}
    <link rel="up" title="{{ parents[-1].title|striptags|e }}" href="{{ parents[-1].link|e }}" />
    {%- endif %}

Trying to do the same thing myself in slide.html:

{%- if parents %}
<div class="slide-header">
  <a href="{{ parents[-1].link|e }}">{{ parents[-1].title|striptags|e }}</a>
</div>
{%- endif %}

Results in:

     [exec] Exception occurred:
     [exec]   File "/usr/local/lib/python3.7/site-packages/jinja2/sandbox.py", line 338, in is_safe_callable
     [exec]     return not (getattr(obj, 'unsafe_callable', False) or
     [exec] jinja2.exceptions.UndefinedError: 'pathto' is undefined

path to index

Next attempt is to see if I can get any link from slide.html:

  <a href="{{ pathto('index') }}">top</a>

Results in pathto not being available:

     [exec] Exception occurred:
     [exec]   File "/usr/local/lib/python3.7/site-packages/jinja2/sandbox.py", line 338, in is_safe_callable
     [exec]     return not (getattr(obj, 'unsafe_callable', False) or
     [exec] jinja2.exceptions.UndefinedError: 'pathto' is undefined

jodygarnett avatar Nov 27 '18 17:11 jodygarnett

Okay this really appears a gap in understanding on my part. From a copy of layout.html the following works:

  <a href="{{ pathto('index') }}">{{ docstitle|e }}</a>

Moving the same snippet to slide.html does not work.

jodygarnett avatar Nov 27 '18 18:11 jodygarnett