Last active
July 3, 2019 03:04
-
-
Save xx4159/d5d3ffb341caaeb87af2358259e93f50 to your computer and use it in GitHub Desktop.
Replace curly braces to span
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Pipe, PipeTransform } from '@angular/core'; | |
@Pipe({ | |
name: 'replaceCurly' | |
}) | |
export class ReplaceCurlyPipe implements PipeTransform { | |
transform(value: string): string { | |
const regex = /\{\{([^\{].*?)\}\}/g; | |
if (value) { | |
return value.replace(regex, `<span>$1</span>`); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment