Sometimes it's necessary to put CSP tags inside JS tags, like:
#[ new test set test = "BLAH" ]#
<script>
var foo = "Hello world";
<csp:if condition='test="BLAH"'>
var billy = "#(test)#";
</csp:if>
</script>
#[ kill test ]#
... Unfortunately, that's not gonna work. Here's the output:
<script>
var foo = "Hello world";
<csp:if condition='test="BLAH"'>
var billy = "BLAH";
</csp:if>
</script>
By tricking the compiler (using #("<")#
), we can get it to work:
#[ new test set test = "BLAH" ]#
#("<")#script>
var foo = "Hello world";
<csp:if condition='test="BLAH"'>
var billy = "#(test)#";
console.log(billy);
<csp:else>
console.log('It didn\' work none. :(');
</csp:if>
</script>
#[ kill test ]#
... and here's the output:
<script>
var foo = "Hello world";
var billy = "BLAH";
console.log(billy);
</script>
Yay!