Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/happyx/spa/tag.nim
Original file line number Diff line number Diff line change
Expand Up @@ -456,18 +456,20 @@ proc xml2Tag*(xml: XmlNode): TagRef =

proc xmlTree2Tag*(current, parent: TagRef, tree: XmlNode) =
let tag = tree.xml2Tag()
if not tag.isNil():
current.add(tag)
if tree.kind == xnElement:
for child in tree.items:
tag.xmlTree2Tag(current, child)
if not tag.isNil():
current.add(tag)


proc tagFromString*(source: string): TagRef {.inline.} =
## Translates raw HTML string into TagRef
let xmlNode = parseHtml(source)
result = initTag("div", @[], true)
# for child in xmlNode:
result.xmlTree2Tag(nil, xmlNode)
# result.xmlTree2Tag(nil, xmlNode)
when defined(js):
result = result.children[0].children[0].TagRef
else:
Expand Down
15 changes: 15 additions & 0 deletions tests/testjs19.nim
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,21 @@ import
../src/happyx


var html =
buildHtml(tDiv):
rawHtml: """
<div>
<input type="password" />
<hr>
<script>
var x = "Hello, world!";
</script>
</div>
"""

echo html


# Declare application with ID "app"
appRoutes "app":
"/page1":
Expand Down