How to create a speed template that displays two "#" litterals at the beginning of a line?

I need to create a high-speed document with several lines with the prefix ยจ ## Foo ", but since the command #is a speed directive, it does not work for me.

I want my output to look like this:

## Foo this
## Bar that
k1, v1
k2, v2
k3, v3

Escaping did not work out as I expected. The following does not work, obviously, since it is #not reset):

## Foo this
## Bar that
#foreach( $foo in $bar )
$foo.key, $foo.value
#end

Lines ## are not displayed - again, as expected. But my attempts to escape do not work either. Shielding solution one:

\## Foo this
\## Bar that
#foreach( $foo in $bar )
$foo.key, $foo.value
#end

or this, avoiding solution two:

\#\# Foo this
\#\# Bar that
#foreach( $foo in $bar )
$foo.key, $foo.value
#end

or even that ...

# set($msg = "##") 
$msg Foo this
$msg Bar that
#foreach( $foo in $bar )
$foo.key, $foo.value
#end

This last one really confused me.

Any ideas?

+3
source share
4

Sigh.... . :

#set($msg = '##') 
$msg Foo this

, :

## Foo this

:

, . , "Hello $name"

( , \#\# .)

+3

:

${esc.h}${esc.h}
+4

org.apache.velocity.tools.generic.EscapeTool , :

#set($msg = "#") 
${msg}${msg} Foo this
+3

"##" - VTL, , , .

## This is a comment
-1

Source: https://habr.com/ru/post/1705345/


All Articles