Escape sequence in set function

dervoudi February 6, 2017

Hi,

how do I escape characters in the set function?

E.g.  I would like to store a complete javascript function in a variable and then call it later in the template. But as soon as I use "{" in the variable, the script won't work.

Is there an escape sequence for special characters?

 

This works:

${set(myFunction,"v=2*w;v.toString()")}
%{var w=4;${myFunction}}

 

This doesn't work:

${set(myFunction,"function retVal(w){var v=2*w;return v.toString()}"}
%{${myFunction} var w=4;retVal(w)}

1 answer

1 vote
Rui Rodrigues
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.
February 7, 2017

Hi @Waldemar Friesen,

A ")" is missing on myFunction definition.

Try this:

${set(myFunction,"function retVal(w){var v=2*w;return v.toString()}")}
%{${myFunction} var w=4;retVal(w)}
Chers,
Rui Rodrigues.
dervoudi February 8, 2017

Hi @Rui Rodrigues,

thanks for the quick reply. Sorry for the misspelling. In my test environment the syntax was correct. I tried to copy the code into the comment field, but it always tried to open a new page instead of pasting it into the field... So I had to write it manually and forgot the closing bracket.

This means: It still does not work. As soon as you type an "{" in your variable value, xporter breaks processing.

 

Simple example:

Line to process: "String without brackets"
${set(varWithoutBrackets,"String without brackets")}
Print out from Variable: ${varWithoutBrackets}
Line to process: "String {with} brackets"
${set(varWithBrackets,"String {with} brackets")}
Print out from Variable: ${varWithBrackets}

 

Result:

 error.PNG

 

I think this is a bug. Either there should be an escape sequence for special characters or xporter should not try to evaluate variable values.

Regards,

Waldemar Friesen

 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events