eleventy icon indicating copy to clipboard operation
eleventy copied to clipboard

Render plugin does not always render shortcodes/filters and does not evaluate Global Data (1.0.0-beta.8)

Open stevenmilstein opened this issue 4 years ago • 1 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:

  1. Add to .eleventy.js:
  eleventyConfig.addShortcode("now", () => {
    return new Date();
  });

  eleventyConfig.addFilter("nowLocale", (locale) => {
    return new Date().toLocaleDateString(locale);
  });
  1. Create _data/globalString.js
module.exports = "I am Global Data";
  1. Create _data/globalStringShortcode.js
module.exports = "It is now {% now %}";
  1. 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 }}

  1. 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: 2021-11-19_14-21-11

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.

stevenmilstein avatar Nov 19 '21 19:11 stevenmilstein

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.

Porges avatar May 07 '22 00:05 Porges

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.

JohnJMills avatar Jun 26 '23 22:06 JohnJMills