You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe. 🤔
I've noticed that some of my code operating on the children of a TagRef' is now broken. Basically this seems to be because the children now appear as seq[Node] instead of seq[TagRef] when passed around as data.
Describe the solution you'd like 💡
Since making a TagRef through buildHtml only to take out a seq of children TagRefs is a bit convoluted, I thought it might would be a good time to implement some templates for creating seqs of to-be-rendered DSL data. I'd use something like this myself in my own development system if it wasn't integrated into happyx. Note that currently the TagRef based approach of buildHtmls fails and only the thunk based approach works in a straightforward way.
template thunkHtml(body: untyped): proc(): TagRef =
proc(): TagRef = buildHtml:
body
template thunkHtmls(body: untyped): seq[proc(): TagRef] =
block:
var res: seq[proc(): TagRef]
template html(b: untyped) =
res.add:
proc(): TagRef = buildHtml:
b
body
res
template buildHtmls(body: untyped): seq[TagRef] =
block:
var res: seq[TagRef]
template html(b: untyped) =
res.add:
buildHtml:
b
body
res
let htmlProcs = thunkHtmls:
html:
tSpan: "front"
html:
tSpan: "back"
let htmlTags = buildHtmls:
html:
tSpan: "right"
html:
tSpan: "left"
component FormatProcHtml:
p: (proc (): TagRef) # parentheses needed in avoid "nested statements" error
html:
em(style="color:blue"): {self.p()}
component FormatTagHtml:
t: TagRef
html:
em(style="color:blue"):
{self.t.val}
appRoutes("ROOT"):
"/":
for i in 1..5:
tDiv:{$htmlProcs[0]()}
FormatProcHtml(htmlProcs[1])
for i in 1..5:
tDiv:{$htmlTags[0]}
FormatTagHtml(htmlTags[1])
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe. 🤔
I've noticed that some of my code operating on the children of a TagRef' is now broken. Basically this seems to be because the children now appear as
seq[Node]
instead ofseq[TagRef]
when passed around as data.Describe the solution you'd like 💡
Since making a TagRef through buildHtml only to take out a seq of children TagRefs is a bit convoluted, I thought it might would be a good time to implement some templates for creating seqs of to-be-rendered DSL data. I'd use something like this myself in my own development system if it wasn't integrated into happyx. Note that currently the
TagRef
based approach ofbuildHtmls
fails and only the thunk based approach works in a straightforward way.The text was updated successfully, but these errors were encountered: