-
|
I searched all over for an existing discussion or issue around this before asking, but could not seem to find an answer. Please forgive me if I missed it. I've been looking to leverage the JavaScript file support for things that are simply a little too dynamic to manage in Nunjucks, specifically for the inclusion of content fragments, or partials. When I tried to create a Is there a way to configure 11ty to process JavaScript files for includes similarly to how they are processed for layouts? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
You can’t use My first thought is that what you're looking for is a shortcode: https://www.11ty.dev/docs/shortcodes/ That would let you write some JavaScript functions that returns a string of HTML that you can call from inside your templates. Another thing that might work is Eleventy’s render plugin: https://www.11ty.dev/docs/plugins/render/ |
Beta Was this translation helpful? Give feedback.
You can’t use
{% include %}for anything other than Nunjucks templates and have it be evaluated. The include tag is purely a Nunjucks thing, and Eleventy doesn't have anything to do with it.My first thought is that what you're looking for is a shortcode: https://www.11ty.dev/docs/shortcodes/
That would let you write some JavaScript functions that returns a string of HTML that you can call from inside your templates.
Another thing that might work is Eleventy’s render plugin: https://www.11ty.dev/docs/plugins/render/