onionhammer / nim-templates

A simple string templating library for Nim
BSD 3-Clause "New" or "Revised" License
93 stars 9 forks source link

Ability to read HTML from file and provide as argument for `tmpli html` #4

Closed joemarct closed 8 years ago

joemarct commented 8 years ago

I have tried to read a file and feed it to tmpli html, like this: tmpli html readFile "templates/base.html"

However, I got this error: Error: field 'strVal' cannot be found

onionhammer commented 8 years ago

This may be possible to implement with staticRead; but i don't think it will work out of the box. Currently tmpli expects a string literal so that the template can be compiled into the resulting executable.

joemarct commented 8 years ago

I hacked my way to achieve my end goal, which is basically to write a separate HTML file and simply pass the path to tmpli as argument. I initiated a pull request #5 , in case you would want to merge my revisions.

joemarct commented 8 years ago

Just to update on the progress of this issue: We ended up creating a separate macro tmplf for reading HTML code from file. This has been merged to master in 84db5ce164b3512a194c54d20510806b454958e8.