Home > @wixc3/common > templateCompilerProvider
Similar to templated string, given a fixed context object returns a function that parses strings in it
Signature:
export declare function templateCompilerProvider(context: Record<string, any>): (template: string) => string;
Parameter | Type | Description |
---|---|---|
context | Record<string, any> | A context for the compiler |
Returns:
(template: string) => string
A template compiler function which accepts a template and compile it with context
const compile = templateCompilerProvider({ greetings: 'Hello', person: { name: 'Elad' } })
compile('${greetings} ${person.name}!')// => Hello Elad!
compile('${person.name} is awesome')// => Elad is awesome