Can someone point out what's wrong with this source filter (I'm trying samples given here - https://nim-lang.org/docs/filters.html) as it refuses to compile with an "invalid indentation" error message
#? stdtmpl | standard
#proc greet(name = "world"): string =
# result = ""
<h1>Hello $name</h1>
#end proc
echo greet()
Also, is this the recommend approach to HTML view templates? If not, can someone suggest alternatives?
I don't know how you got "invalid indentation". Even pressing the "Run" button on the forum gives a different error. This is the correct version:
#? stdtmpl | standard
#proc greet(name = "world"): string =
# result = ""
<h1>Hello $name</h1>
#end proc
#
#echo greet()
Thanks Dom, I didn't realize you could run code right here but yes I've seen this error before too on the same script! I think I finally got it work by moving the above code to its own file and including it at the call site. Given that I take it templates need to be defined in their own files, if this is really so, then perhaps the documentation needs a line highlighting that.
Could you also please throw some light on my other question herein? I see you're using these templates in Jester (which is amazing btw, thanks for all your work!) -- are these templates the way to go for HTML views or do you have other recommendations?
The same "indentation problem" for me. It was impossible to understand why it is not working. Read all I could find in docs and google.
But thanks for this topic - I moved it to the external file and added:
"include file_name"
It wasn't obvious.