npm.io
0.0.2 • Published 4 years ago

angular-dynamic-interpolation

Licence
MIT
Version
0.0.2
Deps
1
Size
70 kB
Vulns
0
Weekly
0

Angular Dynamic Interpolation

A simple library that replaces string placeholders with angular ng-templates.

Requirements

Angular 13+

Example

<!-- components.html -->

<dip-interpolation [template]="'FOO {{ BUTTON }} BAR'">
  <button *dipReplacement="'BUTTON'">FOOBAR</button>
</dip-interpolation>

<!-- result -->
FOO <button>FOOBAR</button> BAR

Configuration

//module.ts

@NgModule({
    ...
    imports: [
        ...
        DynamicInterpolationModule.forRoot({
            //Placeholder names should be matched in regex group
            //The following example will match e.g. %%VARIABLE%%
            regex: /%%(.*?)%%/
        })
    ]
})