From e223a27d6b83e91bfae1c9f5497e45549eecd1b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E9=BE=99?= Date: Sun, 12 Jun 2016 20:11:44 +0800 Subject: [PATCH] add velocity surport --- lib/consolidate.js | 22 ++++++++++++++++++++++ package.json | 3 ++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/lib/consolidate.js b/lib/consolidate.js index 795c2b2..ce02e20 100644 --- a/lib/consolidate.js +++ b/lib/consolidate.js @@ -169,6 +169,28 @@ function fromStringRenderer(name) { }; } +/** + * velocity support. + */ + +exports.velocityjs = fromStringRenderer('velocityjs'); + +/** + * velocity string support. + */ + +exports.velocityjs.render = function(str, options, fn){ + return promisify(fn, function(fn) { + var engine = requires.velocityjs || (requires.velocityjs = require('velocityjs')); + try { + options.locals = options; + fn(null, engine.render(str, options).trimLeft()); + } catch (err) { + fn(err); + } + }); +}; + /** * Liquid support. */ diff --git a/package.json b/package.json index eac8362..cf8ee86 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,8 @@ "underscore": "^1.3.3", "vash": "^0.8.7", "walrus": "^0.10.1", - "whiskers": "^0.3.3" + "whiskers": "^0.3.3", + "velocityjs": "^0.8.2" }, "main": "index", "repository": {