Skip to content
Browse files

Created an isFunction() function. It's pretty naive, but now that I'v…

…e encapsulated that logic I can fill in a better implementation when I know how.
  • Loading branch information...
1 parent f5702cc commit 2aa97481c7da089f646a54c539dc53e92de07552 @pmcelhaney committed May 28, 2010
Showing with 11 additions and 6 deletions.
  1. +11 −6 Mustache.cfc
View
17 Mustache.cfc
@@ -49,7 +49,7 @@
<cfset result &= render(inner, ctx) /> <!--- should probably use StringBuilder for performance --->
</cfloop>
<cfreturn result/>
- <cfelseif not isSimpleValue(context[tagName])>
+ <cfelseif isFunction(context[tagName])>
<cfreturn evaluate("context.#tagName#(inner)") />
<cfelseif ctx xor type eq "^">
<cfreturn inner />
@@ -95,18 +95,23 @@
<cfargument name="key" />
<cfargument name="context"/>
<cfif isStruct(context) && structKeyExists(context, key) >
- <cfif isSimpleValue(context[key]) or isStruct(context[key]) or isQuery(context[key])>
- <cfreturn context[key]/>
- <cfelse>
- <cfreturn evaluate("context.#key#('')")>
+ <cfif isFunction(context[key])>
+ <cfreturn evaluate("context.#key#('')")>
+ <cfelse>
+ <cfreturn context[key]/>
</cfif>
<cfelseif isQuery(context)>
<cfreturn context[key][context.currentrow] />
<cfelse>
<cfreturn "" />
</cfif>
</cffunction>
-
+
+ <cffunction name="isFunction" access="private">
+ <cfargument name="object" />
+ <cfreturn not (isSimpleValue(object) or isStruct(object) or isQuery(object)) />
+ </cffunction>
+
<cffunction
name="ReFindNoCaseValues"
access="private"

0 comments on commit 2aa9748

Please sign in to comment.
Something went wrong with that request. Please try again.