Permalink
Browse files

If a tag references a function rather than a variable, call the funct…

…ion.
  • Loading branch information...
1 parent 8c2d7e5 commit 1f1a9f788a73e8a8797cffc89f73df317fc43506 @pmcelhaney committed May 29, 2010
Showing with 23 additions and 2 deletions.
  1. +5 −1 Mustache.cfc
  2. +9 −0 Person.cfc
  3. +9 −1 Tests.cfc
View
@@ -93,7 +93,11 @@
<cfargument name="key" />
<cfargument name="context"/>
<cfif isStruct(context) && structKeyExists(context, key) >
- <cfreturn context[key] />
+ <cfif isSimpleValue(context[key]) or isStruct(context[key]) or isQuery(context[key])>
+ <cfreturn context[key]/>
+ <cfelse>
+ <cfreturn evaluate("context.#key#()")>
+ </cfif>
<cfelseif isQuery(context)>
<cfreturn context[key][context.currentrow] />
<cfelse>
View
@@ -0,0 +1,9 @@
+<cfcomponent>
+
+ <cfset this.firstname = "John" />
+ <cfset this.lastname = "Smith" />
+
+ <cffunction name="fullName" >
+ <cfreturn "#this.firstname# #this.lastname#" />
+ </cffunction>
+</cfcomponent>
View
@@ -124,7 +124,15 @@
<cfset template = "Ready {{## set }}set {{/ set }}go!" />
<cfset context = { set = true } />
<cfset expected = "Ready set go!" />
- </cffunction>
+ </cffunction>
+
+ <cffunction name="callAFunction">
+ <cfset context = createObject("component", "Person")/>
+ <cfset context.firstname = "Chris" />
+ <cfset context.lastname = "Wanstrath" />
+ <cfset template = "Mustache was created by {{fullname}}." />
+ <cfset expected = "Mustache was created by Chris Wanstrath." />
+ </cffunction>

0 comments on commit 1f1a9f7

Please sign in to comment.