You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 13, 2023. It is now read-only.
@invatom the solution you provided doesn't actually work for me for whatever reason.
I found a way to do it that might be better, but i'm not certain.
this.config.addNunjucksTag('sb_blocks', (nunjucks, nunjucksEnv) => {
let self = this;
return new (function () {
this.tags = ['sb_blocks'];
this.parse = function (parser, nodes, lexer) {
let tok = parser.nextToken();
let args = parser.parseSignature(null, true);
parser.advanceAfterBlockEnd(tok.value);
return new nodes.CallExtensionAsync(this, 'run', args);
};
this.run = function (context, blocks, callback) {
let html_output = new nunjucks.runtime.SafeString(
self.outputBlocks(blocks, nunjucksEnv)
);
// let html_output = self.outputBlocks(blocks, nunjucksEnv);
return callback(null, html_output);
};
})();
});
In the above, you can see I changed nunjucksEngine to just nunjucks, and then I switched let html_output ... to use SafeString (mentioned here in autoescape docs, and here in custom tags docs):
let html_output = new nunjucks.runtime.SafeString(
self.outputBlocks(blocks, nunjucksEnv)
);
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Hi, I just dropped this into my 11ty solution and tried to get sb_blocks to work.
Path is fine, it finds and renders the blocks using
{% sb_blocks sida.data.bloks %}
But the output is treated as unsafe html so all tags are just outputted to screen.
I tried the | safe filter, but that did not work.
Any ideas? I'm not sure if this problem comes from nunjucks, eleventy or this plugin.
The text was updated successfully, but these errors were encountered: