How do i print a variable in the layout templates without having the output encased in quotes

eyrisone August 14, 2014

Hi there.

I'm sure this question has a simple solution. Googling hasn't yielded any results.

I've gone into Confluence > Admin > Layouts and attempted to edit the code diretly to achieve some functionality my company is looking for. I've created variables and output them successfully.

Unfortunately, whenever the variable prints on the page, it is surrounded in quotes ony visible in the source code. This breaks any HTML output that I'm trying to put in.

Specifically:

#set( $foo = "<p>Hello World</p>" )
$foo

...will output "<p>Hello World</p>" without the quotes on the page, and " <p>Hello World</p> " with the quotes in HTML.

What am I missing? How can I get it to output just the string so that the HTML parser will recognize it?

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
eyrisone August 20, 2014

Solution: Add ""WithHtml" to the viarable name. So "$foo" becomes "$fooWithHtml".

1 vote
Alexey_Rjeutski__Polontech_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 14, 2014

Please try to put #disable_html_escaping() before you use set directive. Please note that it will bring you potential security vulnerabilities.

eyrisone August 20, 2014

Thanks for the quick response Alexi.

I actually ended up appending my variable names with "WithHtml" and that fixed it.

so...

#set( $fooWithHtml = "<p>Hello World</p>" )

$fooWithHtml

...now outputs...

"Hello World" on the page and "<p>Hello World</p>" without the quotes in the code.

TAGS
AUG Leaders

Atlassian Community Events