Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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...
commit ea8a35bad6ca3482308f9912a7977bd971ab095b 1 parent 1b94c54
Patrick McElhaney authored July 07, 2010
1  .gitignore
... ...
@@ -0,0 +1 @@
  1
+mxunit
4  Tests.cfc
... ...
@@ -1,4 +0,0 @@
1  
-<cfcomponent output="false" extends="mxunit.framework.TestSuite">
2  
-  <cfset addAll("RenderTests")>
3  
-  <cfset addAll("WinnerTest") />
4  
-</cfcomponent>
3  Winner.cfc
... ...
@@ -1,3 +0,0 @@
1  
-<cfcomponent extends="Mustache">
2  
-  
3  
-</cfcomponent>
5  Mustache.cfc → mustache/Mustache.cfc
@@ -6,7 +6,7 @@
6 6
   </cffunction>
7 7
   
8 8
   <cffunction name="render" output="false">
9  
-    <cfargument name="template" default="#readMustacheFile(getMetaData(this).name)#"/>
  9
+    <cfargument name="template" default="#readMustacheFile(listRest(getMetaData(this).name, '.'))#"/>
10 10
     <cfargument name="context" default="#this#"/>
11 11
     <cfset template = renderSections(template, context) />
12 12
     <cfreturn renderTags(template, context)/>
@@ -114,8 +114,9 @@
114 114
   <cffunction name="readMustacheFile" access="private" output="false">
115 115
     <cfargument name="filename" />                                   
116 116
     <cfset var template="" />
117  
-    <cffile action="read" file="#getDirectoryFromPath(getCurrentTemplatePath())##filename#.mustache" variable="template"/>
  117
+    <cffile action="read" file="#getDirectoryFromPath(getMetaData(this).path)##filename#.mustache" variable="template"/>   
118 118
     <cfreturn trim(template)/>
  119
+		<cfreturn getDirectoryFromPath(getMetaData(this).path) />
119 120
   </cffunction>
120 121
   
121 122
   <cffunction name="get" access="private" output="false">
0  Filter.cfc → tests/Filter.cfc
File renamed without changes
0  Person.cfc → tests/Person.cfc
File renamed without changes
6  RenderTests.cfc → tests/RenderTests.cfc
... ...
@@ -1,7 +1,7 @@
1 1
 <cfcomponent extends="mxunit.framework.TestCase">
2 2
   
3 3
   <cffunction name="setup">
4  
-    <cfset stache = createObject("component", "Mustache").init()/>
  4
+    <cfset stache = createObject("component", "mustache.Mustache").init()/>
5 5
   </cffunction>
6 6
   
7 7
   <cffunction name="tearDown">
@@ -146,7 +146,9 @@
146 146
     <cfset expected = "Hello, <b>world</b>." />
147 147
   </cffunction>
148 148
   
149  
-  <cffunction name="partial">
  149
+  <cffunction name="partial">                       
  150
+	  <!--- using a subclass so that it will look for the partial in this directory --->
  151
+		<cfset stache = createObject("component", "Winner").init()/>   
150 152
     <cfset context = { word = 'Goodnight', name = 'Gracie' } />
151 153
     <cfset template = "<ul><li>Say {{word}}, {{name}}.</li><li>{{> gracie_allen}}</li></ul>" />
152 154
     <cfset expected = "<ul><li>Say Goodnight, Gracie.</li><li>Goodnight</li></ul>" />  
4  tests/Tests.cfc
... ...
@@ -0,0 +1,4 @@
  1
+<cfcomponent output="false" extends="mxunit.framework.TestSuite">      
  2
+  <cfset addAll("tests.RenderTests")>
  3
+  <cfset addAll("tests.WinnerTest") />
  4
+</cfcomponent>
3  tests/Winner.cfc
... ...
@@ -0,0 +1,3 @@
  1
+<cfcomponent extends="mustache.Mustache">
  2
+  
  3
+</cfcomponent>
0  Winner.mustache → tests/Winner.mustache
File renamed without changes
0  WinnerTest.cfc → tests/WinnerTest.cfc
File renamed without changes
0  gracie_allen.mustache → tests/gracie_allen.mustache
File renamed without changes

0 notes on commit ea8a35b

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