Hello. I don't know if it is a bug or my mistake. If it is a bug, then is it a Nim or Karax issue?
this works:
#test.nim
import karax/[karaxdsl,vdom]
let res = buildHtml(html):
head:
meta()
echo res
#<html><head><meta /></head></html>
this doesn't :
#test.nim
import karax/[karaxdsl,vdom]
let res = buildHtml(html):
head:
include test2 # <----- look at this line
echo res
#template/generic instantiation of `buildHtml` from here
#Error: attempting to call undeclared routine: 'meta'
#test2.nim
meta()
This is true for untyped macros, but a macro (like the one below) does have the include statement expanded to the ast of the included file.
import macros
macro t(x: typed) =
echo repr x
t:
include tables
The DSL would need to be able to deal with expanded ASTs, yes. That's quite feasible, if only we had a specification of typed ASTs and a compiler that would implement it.
Oh come on, after that "if only we had" set up, the follow up should be something like "And here is the spec, which is implemented in dev. Give it a spin and report any bugs in the issue tracker". You're just going to leave everyone hanging?