You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
I'm interested in accessing the nunjucks environment to create shortcodes that do custom rendering. One examples is a shortcode that includes a template with a specific context (similar to the Twig include "template.html" with data behavior):
{% includeWith "template.njk", data %}
Another possible application is creating shortcodes that render a nunjucks template to generate output. So, for instance, for an image shortcode you could write the markup as a nunjucks template and import/render that.
Describe the solution you'd like
I'd like to be able to access the nunjucks environment from the this object in shortcode functions, as is already the case with filters. This would allow me to do something like:
I can't directly help but another alternative might be a nunjucks global?
The syntax would then be:
{{includeWith("template.njk", { data: data }) }}
This might be closer to what you're looking for, and has a nice benefit of using {{ rather than {% which feels more 'correct' to me for some thing that's going to render to the page vs an expression.
Is your feature request related to a problem? Please describe.
I'm interested in accessing the nunjucks environment to create shortcodes that do custom rendering. One examples is a shortcode that includes a template with a specific context (similar to the Twig
include "template.html" with data
behavior):Another possible application is creating shortcodes that render a nunjucks template to generate output. So, for instance, for an
image
shortcode you could write the markup as a nunjucks template and import/render that.Describe the solution you'd like
I'd like to be able to access the nunjucks environment from the
this
object in shortcode functions, as is already the case with filters. This would allow me to do something like:Which would allow
Describe alternatives you've considered
This is possible to do as a filter, but I think it makes more sense as a shortcode:
But this to me seems kind of awkward and hacky.
Additional context
No response
The text was updated successfully, but these errors were encountered: