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]) {
|
2018-08-27 23:04:15 +02:00
|
|
|
console.log(`The analyzed partial ${analyzeContext} looks like this`);
|
|
|
|
console.log(plugins.handlebars.partials[analyzeContext]);
|
2017-05-10 16:55:25 +02:00
|
|
|
} else {
|
2018-08-27 23:04:15 +02:00
|
|
|
console.error(`The Partial ${analyzeContext} cannot be found`);
|
2017-05-10 16:55:25 +02:00
|
|
|
}
|
2018-08-27 23:04:15 +02:00
|
|
|
return 'analyzed';
|
2017-05-10 16:55:25 +02:00
|
|
|
}
|
2018-08-27 23:04:15 +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) => {
|
2018-08-27 23:04:15 +02:00
|
|
|
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) => {
|
2018-08-27 23:04:15 +02:00
|
|
|
let template = plugins.handlebars.compile(evaluationString);
|
|
|
|
return template(evaluationContext);
|
|
|
|
});
|