-
Beta Was this translation helpful? Give feedback.
Answered by
pdehaan
Jan 7, 2024
Replies: 1 comment 4 replies
-
As far as I know, Liquid/Eleventy won't recursively process the strings, so You can probably get around that using a custom filter which will parse the template though: // eleventy.config.js
const { EleventyRenderPlugin } = require("@11ty/eleventy");
const { Liquid } = require("liquidjs");
/**
* @param {import("@11ty/eleventy/src/UserConfig")} eleventyConfig
* @returns {ReturnType<import("@11ty/eleventy/src/defaultConfig")>}
*/
module.exports = function (eleventyConfig) {
eleventyConfig.addPlugin(EleventyRenderPlugin);
eleventyConfig.addFilter("liquidify", function (input, ctx = {}) {
const engine = new Liquid();
const tpl = engine.parse(input);
return engine.render(tpl, ctx);
});
return {
dir: {
input: "src",
output: "www",
}
};
}; ---
# src/testrender.md
# layout: blank
permalink: "/testrender/"
myData:
key: '{% assign t123 = "testing 123" %}***This is the assigned var t123: {{ t123 }}***'
---
{% renderTemplate "liquid,md", myData %}
{{ key | liquidify }}
{% assign t345 = "testing 345" %}***This is the assigned var t345: {{ t345 }}***
{% endrenderTemplate %} OUTPUT<p><em><strong>This is the assigned var t123: testing 123</strong></em></p>
<p><em><strong>This is the assigned var t345: testing 345</strong></em></p> |
Beta Was this translation helpful? Give feedback.
4 replies
Answer selected by
imalb-prs
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As far as I know, Liquid/Eleventy won't recursively process the strings, so
key
won't be re-parsed to turn the front matter string into a parsed thing.You can probably get around that using a custom filter which will parse the template though: