Permalink
Browse files

Split up into mustache/ and tests/ directories. That revealed a coupl…

…e of bugs related to finding .mustache files that I had to fix.
  • Loading branch information...
1 parent 1b94c54 commit ea8a35bad6ca3482308f9912a7977bd971ab095b @pmcelhaney committed Jul 7, 2010
View
1 .gitignore
@@ -0,0 +1 @@
+mxunit
View
4 Tests.cfc
@@ -1,4 +0,0 @@
-<cfcomponent output="false" extends="mxunit.framework.TestSuite">
- <cfset addAll("RenderTests")>
- <cfset addAll("WinnerTest") />
-</cfcomponent>
View
3 Winner.cfc
@@ -1,3 +0,0 @@
-<cfcomponent extends="Mustache">
-
-</cfcomponent>
View
5 Mustache.cfc → mustache/Mustache.cfc
@@ -6,7 +6,7 @@
</cffunction>
<cffunction name="render" output="false">
- <cfargument name="template" default="#readMustacheFile(getMetaData(this).name)#"/>
+ <cfargument name="template" default="#readMustacheFile(listRest(getMetaData(this).name, '.'))#"/>
<cfargument name="context" default="#this#"/>
<cfset template = renderSections(template, context) />
<cfreturn renderTags(template, context)/>
@@ -114,8 +114,9 @@
<cffunction name="readMustacheFile" access="private" output="false">
<cfargument name="filename" />
<cfset var template="" />
- <cffile action="read" file="#getDirectoryFromPath(getCurrentTemplatePath())##filename#.mustache" variable="template"/>
+ <cffile action="read" file="#getDirectoryFromPath(getMetaData(this).path)##filename#.mustache" variable="template"/>
<cfreturn trim(template)/>
+ <cfreturn getDirectoryFromPath(getMetaData(this).path) />
</cffunction>
<cffunction name="get" access="private" output="false">
View
0 Filter.cfc → tests/Filter.cfc
File renamed without changes.
View
0 Person.cfc → tests/Person.cfc
File renamed without changes.
View
6 RenderTests.cfc → tests/RenderTests.cfc
@@ -1,7 +1,7 @@
<cfcomponent extends="mxunit.framework.TestCase">
<cffunction name="setup">
- <cfset stache = createObject("component", "Mustache").init()/>
+ <cfset stache = createObject("component", "mustache.Mustache").init()/>
</cffunction>
<cffunction name="tearDown">
@@ -146,7 +146,9 @@
<cfset expected = "Hello, <b>world</b>." />
</cffunction>
- <cffunction name="partial">
+ <cffunction name="partial">
+ <!--- using a subclass so that it will look for the partial in this directory --->
+ <cfset stache = createObject("component", "Winner").init()/>
<cfset context = { word = 'Goodnight', name = 'Gracie' } />
<cfset template = "<ul><li>Say {{word}}, {{name}}.</li><li>{{> gracie_allen}}</li></ul>" />
<cfset expected = "<ul><li>Say Goodnight, Gracie.</li><li>Goodnight</li></ul>" />
View
4 tests/Tests.cfc
@@ -0,0 +1,4 @@
+<cfcomponent output="false" extends="mxunit.framework.TestSuite">
+ <cfset addAll("tests.RenderTests")>
+ <cfset addAll("tests.WinnerTest") />
+</cfcomponent>
View
3 tests/Winner.cfc
@@ -0,0 +1,3 @@
+<cfcomponent extends="mustache.Mustache">
+
+</cfcomponent>
View
0 Winner.mustache → tests/Winner.mustache
File renamed without changes.
View
0 WinnerTest.cfc → tests/WinnerTest.cfc
File renamed without changes.
View
0 gracie_allen.mustache → tests/gracie_allen.mustache
File renamed without changes.

0 comments on commit ea8a35b

Please sign in to comment.