-
-
Notifications
You must be signed in to change notification settings - Fork 557
Closed
Labels
converted-to-discussionenhancementfavoriteVanity label! We like this enhancement request a lot.Vanity label! We like this enhancement request a lot.feature: 🪢 render pluginThe Render pluginThe Render plugin
Description
Is your feature request related to a problem? Please describe.
No response
Describe the solution you'd like
I started using the renderFile option provided in the Render plugin: https://www.11ty.dev/docs/plugins/render/#renderfile. It works as expected, but when I use frontmatter in the rendered file, it doesn't seem to work.
It would be very helpful to have that and make it work 11tysh 💯
{% renderFile "file.njk", { data } %}
In the rendered file:
---
title: Some title
description: ...
---
Content for included file
Describe alternatives you've considered
Before finding the Render plugin I created a custom tag for my 11ty projects which works similar, but I couldn't make it process the nunjucks shortcodes and filters inside the included file:
config.addNunjucksTag("inject", function(nunjucksEngine) {
return new function() {
this.tags = ["inject"];
this.parse = function(parser, nodes) {
const token = parser.nextToken()
const args = parser.parseSignature(null, true)
parser.advanceAfterBlockEnd(token.value)
return new nodes.CallExtensionAsync(this, 'run', args)
}
this.run = function(context, filePath, data, callback) {
filePath = path.resolve('src/', filePath)
// Allow usage without data passed to the tag
if (callback == null) {
callback = data
data = null
}
fs.readFile(filePath, 'utf8', (err, str) => {
if (err != null) return callback(err)
var content = fm(str)
var body = content.body
let ret = nunjucksEngine.renderString(body, data, {
path: filePath
}, callback)
ret = new nunjucksEngine.runtime.SafeString(ret);
callback(null, ret);
})
};
}();
});
Additional context
No response
zachleat, extrabright, User120012, Festerash, ivlasceanu and 4 more
Metadata
Metadata
Assignees
Labels
converted-to-discussionenhancementfavoriteVanity label! We like this enhancement request a lot.Vanity label! We like this enhancement request a lot.feature: 🪢 render pluginThe Render pluginThe Render plugin