Undeclared identifier calling a mixin with a template parameter.
GrundleTrundle opened this issue · comments
I've tried this on 0.16.0 and the development branch of Nim.
Here's the code:
import
emerald, streams
proc mixin_with_params(content: string) {.html_mixin.} =
p: content
proc genSummaryPage(thingy: string) {.html_templ.} =
body:
call_mixin mixin_with_params(thingy)
proc doit() =
let
outfs = newFileStream(stdout)
t = newGenSummaryPage()
t.thingy = "blah"
t.render(outfs)
doit()
Compiling it gives me this error:
hg.nim(7, 37) template/generic instantiation from here
hg.nim(9, 34) Error: undeclared identifier: 'thingy'
It seems specific to passing the thingy
parameter to the mixin. Replacing call_mixin mixin_with_params(thingy)
with call_mixin mixin_with_params("a string")
works fine, and I can reference thingy
in other parts of the template. Just not as a mixin parameter.
This issue shows that emerald is more a tech demo than an actually useful tool for complex tasks. Sometimes, because something is possible does not mean that it is feasible.
This is a conceptual problem an I think the correct way to solve it is to implement the call-by-name-ALGOL-rule for parameter resolution.
That being said, it is unlikely that I will invest more work into this project, since I came to believe that while it is a pretty nice tech demo, it is not a great tool to tackle actual problems.
I understand, thanks for the response.