Hello,
I have enum type
type TEMPLATE_FILES = enum
page_html = "page.html"
head_html = "head.html"
head_includes_html = "head_includes.html"
body_html = "body.html"
header_html = "header.html"
before_content_html = "before_content.html"
after_content_html = "after_content.html"
footer_html = "footer.html"
foot_includes_html = "foot_includes.html"
I can in macro
macro defaultTemplates(): untyped =
result = newStmtList()
var line = ""
for tpl in getType(TEMPLATE_FILES):
echo tpl.treeRepr
if tpl.kind != nnkEmpty:
echo tpl
print page_html and next. I can get value "page.html" and next. Why I get it in macro?
thanks
Zivoslav
if TEMPLATE_FILES never changes you can just iterate over the enum values and get the string, like in any other procedure.
for i in low(TEMPLATE_FILES)..high(TEMPLATE_FILES):
$i
I'm trying to get the contents of the files at compile time.
I have file names in enum. The user can create his own file, or offer him a default, loaded during compilation.
This should work
proc getDefaultFiles(): array[TEMPLATE_FILES, string] {.compileTime.} =
for i in TEMPLATE_FILES:
result[i] = staticRead $i