diff --git a/README.md b/README.md index 70696ce..1706060 100644 --- a/README.md +++ b/README.md @@ -18,9 +18,26 @@ Possible options are (all passed to jade.compile()): * locals - set locals +The loader query is passed to template function, also all environments variables +from process.env will be copied into locals and could be used in +templates `#{MY_ENV_VAR}`. + + +```javascript +require("jade-html?{author:"Kafka"}!./file.jade"); +``` + +```jade +html + script src="#{CDN_URL}/react.js" + body + h3 #{author} +``` + Don't forget to polyfill `require` if you want to use it in node. See [enhanced-require](https://github.com/webpack/enhanced-require) documentation. + ## License MIT (http://www.opensource.org/licenses/mit-license.php) diff --git a/index.js b/index.js index f829448..f24a929 100644 --- a/index.js +++ b/index.js @@ -17,5 +17,9 @@ module.exports = function(source) { compileDebug: this.debug || false }); + for (var k in process.env){ + query[k] = process.env[k] + } + return tmplFunc(query); }