Skip to content
This repository has been archived by the owner on Sep 28, 2023. It is now read-only.

Commit

Permalink
[nj] added renderCaller filter as workaround of mozilla/nunjucks#783
Browse files Browse the repository at this point in the history
  • Loading branch information
ArmorDarks committed Jun 14, 2016
1 parent 6c7c51f commit 3a50ef9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion source/layouts/components/_example.nj
Expand Up @@ -27,7 +27,7 @@
</div>

<div class='o-grid__item h-1/1 h-margin-top {{ 'h-2/9@tablet h-margin-top0@tablet' if not full }}'>
{{ caller() }}
{{ caller()|renderCaller }}
</div>

<div class='o-grid__item h-1/1 h-margin-top {{ 'h-5/9@tablet h-margin-top0@tablet' if not full }}'>
Expand Down
13 changes: 13 additions & 0 deletions tasks/grunt-nunjucks-2-html.coffee
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 3a50ef9

Please sign in to comment.