smarthbs/ts/smarthbs.helpers.ts

32 lines
938 B
TypeScript
Raw Normal View History

2022-07-24 15:30:19 +02:00
import * as plugins from './smarthbs.plugins.js';
2017-03-19 17:14:28 +01:00
2017-05-31 23:59:39 +02:00
/**
* Helper:
* Allows you to analyze a context
*/
2022-07-24 15:30:19 +02:00
plugins.handlebars.registerHelper('__analyze', (analyzeContext) => {
2017-05-10 16:55:25 +02: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 16:55:25 +02:00
} else {
console.error(`The Partial ${analyzeContext} cannot be found`);
2017-05-10 16:55:25 +02:00
}
return 'analyzed';
2017-05-10 16:55:25 +02:00
}
});
2017-05-10 16:55:25 +02:00
2017-05-31 23:59:39 +02:00
/**
* Helper:
* logs all registered partials to console
*/
2022-07-24 15:30:19 +02:00
plugins.handlebars.registerHelper('__allPartialsLog', (analyzeContext) => {
console.log(plugins.handlebars.partials);
return 'analyzed';
});
2017-05-10 16:55:25 +02:00
2017-03-25 20:23:47 +01:00
plugins.handlebars.registerHelper('__compile', (evaluationString, evaluationContext) => {
let template = plugins.handlebars.compile(evaluationString);
return template(evaluationContext);
});