Render plugin does not always render shortcodes/filters and does not evaluate Global Data (1.0.0-beta.8)
stevenmilstein opened this issue · comments
Describe the bug
According to the Render documentation:
Everything you’ve added to project’s configuration file will also be available in these renders too: shortcodes, filters, etc.
However, the Render plugin does not always render shortcodes/filters and does not evaluate Global Data.
Feature | Shortcodes/Filter Evaluates | Shortcodes/Filter Renders | Global Data Evaluates | Global Data Renders |
---|---|---|---|---|
njk |
True | True | True | False |
renderTemplate |
True | False | False | False |
renderFile |
True | True | False | False |
To Reproduce
Steps to reproduce the behavior:
- Add to
.eleventy.js
:
eleventyConfig.addShortcode("now", () => {
return new Date();
});
eleventyConfig.addFilter("nowLocale", (locale) => {
return new Date().toLocaleDateString(locale);
});
- Create
_data/globalString.js
module.exports = "I am Global Data";
- Create
_data/globalStringShortcode.js
module.exports = "It is now {% now %}";
- Create file
renderFile.md
#### I am an h3 title
1. I am a numbered list
1. shortcode now: {% now %}
1. filter nowLocale: {{ "en-US" | nowLocale }}
1. ./src/\_data/globalString.js globalString: {{ globalString }} <mark>Does not evaluate nor render</mark>
1. ./src/\_data/globalStringShortcode.js globalStringShortcode: {{ globalStringShortcode }}
- Create file:
renderTest.njk
<h1>Render Test</h1>
<h2>njk</h2>
<h3>I am an h3 title</h3>
<ol>
<li>I am a numbered list</li>
<li>shortcode now: {% now %} </li>
<li>filter nowLocale: {{ "en-US" | nowLocale }} </li>
<li>./src/_data/globalString.js globalString: {{ globalString }} </li>
<li>./src/_data/globalStringShortcode.js globalStringShortcode: {{ globalStringShortcode }} </li>
</ol>
<h2>renderTemplate</h2>
{% renderTemplate "md" %}
#### I am an h3 title
1. I am a numbered list
1. shortcode now: {% now %} <mark>Does not render</mark>
1. filter nowLocale: {{ "en-US" | nowLocale }} <mark>Does not render</mark>
1. ./src/\_data/globalString.js globalString: {{ globalString }} <mark>Does not evaluate nor render</mark>
1. ./src/_data/globalStringShortcode.js globalStringShortcode: {{ globalStringShortcode }}
{% endrenderTemplate %}
<h2>renderFile</h2>
{% renderFile "renderFile.md" %}
Expected behavior
See highlighted text "Does not ..." for which examples do not evaluate and/or render the shortcodes/filters.
Screenshots
Here's the rendered page:
Environment:
- Mac OS 10.13.6
- Eleventy Version 1.0.0-beta.8
Additional context
The Global Data not rendering may be related to #2069.
I’ve run into this while trying to render my excerpt from markdown which contains shortcodes.
I’m using:
await this.renderTemplate(data.page.excerpt, "md");
However, none of the shortcodes registered in the parent config are rendered.
Bump on this. Running into the same issue with shortcodes not rendering in excerpts.
From what I've read, it seems like this is how the render plugin should work. If not, there needs to be a way to render shortcodes in excerpts.