-
-
Notifications
You must be signed in to change notification settings - Fork 557
Closed
Labels
bug: has-workaroundHas an okay workaround to the issue for nowHas an okay workaround to the issue for nowconverted-to-discussionenhancementfeature: 🪢 render pluginThe Render pluginThe Render plugin
Description
Is your feature request related to a problem? Please describe.
I want to pull in files dynamically, associating markdown descriptions of taxonomies and other things like so:
{%- set desc = "./_meta/tags/" + tag + ".md" -%}
<div>{% renderFile desc %}</div>
In this scenario, though, if the tag does not exist eleventy will fail to build.
Describe the solution you'd like
It seems potentially useful to be able to opt not to fail if the file is not there today. Probably best would be an additional shortcode that has a try/catch in it:
{% renderFileIfExists desc %}
Nunjucks as an option in include: {% include "missing.html" ignore missing %}
Describe alternatives you've considered
A simple way to check the existence of the file in another variable or maybe more helpfully overall adding a custom
{% try %} block to supported templating languages then I could instead do
{% try %} <div>{% renderFile desc %}</div> {% endtry %}
Additional context
No response
Metadata
Metadata
Assignees
Labels
bug: has-workaroundHas an okay workaround to the issue for nowHas an okay workaround to the issue for nowconverted-to-discussionenhancementfeature: 🪢 render pluginThe Render pluginThe Render plugin