How pass the arguments to sub-template when using STRawGroupDir
-
03-07-2021 - |
Question
I am using StringTemplate v4.05 to build my web application.
As I am using STRawGroupDir
, I do not define something like init(v) :: ...
in each .st
Currently I can successfully render the sub-template like below: ('$' is my delimiter )
$/elements/test()$
But when test.st is like below
<div>Hello $name$</div>
I do not know how to pass the argument to $name$. My target is like below
$/elements/test(["Cavid"])$
$/elements/test(["Daniel"])$
$/elements/test(["Candy"])$
Solution
When using STRawGroupDir
and template has only one placeholder, it can be referred to as it
.
In your case test.st would be
<div>Hello $it$</div>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow