Skip to main content
Skip table of contents

EscapeVar: Escape variable value for Javascript or XML compatibility

Tag: EcapeVar

The action EscapeVar function assigns a value to a variable (like SetVar) after having escaped its value according to target platform.

EscapeVar can process several variables at once

Detailed Description

Javascript (JS) and XML formulas assigned to a variable need to be escaped to be compatible with the interpretation engine. 

Tag Attributes

AttributesValue Description
Variable NameAny unreserved name valid in XML. Reserved names are listed on: Variables
Variable ValueAny string or number to escape
CRLFReplacement for CR,,LF or CRLF. If not supplied, CR and LF will be removed
TypeTarget platform type - Required
Accepted values:

Example Scripts

<EscapeVar ESCAPEDtext="{%FormattedText%}" type="JS"/>
	<calcvar FormattedText='USE_CDATA'>
		var str = '\tName\n\tValue\n\tType\n\n';
	<echo value="FormattedText: {%FormattedText%}"/>
	<EscapeVar ESCAPEDtext="{%FormattedText%}" type="JS"/>
	<calcvar JSCalculated='USE_CDATA'>
		<![CDATA[var str = '{%ESCAPEDtext%}' + '\tConvoy 2022\n\n';
	<echo value="Returned from JS: {%JSCalculated%}"/>
	<!--calcvar v_ErrorText='USE_CDATA'>
		rgx = /\[.*\]:\n([^\n]*\n).*/gs;
		var str = `{%ErrorAction%}`;
	<echo value="{%v_ErrorText%}"/-->
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.