diff --git a/CHANGELOG.md b/CHANGELOG.md index ddf74215..e9ebb84c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ ### Added - [nj] Added `example()` macro which allows to quickly output demo of any html or css - [nj] Added early version of Examples page, which showcasing large portion (but not all) of Ekzo helpers and objects +- [nj] Added `renderCaller` filter as workaround of that issue https://github.com/mozilla/nunjucks/issues/783 ### Fixed - Fixed typo in Grunt's watch config diff --git a/source/layouts/components/_example.nj b/source/layouts/components/_example.nj index 9ee8caa0..b9c4743e 100644 --- a/source/layouts/components/_example.nj +++ b/source/layouts/components/_example.nj @@ -27,7 +27,7 @@
- {{ caller() }} + {{ caller()|renderCaller }}
diff --git a/tasks/grunt-nunjucks-2-html.coffee b/tasks/grunt-nunjucks-2-html.coffee index 688be4e7..db7934ad 100644 --- a/tasks/grunt-nunjucks-2-html.coffee +++ b/tasks/grunt-nunjucks-2-html.coffee @@ -57,6 +57,7 @@ module.exports = (grunt) -> i18n = new Gettext() marked = require('marked') markdown = require('nunjucks-markdown') + nunjucks = require('nunjucks') urlify = require('urlify').create({ addEToUmlauts : taskConfig.urlify.addEToUmlauts szToSs : taskConfig.urlify.szToSs @@ -400,6 +401,18 @@ module.exports = (grunt) -> array.push(value) array + ###* + * Renders output of `caller()` once again. Useful if you're + * using `{% raw %}` block inside of call, for example, + * to showcase nunjucks code + * @param {object} caller Caller to force render + * @return {string} Rendered html + * + * @todo Related to this issue https://github.com/mozilla/nunjucks/issues/783 + ### + env.addFilter 'renderCaller', (caller) -> + nunjucks.renderString(caller.val, this.getVariables()); + ###* * Get language code from locale, without country * @param {string} locale = currentLocale Locale, from which should be taken language code