Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
stevenmilstein opened this issue Nov 19, 2021 · 2 comments

Comments

@stevenmilstein
Copy link

stevenmilstein commented Nov 19, 2021

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.

@Porges
Copy link

Porges commented May 7, 2022

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.

@JohnJMills
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants