@@ -11,14 +11,40 @@ import Plot
1111package struct PlotTests : HTMLGenerator {
1212 package init ( ) { }
1313
14- package func simpleHTML ( ) -> String {
14+ package func staticHTML ( ) -> String {
1515 HTML (
1616 . body(
1717 . h1( " Swift HTML Benchmarks " )
1818 )
1919 ) . render ( )
2020 }
21- package func optimalHTML( ) -> String {
22- simpleHTML ( )
21+ package func dynamicHTML( _ context: Utilities . HTMLContext ) -> String {
22+ let context : Context = Context ( context)
23+ return HTML (
24+ . body(
25+ . component( context. heading) ,
26+ . component( context. desc) ,
27+ . component( context. details_heading) ,
28+ . component( context. qualities_heading) ,
29+ . component( context. qualities)
30+ )
31+ )
32+ . render ( )
33+ }
34+ }
35+
36+ struct Context {
37+ let heading : any Component
38+ let desc : any Component
39+ let details_heading : any Component
40+ let qualities_heading : any Component
41+ let qualities : any Component
42+
43+ init ( _ context: Utilities . HTMLContext ) {
44+ heading = H1 ( context. heading)
45+ desc = Div ( Paragraph ( context. string) . id ( " desc " ) )
46+ details_heading = H2 ( context. user. details_heading)
47+ qualities_heading = H3 ( context. user. qualities_heading)
48+ qualities = List ( context. user. qualities) . id ( " user-qualities " )
2349 }
2450}
0 commit comments