carlitoplatanito / gulp-nunjucks-render

[Gulp](https://github.com/wearefractal/gulp) plugin to render [Nunjucks](http://mozilla.github.io/nunjucks/) templates

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add info to docs

molszanski opened this issue · comments

Hey,

in every nunjucks template you add a magic variable name that is filename the is being processed.

I think you should add it to docs page

Sorry, I don't understand what you mean? I don't add any magic variables...

  options.name = typeof options.name === 'function' && options.name(file) || file.relative;
  file.contents = new Buffer(nunjucks.renderString(file.contents.toString(), options));

add {{ name }} to any template you run and see what happens

Ahh, sorry you are correct, completely through me off by calling it a "magic" variable, my fault.

Will make sure to document it.

Thanks

IMO this is pretty cool feature, worth keeping and informing

Won't this create a collision if the data context contains a name key?

eg.
thing.nunj

<label>Name: <input type="text" value="{{ name }}"></label>

thing.html

<label>Name: <input type="text" value="thing.nunj"></label>

Seems like name could be a fairly common key - can I suggest renaming it to something unlikely to cause a collision, such as _name, _filename, $template_name etc.