I'd like to execute template with noescape
and no quotes, but noescape
is not supported now.
Any suggestion or do I have to use another template engine? Thank you!
Code here: http://play.golang.org/p/R-Ib5H9bXx
I'd like to execute template with noescape
and no quotes, but noescape
is not supported now.
Any suggestion or do I have to use another template engine? Thank you!
Code here: http://play.golang.org/p/R-Ib5H9bXx
You are encouraged to store safe Javascript in the type template.JS
:
type JS string
JS encapsulates a known safe EcmaScript5 Expression, for example,
(x + y * z())
. Template authors are responsible for ensuring that typed expressions do not break the intended precedence and that there is no statement/expression ambiguity as when passing an expression like "{ foo: bar() } 'foo'", which is both a valid Expression and a valid Program with a very different meaning.
So, the only change you need to do to your code is:
type Var struct {
Name template.JS
Value template.JS
}