diff --git a/Readme.md b/Readme.md index 5a8b170..d7bb262 100644 --- a/Readme.md +++ b/Readme.md @@ -39,6 +39,7 @@ - [react](https://github.com/facebook/react) - [slm](https://github.com/slm-lang/slm) - [swig (unmaintained)](https://github.com/paularmstrong/swig) + - [swig (maintained fork)](https://github.com/node-swig/swig-templates) - [teacup](https://github.com/goodeggs/teacup) - [templayed](http://archan937.github.com/templayed.js/) - [twig](https://github.com/justjohn/twig.js) diff --git a/lib/consolidate.js b/lib/consolidate.js index 3b4b600..37386bf 100644 --- a/lib/consolidate.js +++ b/lib/consolidate.js @@ -540,7 +540,18 @@ exports.swig = fromStringRenderer('swig'); exports.swig.render = function(str, options, fn){ return promisify(fn, function(fn) { - var engine = requires.swig || (requires.swig = require('swig')); + var engine = requires.swig; + if (!engine) { + try { + engine = requires.swig = require('swig'); + } catch (err) { + try { + engine = requires.swig = require('swig-templates'); + } catch (otherError) { + throw err; + } + } + } try { if(options.cache === true) options.cache = 'memory'; diff --git a/package.json b/package.json index 56f0663..aa4e653 100644 --- a/package.json +++ b/package.json @@ -56,6 +56,7 @@ "react-dom": "^15.3.2", "should": "*", "slm": "^0.5.0", + "swig-templates": "^2.0.2", "swig": "^1.4.1", "teacup": "^2.0.0", "templayed": ">=0.2.3",