@@ -8,6 +8,16 @@ export const renderChunk = (cnk, props) => {
8
8
: cnk . content ;
9
9
10
10
let chunk = { ...cnk , content : sanitizedContent } ;
11
+ let tokens = chunk . content . match ( / \{ { ( .* ?) \} } / g) ;
12
+
13
+ let parsedChunk = chunk . content ;
14
+
15
+ if ( tokens !== null ) {
16
+ tokens . forEach ( function ( token ) {
17
+ parsedChunk = parsedChunk . replace ( token , props . variables [ token . substr ( 2 , token . length - 4 ) ] ) ;
18
+ } ) ;
19
+ }
20
+
11
21
switch ( chunk . chunk_type ) {
12
22
case "single_line_text" :
13
23
case "long_text" :
@@ -20,13 +30,13 @@ export const renderChunk = (cnk, props) => {
20
30
key = { chunk . identifier }
21
31
{ ...props }
22
32
>
23
- { chunk . content }
33
+ { parsedChunk }
24
34
</ em-span > )
25
35
: ( < Text
26
36
key = { chunk . identifier }
27
37
{ ...props }
28
38
>
29
- { chunk . content }
39
+ { parsedChunk }
30
40
</ Text > ) ;
31
41
case "rich_text" :
32
42
return Platform . OS === 'web'
@@ -37,7 +47,7 @@ export const renderChunk = (cnk, props) => {
37
47
data-chunk-content-key = { chunk . content_key }
38
48
data-chunk-type = "rich_text"
39
49
key = { chunk . identifier }
40
- dangerouslySetInnerHTML = { { __html : chunk . content } }
50
+ dangerouslySetInnerHTML = { { __html : parsedChunk } }
41
51
{ ...props }
42
52
>
43
53
</ em-span > )
@@ -62,7 +72,7 @@ export const renderChunk = (cnk, props) => {
62
72
/> ) ;
63
73
default :
64
74
return Platform . OS === 'web'
65
- ? < span { ...props } > { chunk . content } </ span >
66
- : < Text { ...props } > { chunk . content } </ Text > ;
75
+ ? < span { ...props } > { parsedChunk } </ span >
76
+ : < Text { ...props } > { parsedChunk } </ Text > ;
67
77
}
68
78
} ;
0 commit comments