Permalink
Browse files

{{&ampersand}} can also be used to prevent HTML escaping.

  • Loading branch information...
1 parent d113ddb commit 7a8dcd857cd3170c0a2fcdb2322ec127065be459 @pmcelhaney committed May 28, 2010
Showing with 7 additions and 3 deletions.
  1. +2 −2 CFStache.cfc
  2. +5 −1 Tests.cfc
View
@@ -63,7 +63,7 @@
<cfset var matches = arrayNew(1) />
<cfloop condition = "true" >
- <cfset matches = ReFindNoCaseValues(template, "\{\{(!|\{)?(\w+)\}?\}\}") />
+ <cfset matches = ReFindNoCaseValues(template, "\{\{(!|\{|&)?(\w+)\}?\}\}") />
<cfif arrayLen(matches) eq 0>
<cfbreak>
</cfif>
@@ -81,7 +81,7 @@
<cfargument name="context" />
<cfif type eq "!">
<cfreturn "" />
- <cfelseif type eq "{">
+ <cfelseif type eq "{" or type eq "&">
<cfreturn get(tagName, context) />
<cfelse>
<cfreturn htmlEditFormat(get(tagName, context)) />
View
@@ -95,6 +95,10 @@
<cfset expected = "Hello, <b>world</b>!" />
</cffunction>
-
+ <cffunction name="dontEscapeWithAmpersand">
+ <cfset template = "Hello, {{&thing}}!" />
+ <cfset context = { thing = '<b>world</b>'} />
+ <cfset expected = "Hello, <b>world</b>!" />
+ </cffunction>
</cfcomponent>

0 comments on commit 7a8dcd8

Please sign in to comment.