smarthbs/ts/smarthbs.helpers.ts

32 lines
931 B
TypeScript
Raw Normal View History

import * as plugins from './smarthbs.plugins';
2017-03-19 16:14:28 +00:00
2017-05-31 21:59:39 +00:00
/**
* Helper:
* Allows you to analyze a context
*/
plugins.handlebars.registerHelper('__analyze', analyzeContext => {
2017-05-10 14:55:25 +00:00
if (typeof analyzeContext === 'string') {
if (plugins.handlebars.partials[analyzeContext]) {
console.log(`The analyzed partial ${analyzeContext} looks like this`);
console.log(plugins.handlebars.partials[analyzeContext]);
2017-05-10 14:55:25 +00:00
} else {
console.error(`The Partial ${analyzeContext} cannot be found`);
2017-05-10 14:55:25 +00:00
}
return 'analyzed';
2017-05-10 14:55:25 +00:00
}
});
2017-05-10 14:55:25 +00:00
2017-05-31 21:59:39 +00:00
/**
* Helper:
* logs all registered partials to console
*/
plugins.handlebars.registerHelper('__allPartialsLog', analyzeContext => {
console.log(plugins.handlebars.partials);
return 'analyzed';
});
2017-05-10 14:55:25 +00:00
2017-03-25 19:23:47 +00:00
plugins.handlebars.registerHelper('__compile', (evaluationString, evaluationContext) => {
let template = plugins.handlebars.compile(evaluationString);
return template(evaluationContext);
});