@@ -200,8 +200,10 @@ async function render({ source, element, selector, data, key, index, currentInde
200
200
201
201
await renderTemplate ( element [ i ] , data , key , index ) ;
202
202
}
203
- } else
204
- await renderValues ( element [ i ] , data ) ;
203
+ } else {
204
+ let renderAs = element [ i ] . getAttribute ( 'render-as' ) || key ;
205
+ await renderValues ( element [ i ] , data , key , renderAs ) ;
206
+ }
205
207
206
208
}
207
209
@@ -583,6 +585,8 @@ async function renderValues(node, data, key, renderAs, keyPath, parent) {
583
585
async function renderValue ( node , data , placeholder , renderAs , renderedNode ) {
584
586
let output = placeholder ;
585
587
let regex = / \{ ( [ ^ { } ] + ) \} /
588
+ let omitted = { }
589
+
586
590
let match ;
587
591
do {
588
592
match = output . match ( regex ) ;
@@ -633,19 +637,25 @@ async function renderValue(node, data, placeholder, renderAs, renderedNode) {
633
637
if ( typeof value === "object" ) {
634
638
value = JSON . stringify ( value , null , 2 ) ;
635
639
}
636
- output = output . replace ( match [ 0 ] , value ) ;
640
+ output = output . replaceAll ( match [ 0 ] , value ) ;
637
641
} else if ( renderAs ) {
638
642
if ( match [ 0 ] . startsWith ( `{{${ renderAs } .` ) ) {
639
- output = output . replace ( match [ 0 ] , "" ) ;
643
+ output = output . replaceAll ( match [ 0 ] , "" ) ;
640
644
} else {
641
- match = null ;
645
+ output = output . replaceAll ( match [ 0 ] , `<|${ match [ 1 ] } |>` ) ;
646
+ omitted [ `<|${ match [ 1 ] } |>` ] = match [ 0 ]
642
647
}
643
648
} else {
649
+ // output = output.replace(match[0], `<|${match[1]}|>`);
644
650
match = null ;
645
651
}
646
652
}
647
653
} while ( match ) ;
648
654
655
+ for ( let key of Object . keys ( omitted ) ) {
656
+ output = output . replaceAll ( key , omitted [ key ] ) ;
657
+ }
658
+
649
659
return output ;
650
660
}
651
661
0 commit comments