35 lines
1.0 KiB
TypeScript
35 lines
1.0 KiB
TypeScript
import * as plugins from './smarthbs.plugins.js';
|
|
|
|
/**
|
|
* Helper:
|
|
* Allows you to analyze a context
|
|
*/
|
|
plugins.handlebars.registerHelper('__analyze', (analyzeContext: unknown) => {
|
|
if (typeof analyzeContext === 'string') {
|
|
if (plugins.handlebars.partials[analyzeContext]) {
|
|
console.log(`The analyzed partial ${analyzeContext} looks like this`);
|
|
console.log(plugins.handlebars.partials[analyzeContext]);
|
|
} else {
|
|
console.error(`The Partial ${analyzeContext} cannot be found`);
|
|
}
|
|
return 'analyzed';
|
|
}
|
|
});
|
|
|
|
/**
|
|
* Helper:
|
|
* logs all registered partials to console
|
|
*/
|
|
plugins.handlebars.registerHelper('__allPartialsLog', (_analyzeContext: unknown) => {
|
|
console.log(plugins.handlebars.partials);
|
|
return 'analyzed';
|
|
});
|
|
|
|
plugins.handlebars.registerHelper('__compile', (evaluationString: unknown, evaluationContext: unknown) => {
|
|
if (typeof evaluationString !== 'string') {
|
|
return '';
|
|
}
|
|
const template = plugins.handlebars.compile(evaluationString);
|
|
return template(evaluationContext);
|
|
});
|