Closed jalberto closed 3 months ago
is it a bug, or works as expected?
I believe this is working as intended. It's generally best to pick one templating language and stick with it for the entire project.
It's generally best to pick one templating language and stick with it for the entire project.
Sure it's safer to stick with a single templating language. But what about markdown files?
It seems Eleventy does not apply any parsing or transformation to included files and blindly delegates the responsibility of inclusions to the template engine, just giving it some hints about where to find files. It means you can't have a template with complex HTML that includes pure content sections as easier to maintain markdown files.
@gael-ian For cases like that, I have a filter to convert markdown to html.
const md = require('markdown-it')({ })
eleventyConfig.setLibrary('md', md);
eleventyConfig.addFilter("markdownify", string => {
return md.renderInline(string)
})
@jalberto I think this is happening because the njk
template is being included with a liquid tag. To my knowledge, includes only read the contents of a file. That said, you could create a custom njk filter (see https://github.com/11ty/eleventy/issues/1316#issuecomment-709389133).
To my knowledge, includes only read the contents of a file.
And maybe that's the point. What if 11ty overrides template engines include
functions to not only give them the right context to be able to load files from the right directories but to also apply parsing and transforming ?
This way, no need for a markdownify
filter (by the way, thanks for the tip) or any other. Any file could just be written is any of the supported formats and the output still be what developpers expect it to be.
I know it may be difficult to do and maybe it's not the way the 11ty team wants to go.
Correct, because Nunjucks and Liquid are similar, this may appear like it’s working but it’s parsing both as Liquid (the file extension of an include has no bearing).
All that said, you can do this with the Render plugin, if you wish: https://www.11ty.dev/docs/plugins/render/
if I create a Liquid file like this:
`b.njk' will try to render as liquid, and this is an issue if it contains any njk specificities