Template-based shortcodes do not work
jamadden opened this issue · 1 comments
Template-based shortcodes fail with this plugin as the renderer.
Given a file in a site at shortcodes/foo.tmpl
containing arbitrary ReST, when that shortcode is invoked, Nikola will call render_template_to_string
passing the contents of foo.tmpl
as the template
argument. We expect the template argument to be the name of the template, which we typically derive from a filename, so we fail with a ComponentLookupError when we try to locate the template adapter.
One quick option would be to catch that error, example the template string, and if it doesn't look like a filename (e.g., contains at least on ReST directive ..
) return that string directly. That fixes the common case of using a template shortcode as a primitive "include" directive.
Alternately, we could try to examine all the files in the site's shortcodes
directory and register them as page templates like everything else.
Right, I was thinking about this all wrong. I wanted to be able to use shortcodes to produce additional ReST that got expanded into the document, but they are expected to produce HTML that's output as-is. They might still be useful, but not for the trivial case I was thinking of.