For anyone who want to do testing on MiniHtml library, please fork my repo from GitHub.
Generate HTML from B4X code. Contribute to pyhoon/MiniHtml-B4X development by creating an account on GitHub.
For Pakai server v6, it is already a stable version and ready to use for developing web app.
However, the sample code demonstrated in this project template generates the html on demand.
I think this is against the DRY principle.
It can be improved in term of performance and make a better developer experience.
My idea is to
store a tag object in memory that is generated using MiniHtml template and then
reuse it.
I can also use other caching solution available for server such as KVS, Caffeine or Lettuce.
The template object when retrieved to use further must not changed from the original form.
This is not true as I what I am facing now.
Check this code:
Private Sub Test4
Dim Temp As Tag = Paragraph.init ' <p></p>
Dim M1 As Map = CreateMap("Temp": Temp)
Dim D1 As Tag = Div.init
'Dim P1 As Tag = M1.Get("Temp")
Dim P1 As Tag = M1.Get("Temp").As(Tag).Clone
P1.text("Demo 1").up(D1)
'Dim P2 As Tag = M1.Get("Temp")
Dim P2 As Tag = M1.Get("Temp").As(Tag).Clone
P2.text("Demo 2").up(D1)
Dim PT As Tag = M1.Get("Temp")
Log(PT.Build)
' Log 1 (without Clone) : <p>Demo 1Demo 2</p>
' Log 2 (with Clone) : <p></p>
End Sub