add postprocess
This commit is contained in:
@ -7,3 +7,4 @@ import './smarthbs.helpers'
|
||||
export * from './smarthbs.partials'
|
||||
export * from './smarthbs.template'
|
||||
export * from './smarthbs.variables'
|
||||
export * from './smarthbs.postprocess'
|
||||
|
@ -1,5 +1,9 @@
|
||||
import * as plugins from './smarthbs.plugins'
|
||||
|
||||
/**
|
||||
* Helper:
|
||||
* Allows you to analyze a context
|
||||
*/
|
||||
plugins.handlebars.registerHelper('__analyze', (analyzeContext) => {
|
||||
if (typeof analyzeContext === 'string') {
|
||||
if (plugins.handlebars.partials[analyzeContext]) {
|
||||
@ -12,6 +16,10 @@ plugins.handlebars.registerHelper('__analyze', (analyzeContext) => {
|
||||
}
|
||||
})
|
||||
|
||||
/**
|
||||
* Helper:
|
||||
* logs all registered partials to console
|
||||
*/
|
||||
plugins.handlebars.registerHelper('__allPartialsLog', (analyzeContext) => {
|
||||
console.log(plugins.handlebars.partials)
|
||||
return 'analyzed'
|
||||
|
16
ts/smarthbs.postprocess.ts
Normal file
16
ts/smarthbs.postprocess.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import * as plugins from './smarthbs.plugins'
|
||||
|
||||
|
||||
let safeSyntaxBeginRegex = /{-{/g
|
||||
let safeSyntaxEndRegex = /}-}/g
|
||||
|
||||
/**
|
||||
* allows you to keep handlebars in place across multiple iterations
|
||||
* helpful when handlebars syntax is used by more than one tool in a build chain
|
||||
*/
|
||||
export let postprocess = async (stringArg: string): Promise<string> => {
|
||||
let processedString = stringArg
|
||||
processedString = processedString.replace(safeSyntaxBeginRegex, '{{')
|
||||
processedString = processedString.replace(safeSyntaxEndRegex, '}}')
|
||||
return processedString
|
||||
}
|
Reference in New Issue
Block a user