jstransformers / jstransformer-nunjucks

Nunjucks support for JSTransformers.
http://npm.im/jstransformer-nunjucks
MIT License
6 stars 6 forks source link

Add option to use custom Nunjucks loaders #34

Closed gijswijs closed 5 years ago

gijswijs commented 5 years ago

Nunjucks allows for custom loaders for more complex loading, like from a database. Jstransformer-nunjucks doesn't support it, because it uses the Nunjucks simple API by default. This commit changes the default behavior to switch to the Nunjucks Environment constructor if loaders is available as a key in the options dictionary object.

A test case is provided to explain expected behavior.

More info on Nunjucks custom loaders: https://mozilla.github.io/nunjucks/api.html#writing-a-loader

codecov-io commented 5 years ago

Codecov Report

Merging #34 into master will increase coverage by 2.95%. The diff coverage is 92.3%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master   #34      +/-   ##
=======================================
+ Coverage   69.04%   72%   +2.95%     
=======================================
  Files           1     1              
  Lines          42    50       +8     
  Branches       15    17       +2     
=======================================
+ Hits           29    36       +7     
- Misses         13    14       +1
Impacted Files Coverage Δ
index.js 72% <92.3%> (+2.95%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 9d2c7f1...6856c16. Read the comment docs.

RobLoach commented 5 years ago

This is great!