Thanks. That all sounds quite complex, particularly for something that in all honesty I don't expect to need that often. I'll have a think about whether I want to go any further down this rabbit hole :-)
I appreciate the help. Paul On Sunday, 16 April 2023 at 22:13:42 UTC+1 [email protected] wrote: > On Sun, 16 Apr 2023 at 21:55, Paul Moore <[email protected]> wrote: > > To use BODY_END (or EXTRA_HEAD) I'd need to write a plugin in Python, > wouldn't I? Or can I set that in a template shortcode as well? Although I'm > getting the impression that doing this *without* a plugin may be more > difficult than it's worth... > > You can’t do that from a template shortcode. > > > Alternatively, is there a way to say "if the page/post has a particular > value in its metadata, add the following to the page HTML somewhere (header > or body end seem like reasonable options)"? Basically, I'm thinking of a > custom equivalent to the `has_math` metadata value. > > You could try doing the same thing math_helper.tmpl does in your > site’s theme/templates (the math_scripts_ifpost(s) functions are > called from other templates where math might be needed). has_math is > an attribute on post objects; your custom meta field won’t be, but you > can still access the metadata dictionary with > post.meta['lang'].get("has_fancy_js_library"). You could also expose a > custom Python function in GLOBAL_CONTEXT to make this easier (this > might be necessary if you’re using Jinja2, which doesn’t allow > arbitrary Python in templates.) > > -- > Chris Warrick <https://chriswarrick.com/> > PGP: 5EAAEA16 > -- You received this message because you are subscribed to the Google Groups "nikola-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/nikola-discuss/ed9bfa4e-9dee-448d-9ab2-e8d2ea295598n%40googlegroups.com.
