-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
escaping curly braces before parsing as JSX
- Loading branch information
Clint Goodman
committed
Feb 13, 2017
1 parent
3da7129
commit 24e3bef
Showing
3 changed files
with
15 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* If the SVG has text that has curly braces, or | ||
if there is a <style> element (which will, of | ||
course, have curly braces) then we need to | ||
escape those for JSX parsing. */ | ||
export default function escape(raw) { | ||
// converts | ||
// <style> .class1 {} .class2{}</style> | ||
// to | ||
// <style> .class1 {`{`}{`}`} .class2{`{`}{`}`}</style> | ||
return raw.replace(/(\{|\})/g, '{`$1`}'); | ||
} |
This file contains 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
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.