@@ -2,6 +2,7 @@ import parse from "./parser.js";
22import { Node , isNode } from "./node.js" ;
33import * as hole from "./hole.js" ;
44import { NamedReactive } from "./reactive.js" ;
5+ import * as logger from "./logger.js" ;
56
67export const html = (
78 strings : TemplateStringsArray ,
@@ -21,13 +22,17 @@ export const html = (
2122 throw TypeError ( "Template root must be an element" ) ;
2223 }
2324
24- const context = Object . freeze ( indexContext ( values ) ) ;
25+ const context = indexContext ( values ) ;
2526
26- return Object . freeze ( {
27+ const renderable : Renderable = {
2728 type : "renderable" ,
2829 template,
2930 context,
30- } )
31+ } ;
32+
33+ logger . debug ( "Renderable" , renderable ) ;
34+
35+ return renderable ;
3136} ;
3237
3338export default html ;
@@ -46,14 +51,16 @@ export type Context = { [key: string]: NamedReactive<unknown> };
4651
4752const indexContext = ( items : Array < NamedReactive < unknown > > ) : Context => {
4853 return Object . fromEntries ( items . map ( ( item ) => [ item . name , item ] ) ) ;
49- }
54+ } ;
5055
5156const flattenTemplateStrings = (
5257 strings : TemplateStringsArray ,
53- values : Array < NamedReactive < unknown > >
58+ values : Array < NamedReactive < unknown > > ,
5459) : string => {
55- return strings . reduce ( ( result , string , i ) => {
60+ const templateString = strings . reduce ( ( result , string , i ) => {
5661 const value = values [ i ] ;
5762 return result + string + ( value ? hole . markup ( value . name ) : "" ) ;
5863 } , "" ) ;
59- }
64+ logger . debug ( "Flattened" , templateString ) ;
65+ return templateString ;
66+ } ;
0 commit comments