2022-07-24 13:30:19 +00:00
|
|
|
import * as plugins from './smarthbs.plugins.js';
|
2017-03-19 16:14:28 +00:00
|
|
|
|
2017-05-31 21:59:39 +00:00
|
|
|
/**
|
|
|
|
* Helper:
|
|
|
|
* Allows you to analyze a context
|
|
|
|
*/
|
2022-07-24 13:30:19 +00:00
|
|
|
plugins.handlebars.registerHelper('__analyze', (analyzeContext) => {
|
2017-05-10 14:55:25 +00:00
|
|
|
if (typeof analyzeContext === 'string') {
|
|
|
|
if (plugins.handlebars.partials[analyzeContext]) {
|
2018-08-27 21:04:15 +00:00
|
|
|
console.log(`The analyzed partial ${analyzeContext} looks like this`);
|
|
|
|
console.log(plugins.handlebars.partials[analyzeContext]);
|
2017-05-10 14:55:25 +00:00
|
|
|
} else {
|
2018-08-27 21:04:15 +00:00
|
|
|
console.error(`The Partial ${analyzeContext} cannot be found`);
|
2017-05-10 14:55:25 +00:00
|
|
|
}
|
2018-08-27 21:04:15 +00:00
|
|
|
return 'analyzed';
|
2017-05-10 14:55:25 +00:00
|
|
|
}
|
2018-08-27 21:04:15 +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
|
|
|
|
*/
|
2022-07-24 13:30:19 +00:00
|
|
|
plugins.handlebars.registerHelper('__allPartialsLog', (analyzeContext) => {
|
2018-08-27 21:04:15 +00:00
|
|
|
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) => {
|
2018-08-27 21:04:15 +00:00
|
|
|
let template = plugins.handlebars.compile(evaluationString);
|
|
|
|
return template(evaluationContext);
|
|
|
|
});
|