Permalink
Browse files

use listlast instead of listrest to mustache file from metadata name

closes issue 2
  • Loading branch information...
1 parent 063b411 commit 7cae8818dd60130e4f92f06da6fae5a6f07a8f41 @rip747 rip747 committed Oct 1, 2011
View
@@ -35,7 +35,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
</cffunction>
<cffunction name="render" output="false">
- <cfargument name="template" default="#readMustacheFile(listRest(getMetaData(this).name, '.'))#"/>
+ <cfargument name="template" default="#readMustacheFile(ListLast(getMetaData(this).name, '.'))#"/>
<cfargument name="context" default="#this#"/>
<cfset template = renderSections(template, context) />
<cfreturn renderTags(template, context)/>
View
@@ -1,4 +1,5 @@
<cfcomponent output="false" extends="mxunit.framework.TestSuite">
<cfset addAll("tests.RenderTests")>
<cfset addAll("tests.WinnerTest") />
+<cfset addAll("tests.one.two.three.WinnerTest") />
</cfcomponent>
@@ -0,0 +1,3 @@
+<cfcomponent extends="mustache.Mustache">
+
+</cfcomponent>
@@ -0,0 +1,5 @@
+Hello {{name}}
+You have just won ${{value}}!
+{{#in_ca}}
+Well, ${{taxed_value}}, after taxes.
+{{/in_ca}}
@@ -0,0 +1,17 @@
+<cfcomponent extends="mxunit.framework.TestCase">
+ <cffunction name="canonincalExample">
+ <cfset winner = createObject("component", "Winner").init()/>
+ <cfset winner.name = "Patrick" />
+ <cfset winner.value = 10000 />
+ <cfset winner.taxed_value = 10000 - 10000 * 0.4/>
+ <cfset winner.in_ca = true />
+ <!--- TODO: Technically, there shouldn't be newlines after "$10000!" and "taxes." (going by the ctemplate spec) --->
+ <cfset expected = "Hello Patrick
+You have just won $10000!
+
+Well, $6000, after taxes.
+" />
+ <cfset assertEquals(expected, winner.render()) />
+ </cffunction>
+
+</cfcomponent>

0 comments on commit 7cae881

Please sign in to comment.