Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Ignore whitespace in tags {{ like_this }}.

  • Loading branch information...
commit 1f436bd47bfe31faf620734aaee1cdcb4ea9117d 1 parent 7a8dcd8
@pmcelhaney authored
Showing with 15 additions and 2 deletions.
  1. +2 −2 CFStache.cfc
  2. +13 −0 Tests.cfc
View
4 CFStache.cfc
@@ -22,7 +22,7 @@
<cfset var matches = arrayNew(1) />
<cfloop condition = "true" >
- <cfset matches = ReFindNoCaseValues(template, "\{\{(##)(\w+)}}(.*?)\{\{/\2\}\}")>
+ <cfset matches = ReFindNoCaseValues(template, "\{\{(##)\s*(\w+)\s*}}(.*?)\{\{/\s*\2\s*\}\}")>
<cfif arrayLen(matches) eq 0>
<cfbreak>
</cfif>
@@ -63,7 +63,7 @@
<cfset var matches = arrayNew(1) />
<cfloop condition = "true" >
- <cfset matches = ReFindNoCaseValues(template, "\{\{(!|\{|&)?(\w+)\}?\}\}") />
+ <cfset matches = ReFindNoCaseValues(template, "\{\{(!|\{|&)?\s*(\w+)\s*\}?\}\}") />
<cfif arrayLen(matches) eq 0>
<cfbreak>
</cfif>
View
13 Tests.cfc
@@ -99,6 +99,19 @@
<cfset template = "Hello, {{&thing}}!" />
<cfset context = { thing = '<b>world</b>'} />
<cfset expected = "Hello, <b>world</b>!" />
+ </cffunction>
+
+ <cffunction name="ignoreWhitespace">
+ <cfset template = "Hello, {{ thing }}!" />
+ <cfset context = { thing = 'world'} />
+ <cfset expected = "Hello, world!" />
+ </cffunction>
+
+
+ <cffunction name="ignoreWhitespaceInSection">
+ <cfset template = "Ready {{## set }}set {{/ set }}go!" />
+ <cfset context = { set = true } />
+ <cfset expected = "Ready set go!" />
</cffunction>
</cfcomponent>
Please sign in to comment.
Something went wrong with that request. Please try again.