File tree Expand file tree Collapse file tree
tests/Oxpecker.ViewEngine.Tests Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11open System
2- open System.ComponentModel .DataAnnotations
32open System.Text .Json .Serialization
43open System.Threading .Tasks
54open Microsoft.AspNetCore .Authorization
Original file line number Diff line number Diff line change @@ -100,6 +100,12 @@ module Builder =
100100 interface HtmlElement with
101101 member this.Render sb = this.Render sb
102102
103+ /// Integer node that will NOT be HTML-escaped
104+ type IntNode ( value : int ) =
105+ member this.Render ( sb : StringBuilder ) = value |> sb.Append |> ignore
106+ interface HtmlElement with
107+ member this.Render sb = this.Render sb
108+
103109 /// Create text node that will NOT be HTML-escaped
104110 let inline raw text = RawTextNode text
105111
@@ -132,6 +138,8 @@ module Builder =
132138
133139 member inline _.Yield ( text : string | null ) : HtmlContainerFun = _. AddChild( RegularTextNode text)
134140
141+ member inline _.Yield ( value : int ) : HtmlContainerFun = _. AddChild( IntNode value)
142+
135143 type HtmlContainerExtensions =
136144 [<Extension>]
137145 static member inline Run ( this : #HtmlContainer , [<InlineIfLambda>] runExpr : HtmlContainerFun ) =
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ open FsUnit.Light
1212let ``Basic test`` () =
1313 let result =
1414 html() {
15- div( id = " 1" )
15+ div( id = " 1" ) { 1 }
1616 div( id = " 2" ) {
1717 let x = 2
1818 div( id = " 3" , class' = " test" )
@@ -24,13 +24,13 @@ let ``Basic test`` () =
2424 result
2525 |> Render.toString
2626 |> shouldEqual
27- """ <html><div id="1"></div><div id="2"><div id="3" class="test"></div><br><br><div id="4"></div></div></html>"""
27+ """ <html><div id="1">1 </div><div id="2"><div id="3" class="test"></div><br><br><div id="4"></div></div></html>"""
2828
2929[<Fact>]
3030let ``Basic test to bytes`` () =
3131 let result =
3232 html() {
33- div( id = " 1" )
33+ div( id = " 1" ) { 1 }
3434 div( id = " 2" ) {
3535 let x = 2
3636 div( id = " 3" , class' = " test" )
@@ -43,7 +43,7 @@ let ``Basic test to bytes`` () =
4343 |> Render.toBytes
4444 |> Encoding.UTF8.GetString
4545 |> shouldEqual
46- """ <html><div id="1"></div><div id="2"><div id="3" class="test"></div><br><br><div id="4"></div></div></html>"""
46+ """ <html><div id="1">1 </div><div id="2"><div id="3" class="test"></div><br><br><div id="4"></div></div></html>"""
4747
4848
4949[<Fact>]
You can’t perform that action at this time.
0 commit comments