From 69ff80cc2bf3d6e23444e075966c29f3c49385ba Mon Sep 17 00:00:00 2001 From: Phil Kunz Date: Sat, 25 Mar 2017 20:23:47 +0100 Subject: [PATCH] add __compile helper --- dist/index.d.ts | 4 +++- dist/index.js | 6 ++++-- dist/smarthbs.helpers.d.ts | 2 -- dist/smarthbs.helpers.js | 7 +++++-- ts/index.ts | 3 ++- ts/smarthbs.helpers.ts | 5 ++++- 6 files changed, 18 insertions(+), 9 deletions(-) diff --git a/dist/index.d.ts b/dist/index.d.ts index 0a86845..12fc22b 100644 --- a/dist/index.d.ts +++ b/dist/index.d.ts @@ -1,5 +1,7 @@ +/// export declare type TTemplateStringType = 'filePath' | 'code'; +export declare let handlebars: typeof Handlebars; export * from './smarthbs.compile'; -export * from './smarthbs.helpers'; +import './smarthbs.helpers'; export * from './smarthbs.partials'; export * from './smarthbs.template'; diff --git a/dist/index.js b/dist/index.js index 5cd8290..a0bfbbb 100644 --- a/dist/index.js +++ b/dist/index.js @@ -3,8 +3,10 @@ function __export(m) { for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; } Object.defineProperty(exports, "__esModule", { value: true }); +const plugins = require("./smarthbs.plugins"); +exports.handlebars = plugins.handlebars; __export(require("./smarthbs.compile")); -__export(require("./smarthbs.helpers")); +require("./smarthbs.helpers"); __export(require("./smarthbs.partials")); __export(require("./smarthbs.template")); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztBQUdBLHdDQUFrQztBQUNsQyx3Q0FBa0M7QUFDbEMseUNBQW1DO0FBQ25DLHlDQUFtQyJ9 \ No newline at end of file +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztBQUFBLDhDQUE2QztBQUdsQyxRQUFBLFVBQVUsR0FBRyxPQUFPLENBQUMsVUFBVSxDQUFBO0FBQzFDLHdDQUFrQztBQUNsQyw4QkFBMkI7QUFDM0IseUNBQW1DO0FBQ25DLHlDQUFtQyJ9 \ No newline at end of file diff --git a/dist/smarthbs.helpers.d.ts b/dist/smarthbs.helpers.d.ts index 2117d55..e69de29 100644 --- a/dist/smarthbs.helpers.d.ts +++ b/dist/smarthbs.helpers.d.ts @@ -1,2 +0,0 @@ -/// -export declare let registerHelper: typeof Handlebars.registerHelper; diff --git a/dist/smarthbs.helpers.js b/dist/smarthbs.helpers.js index 706063a..cad126f 100644 --- a/dist/smarthbs.helpers.js +++ b/dist/smarthbs.helpers.js @@ -1,5 +1,8 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const plugins = require("./smarthbs.plugins"); -exports.registerHelper = plugins.handlebars.registerHelper; -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRoYnMuaGVscGVycy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0aGJzLmhlbHBlcnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSw4Q0FBNkM7QUFFbEMsUUFBQSxjQUFjLEdBQUcsT0FBTyxDQUFDLFVBQVUsQ0FBQyxjQUFjLENBQUEifQ== \ No newline at end of file +plugins.handlebars.registerHelper('__compile', (evaluationString, evaluationContext) => { + let template = plugins.handlebars.compile(evaluationString); + return template(evaluationContext); +}); +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRoYnMuaGVscGVycy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0aGJzLmhlbHBlcnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSw4Q0FBNkM7QUFFN0MsT0FBTyxDQUFDLFVBQVUsQ0FBQyxjQUFjLENBQUMsV0FBVyxFQUFFLENBQUMsZ0JBQWdCLEVBQUUsaUJBQWlCO0lBQ2pGLElBQUksUUFBUSxHQUFHLE9BQU8sQ0FBQyxVQUFVLENBQUMsT0FBTyxDQUFDLGdCQUFnQixDQUFDLENBQUE7SUFDM0QsTUFBTSxDQUFDLFFBQVEsQ0FBQyxpQkFBaUIsQ0FBQyxDQUFBO0FBQ3BDLENBQUMsQ0FBQyxDQUFBIn0= \ No newline at end of file diff --git a/ts/index.ts b/ts/index.ts index 6d3ee1b..e3377ac 100644 --- a/ts/index.ts +++ b/ts/index.ts @@ -1,7 +1,8 @@ import * as plugins from './smarthbs.plugins' export type TTemplateStringType = 'filePath' | 'code' +export let handlebars = plugins.handlebars export * from './smarthbs.compile' -export * from './smarthbs.helpers' +import './smarthbs.helpers' export * from './smarthbs.partials' export * from './smarthbs.template' diff --git a/ts/smarthbs.helpers.ts b/ts/smarthbs.helpers.ts index ac93dd3..3ac5573 100644 --- a/ts/smarthbs.helpers.ts +++ b/ts/smarthbs.helpers.ts @@ -1,4 +1,7 @@ import * as plugins from './smarthbs.plugins' -export let registerHelper = plugins.handlebars.registerHelper +plugins.handlebars.registerHelper('__compile', (evaluationString, evaluationContext) => { + let template = plugins.handlebars.compile(evaluationString) + return template(evaluationContext) +})