Including literal JSON content in Velocity (avoiding HTML screens)

I am trying to use the Velocity engine built into Atlassian products (and exposed through com.atlassian.templaterenderer) to substitute the JSON value in the template.

In the template, it looks something like this:

<script>
  foo = $foo
</script>

However, when I draw a template with "foo" matched to a string ["bar", "baz"], the output is as follows:

<script>
  foo = [&quot;bar&quot;, &quot;baz&quot;]
</script>

How can this be avoided?

+3
source share
2 answers

Atlassian has an event handler that escapes any variable with a name that does not end with WithHtml.

In this way:

<script>
foo = $fooWithHtml
</script>

expands at will.

+4
source

, , EscapeHtmlReference, velocity.properties, java. .

+1

All Articles