<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -62,19 +62,6 @@ Context.prototype.runAction = function runAction(captures, action) {
     data.juice = this.helpers;
     data.juice.urlFor = this.urlFor.bind(this);
 
-    const fs = require('filesystem-base');
-
-    var templates = JSON.parse( fs.rawOpen( this.docRoot + 'conf/templates.json' ).readWhole() );
-
-    for ( let ext in templates ) {
-      let path = this.docRoot + 'templates/' + action.render + '.' + ext;
-      if ( fs.isFile( path ) ) {
-        var t = fs.rawOpen( path, 'r' ).readWhole();
-        var body = require( templates[ ext ] ).render( data, t )
-        break;
-      }
-    }
-
     if ( body === undefined )
       throw &quot;Couldn't find template file to load&quot;;
 
@@ -117,3 +104,23 @@ Context.prototype.buildParams = function buildParams() {
   this.params = store.params;
 }
 
+Context.prototype.renderTemplate = function( file, stash ) {
+  // load templates config or default to TT if not available
+  var conf = this.config( 'templates' ) || { &quot;tt&quot; : &quot;Template&quot; };
+
+  const fs = require('filesystem-base');
+
+  for ( let ext in conf ) {
+    // build the path to the template using the extension from conf
+    var path = this.docRoot + 'templates/' + file + '.' + ext;
+
+    // if the template exists, render it with the right engine and return
+    if ( fs.isFile( path ) ) {
+      let template = fs.rawOpen( path, 'r' ).readWhole();
+      let engine = require( conf[ ext ] );
+      return engine.render( stash, template );
+    }
+  }
+
+  throw &quot;Template not found&quot;;
+}</diff>
      <filename>lib/juice/context.js</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>9b604007a48bab5b7cdd72017f67fab0ade4203e</id>
    </parent>
  </parents>
  <author>
    <name>Dominic Baggott</name>
    <email>dominic.baggott@gmail.com</email>
  </author>
  <url>http://github.com/ashb/juice/commit/5e88644b0dac9b6f6086a38386d08b2a68ca9f41</url>
  <id>5e88644b0dac9b6f6086a38386d08b2a68ca9f41</id>
  <committed-date>2009-10-31T18:16:32-07:00</committed-date>
  <authored-date>2009-10-31T18:16:32-07:00</authored-date>
  <message>Refactor template rendering to its own method</message>
  <tree>a3370067374006fec8e65d2972a3b18c83f573dd</tree>
  <committer>
    <name>Dominic Baggott</name>
    <email>dominic.baggott@gmail.com</email>
  </committer>
</commit>
