<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -35,6 +35,28 @@ function path()
 }
 
 /**
+ * Convenience method to find file in a given array of directories.
+ * @param string $filename
+ * @param array $paths
+ * @return string Found file path or FALSE
+ */
+function find($filename, $paths)
+{
+    if ($filename and is_array($paths))
+    {
+        foreach ($paths as $path)
+        {
+            $fullpath = $path.DIRECTORY_SEPARATOR.$filename;
+            if (file_exists($fullpath))
+            {
+                return $fullpath;
+            }
+        }
+    }
+    return FALSE;
+}
+
+/**
  * Convenience method to determine if this script was initiated by an
  * XMLHTTPRequest (AJAX)
  * @return boolean TRUE if called by AJAX</diff>
      <filename>minim.php</filename>
    </modified>
    <modified>
      <diff>@@ -3,7 +3,7 @@
 &lt;?php $this-&gt;load_helpers('logged_in_user') ?&gt;
 
 &lt;?php $this-&gt;set('meta') ?&gt;
-  &lt;link rel=&quot;shortcut icon&quot; type=&quot;image/gif&quot; href=&quot;&lt;?php echo minim()-&gt;webroot ?&gt;/images/favicon.gif&quot;&gt;
+  &lt;link rel=&quot;shortcut icon&quot; type=&quot;image/gif&quot; href=&quot;&lt;?php $this-&gt;asset_url('/images/favicon.gif') ?&gt;&quot;&gt;
 &lt;?php $this-&gt;get('page_meta') ?&gt;
 &lt;?php $this-&gt;end() ?&gt;
 
@@ -27,7 +27,7 @@
 &lt;?php $this-&gt;set('content') ?&gt;
   &lt;div id=&quot;wrapper&quot;&gt;
    &lt;div id=&quot;masthead&quot;&gt;
-    &lt;h1&gt;Minim Admin&lt;/div&gt;
+    &lt;h1&gt;Minim Admin&lt;/h1&gt;
     &lt;div class=&quot;logged_in&quot;&gt;
 &lt;?php if ($user = logged_in_user()): ?&gt;
      Logged in as &lt;strong&gt;&lt;?php echo $user['name'] ?&gt;&lt;/strong&gt; - &lt;a href=&quot;&lt;?php echo minim('routing')-&gt;url_for('logout') ?&gt;&quot;&gt;Log out&lt;/a&gt;</diff>
      <filename>plugins/admin/templates/admin_base.php</filename>
    </modified>
    <modified>
      <diff>@@ -56,8 +56,14 @@ if (strtolower($_SERVER['REQUEST_METHOD']) == 'post')
     }
 }
 
-minim('templates')-&gt;render('model-edit', array(
-    'model_name' =&gt; $model_name,
-    'form' =&gt; $form,
-    'errors' =&gt; $errors
-));
+minim('templates')-&gt;render(
+    array(
+        &quot;{$model_name}-edit&quot;,
+        'model-edit'
+    ),
+    array(
+        'model_name' =&gt; $model_name,
+        'form' =&gt; $form,
+        'errors' =&gt; $errors
+    )
+);</diff>
      <filename>plugins/admin/views/admin-model-edit.php</filename>
    </modified>
    <modified>
      <diff>@@ -1,10 +1,10 @@
 &lt;?php
-class Minim_New_Forms implements Minim_Plugin // {{{
+class Minim_New_Forms implements Minim_Plugin
 {
     var $_widget_types;
     var $widget_paths;
 
-    function Minim_New_Forms() // {{{
+    function Minim_New_Forms()
     {
         $file = realpath(__FILE__);
         $this-&gt;_widget_types = array(
@@ -21,25 +21,25 @@ class Minim_New_Forms implements Minim_Plugin // {{{
             // TODO - add more default widgets
         );
         $this-&gt;widget_paths = array();
-    } // }}}
+    }
 
     /**
      * Register a widget type 
      */
-    function register_widget_type($type, $file, $class_name) // {{{
+    function register_widget_type($type, $file, $class_name)
     {
         $this-&gt;_widget_types[$type] = array(
             'file' =&gt; $file,
             'class' =&gt; $class_name
         );
-    } // }}}
+    }
 
-    function create() // {{{
+    function create()
     {
         return new Minim_Form($this);
-    } // }}}
+    }
 
-    function from_model($manager, $model=NULL) // {{{
+    function from_model($manager, $model=NULL)
     {
         $form = new Minim_Form($this);
         try
@@ -53,28 +53,24 @@ class Minim_New_Forms implements Minim_Plugin // {{{
         }
         foreach ($manager-&gt;_fields as $name =&gt; $field)
         {
-            # try to get a widget for the form field:
-            # 1. see if there's a suggested widget in the model field
-            # 2. if not, go with a default text field
-            # widgets can be overridden later
-            $widget = 'text';
-            if (isset($field-&gt;widget) and $field-&gt;widget)
-            {
-                $widget = $field-&gt;widget;
-            }
+            // try to get a widget for the form field:
+            // widgets can be overridden later
+            $widget = $field-&gt;widget();
 
-            # add a form field
-            # TODO - add field params as argument
-            $form-&gt;$widget($name, array(
-                'label' =&gt; ucfirst($name)
+            // add a form field
+            $form-&gt;$widget($name, array_merge(
+                array(
+                    'label' =&gt; ucfirst($name)
+                ),
+                $field-&gt;params
             ));
         }
         error_log(print_r($form, TRUE));
         return $form;
-    } // }}}
-} // }}}
+    }
+}
 
-class Minim_Form // {{{
+class Minim_Form
 {
     var $_forms;
     var $_fields;
@@ -82,19 +78,19 @@ class Minim_Form // {{{
     var $method;
     var $attrs;
 
-    function Minim_Form(&amp;$fo, $action='', $method='POST', $attrs=array()) // {{{
+    function Minim_Form(&amp;$fo, $action='', $method='POST', $attrs=array())
     {
         $this-&gt;_forms =&amp; $fo;
         $this-&gt;submit_url = $action;
         $this-&gt;method = $method;
         $this-&gt;attrs = $attrs;
         $this-&gt;_fields = array();
-    } // }}}
+    }
 
     /**
      * Check for form data matching this form's fields in the request
      */
-    function was_submitted() // {{{
+    function was_submitted()
     {
         $data = $GLOBALS[&quot;_{$this-&gt;method}&quot;];
         
@@ -114,12 +110,12 @@ class Minim_Form // {{{
         }
         $this-&gt;populate($submission);
         return TRUE;
-    } // }}}
+    }
 
     /**
      * Validate form submission
      */
-    function is_valid() // {{{
+    function is_valid()
     {
         foreach ($this-&gt;_fields as &amp;$field)
         {
@@ -129,23 +125,23 @@ class Minim_Form // {{{
             }
         }
         return TRUE;
-    } // }}}
+    }
 
     /**
      * Set a form's values to those in the specified array
      */
-    function populate($data) // {{{
+    function populate($data)
     {
         foreach ($this-&gt;_fields as $field)
         {
             $field-&gt;value = $data[$field-&gt;name];
         }
-    } // }}}
+    }
 
     /**
      * Enable syntactic sugar for adding fields to a form.
      */
-    function &amp;__call($name, $params) // {{{
+    function &amp;__call($name, $params)
     {
         if (array_key_exists($name, $this-&gt;_forms-&gt;_widget_types))
         {
@@ -158,12 +154,12 @@ class Minim_Form // {{{
             $this-&gt;add_field($name, $field_name, $params);
         }
         return $this;
-    } // }}}
+    }
 
     /**
      * Add a field to a form
      */
-    function add_field($widget, $name, $params) // {{{
+    function add_field($widget, $name, $params)
     {
         $widgets = $this-&gt;_forms-&gt;_widget_types;
         if (array_key_exists($widget, $widgets))
@@ -181,18 +177,18 @@ class Minim_Form // {{{
             ));
             $this-&gt;_fields[$name] = new $widgets[$widget]['class']($params);
         }
-    } // }}}
+    }
 
-    function __get($name) // {{{
+    function __get($name)
     {
         if (array_key_exists($name, $this-&gt;_fields))
         {
             return $this-&gt;_fields[$name];
         }
         return NULL;
-    } // }}}
+    }
 
-    function render() // {{{
+    function render()
     {
         $fields = '';
         foreach ($this-&gt;_fields as $field)
@@ -204,58 +200,64 @@ class Minim_Form // {{{
     {$fields}
 &lt;/form&gt;
 HTML;
-    } // }}}
-} // }}}
+    }
+} 
 
-class Minim_Form_Field // {{{
+class Minim_Form_Field
 {
     var $name;
     var $type;
     var $label;
+    var $max_length;
     var $help;
     var $value;
     var $initial_value;
     var $form;
 
-    function __construct($params=array()) // {{{
+    function __construct($params=array())
     {
         $this-&gt;name = $params['name'];
         $this-&gt;type = 'text';
         $this-&gt;form =&amp; $params['form'];
-        foreach (array('label', 'help', 'value', 'initial_value') as $var)
+        foreach (array('label', 'help', 'value', 'initial_value', 'max_length') as $var)
         {
             $this-&gt;$var = @$params[$var] ? $params[$var] : '';
         }
         $this-&gt;_validation_method = @$params['validate'];
-    } // }}}
+    }
 
-    function render_label() // {{{
+    function render_label()
     {
         return &lt;&lt;&lt;HTML
 &lt;label for=&quot;{$this-&gt;name}_field&quot;&gt;{$this-&gt;label}&lt;/label&gt;
 HTML;
-    } // }}}
+    }
 
-    function render_field() // {{{
+    function render_field()
     {
         $value_attr = '';
         if ($this-&gt;value)
         {
             $value_attr = ' value=&quot;'.$this-&gt;value.'&quot;';
         }
+        $max_length = '';
+        if (@$this-&gt;max_length)
+        {
+            $max_length = ' maxlength=&quot;'.$this-&gt;max_length.'&quot;';
+        }
         return &lt;&lt;&lt;HTML
-&lt;input type=&quot;text&quot; name=&quot;{$this-&gt;name}&quot; id=&quot;{$this-&gt;name}_field&quot;{$value_attr}&gt;
+&lt;input type=&quot;text&quot; name=&quot;{$this-&gt;name}&quot; id=&quot;{$this-&gt;name}_field&quot;{$value_attr}{$max_length}&gt;
 HTML;
-    } // }}}
+    }
 
-    function render_help() // {{{
+    function render_help()
     {
         return &lt;&lt;&lt;HTML
-&lt;p class=&quot;formfield_help&quot;&gt;{$this-&gt;help}&lt;/p&gt;
+&lt;p class=&quot;help&quot;&gt;{$this-&gt;help}&lt;/p&gt;
 HTML;
-    } // }}}
+    }
 
-    function render_as_div() // {{{
+    function render_as_div()
     {
         $label = $this-&gt;render_label();
         $field = $this-&gt;render_field();
@@ -267,9 +269,9 @@ HTML;
     {$help}
 &lt;/div&gt;
 HTML;
-    } // }}}
+    }
 
-    function is_valid() // {{{
+    function is_valid()
     {
         $validate = $this-&gt;_validation_method;
         if ($validate)
@@ -277,5 +279,20 @@ HTML;
             return $validate($this);
         }
         return TRUE;
-    } // }}}
-} // }}}
+    }
+}
+
+class Minim_Form_TextArea extends Minim_Form_Field
+{
+    function render_field()
+    {
+        $value_attr = '';
+        if ($this-&gt;value)
+        {
+            $value_attr = $this-&gt;value;
+        }
+        return &lt;&lt;&lt;HTML
+&lt;textarea name=&quot;{$this-&gt;name}&quot; id=&quot;{$this-&gt;name}_field&quot;&gt;{$value_attr}&lt;/textarea&gt;
+HTML;
+    }
+}</diff>
      <filename>plugins/forms/new_forms.php</filename>
    </modified>
    <modified>
      <diff>@@ -4,7 +4,7 @@ class Minim_Orm_Sqlite_Backend implements Minim_Orm_Backend
     var $_orm;
     var $_db;
 
-    function __construct($params, &amp;$orm) // {{{
+    function __construct($params, $orm) // {{{
     {
         $this-&gt;_orm = $orm;
         if (!array_key_exists('database', $params))
@@ -16,7 +16,7 @@ class Minim_Orm_Sqlite_Backend implements Minim_Orm_Backend
         $this-&gt;_db-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
     } // }}}
 
-    function save(&amp;$do, &amp;$manager) // {{{
+    function save($do, $manager) // {{{
     {
         $fields = array_keys($manager-&gt;_fields);
         $values = preg_replace('/^/', ':', $fields);
@@ -30,7 +30,7 @@ class Minim_Orm_Sqlite_Backend implements Minim_Orm_Backend
     /**
      * Delete the specified record
      */
-    function delete(&amp;$do, &amp;$manager) // {{{
+    function delete($do, $manager) // {{{
     {
         $fields = array_keys($manager-&gt;_fields);
         $criteria = array();
@@ -53,7 +53,7 @@ class Minim_Orm_Sqlite_Backend implements Minim_Orm_Backend
         $sth-&gt;execute($values);
     } // }}}
 
-    function &amp;get($params, &amp;$manager) // {{{
+    function get($params, $manager) // {{{
     {
         $criteria = '';
         foreach ($params as $key =&gt; $value)
@@ -92,7 +92,7 @@ class Minim_Orm_Sqlite_Backend implements Minim_Orm_Backend
         error_log(&quot;Got $num_results result(s): &quot;.dump($results));
         if ($num_results == 1)
         {
-            $instance =&amp; $manager-&gt;create($results[0]);
+            $instance = $manager-&gt;create($results[0]);
             $instance-&gt;_in_db = TRUE;
             return $instance;
         }
@@ -103,20 +103,20 @@ class Minim_Orm_Sqlite_Backend implements Minim_Orm_Backend
         throw new Minim_Orm_Exception(&quot;No results for get&quot;);
     } // }}}
 
-    function &amp;get_dataobjects(&amp;$modelset) // {{{
+    function get_dataobjects($modelset) // {{{
     {
         list($query, $params) = $this-&gt;build_query($modelset);
-        $s =&amp; $this-&gt;execute_query($query, $params);
+        $s = $this-&gt;execute_query($query, $params);
         $objects = array();
-        $manager =&amp; $modelset-&gt;_manager;
+        $manager = $modelset-&gt;_manager;
         foreach ($s-&gt;fetchAll() as $row)
         {
-            $objects[] =&amp; $manager-&gt;create($row);
+            $objects[] = $manager-&gt;create($row);
         }
         return $objects;
     } // }}}
 
-    function count_dataobjects(&amp;$modelset) // {{{
+    function count_dataobjects($modelset) // {{{
     {
         list($query, $params) = $this-&gt;build_count_query($modelset);
         $s = $this-&gt;execute_query($query, $params);
@@ -128,16 +128,16 @@ class Minim_Orm_Sqlite_Backend implements Minim_Orm_Backend
         return $count;
     } // }}}
 
-    function build_count_query(&amp;$modelset) // {{{
+    function build_count_query($modelset) // {{{
     {
         return $this-&gt;build_query($modelset, True);
     } // }}}
 
-    function build_query(&amp;$modelset, $count=False) // {{{
+    function build_query($modelset, $count=False) // {{{
     {
         $query = array();
         $params = array();
-        foreach ($modelset-&gt;_filters as &amp;$filter)
+        foreach ($modelset-&gt;_filters as $filter)
         {
             // TODO - hide this from the developer
             list($expr, $value) = $this-&gt;render($filter);
@@ -210,7 +210,7 @@ SQL;
         return $s;
     } // }}} 
 
-    function render(&amp;$filter) // {{{
+    function render($filter) // {{{
     {
         switch ($filter-&gt;_operator)
         {</diff>
      <filename>plugins/orm/backends/sqlite.php</filename>
    </modified>
    <modified>
      <diff>@@ -38,7 +38,7 @@ class Minim_Orm implements Minim_Plugin
      *
      * @param string $name Name of model to register
      */
-    function &amp;register($name)
+    function register($name)
     {
         if (array_key_exists($name, $this-&gt;_managers))
         {
@@ -52,7 +52,7 @@ class Minim_Orm implements Minim_Plugin
      * Get a reference to the Manager for the named model.
      * Managers are lazy-loaded.
      */
-    function &amp;__get($name)
+    function __get($name)
     {
         if (!array_key_exists($name, $this-&gt;_managers))
         {
@@ -122,7 +122,7 @@ class Minim_Orm implements Minim_Plugin
      * Set the backend for the ORM, eg: MySQL DB, SQLite DB, etc
      * Return FALSE on failure
      */
-    function &amp;set_backend($type, $params)
+    function set_backend($type, $params)
     {
         // do not load a second backend
         if ($this-&gt;_backend)
@@ -160,15 +160,15 @@ class Minim_Orm implements Minim_Plugin
 
 interface Minim_Orm_Backend
 {
-    function save(&amp;$dataobject, &amp;$manager);
+    function save($dataobject, $manager);
 
-    function delete(&amp;$dataobject, &amp;$manager);
+    function delete($dataobject, $manager);
 
-    function &amp;get($params, &amp;$manager);
+    function get($params, $manager);
 
-    function count_dataobjects(&amp;$modelset);
+    function count_dataobjects($modelset);
 
-    function &amp;get_dataobjects(&amp;$modelset);
+    function get_dataobjects($modelset);
 }
 
 class Minim_Orm_Exception extends Exception {}
@@ -188,10 +188,10 @@ class Minim_Orm_Manager
     var $_fields;
     var $_sorting;
 
-    function Minim_Orm_Manager($name, &amp;$orm)
+    function Minim_Orm_Manager($name, $orm)
     {
         $this-&gt;_model = $name;
-        $this-&gt;_orm =&amp; $orm;
+        $this-&gt;_orm = $orm;
         $this-&gt;_db_table = strtolower($name);
         $this-&gt;_fields = array();
         $this-&gt;_sorting = array();
@@ -200,7 +200,7 @@ class Minim_Orm_Manager
     /**
      * Enable syntactic sugar for adding fields to model.
      */
-    function &amp;__call($name, $args)
+    function __call($name, $args)
     {
         if (array_key_exists($name, $this-&gt;_orm-&gt;_field_types))
         {
@@ -260,7 +260,7 @@ class Minim_Orm_Manager
     /**
      * Create a new DataObject instance based on this model
      */
-    function &amp;create($data=array())
+    function create($data=array())
     {
         $instance = new Minim_Orm_DataObject($this);
 
@@ -281,7 +281,7 @@ class Minim_Orm_Manager
     /**
      * Save specified dataobject to ORM backend
      */
-    function save(&amp;$do)
+    function save($do)
     {
         $this-&gt;_orm-&gt;_backend-&gt;save($do, $this);
     }
@@ -289,7 +289,7 @@ class Minim_Orm_Manager
     /**
      * Delete specified dataobject from ORM backend
      */
-    function delete(&amp;$do)
+    function delete($do)
     {
         $this-&gt;_orm-&gt;_backend-&gt;delete($do, $this);
     }
@@ -297,7 +297,7 @@ class Minim_Orm_Manager
     /**
      * Retrieve a single data object from the ORM backend
      */
-    function &amp;get($params)
+    function get($params)
     {
         if ($this-&gt;_orm-&gt;_backend)
         {
@@ -317,7 +317,7 @@ class Minim_Orm_Manager
     /**
      * Get a QueryObject on the 'all' ModelSet
      */
-    function &amp;where($fieldname)
+    function where($fieldname)
     {
         return $this-&gt;all()-&gt;where($fieldname);
     }
@@ -330,6 +330,13 @@ class Minim_Orm_Manager
  */
 class Minim_Orm_Field
 {
+    var $params;
+
+    function __construct($params)
+    {
+        $this-&gt;params = array();
+    }
+
     /**
      * Validate field value.
      */
@@ -337,6 +344,11 @@ class Minim_Orm_Field
     {
         return TRUE;
     }
+
+    function widget()
+    {
+        return 'text';
+    }
 }
 
 /**
@@ -353,9 +365,9 @@ class Minim_Orm_ModelSet implements Iterator, Countable
     var $_count;
     var $_cache;
 
-    function Minim_Orm_ModelSet(&amp;$manager)
+    function Minim_Orm_ModelSet($manager)
     {
-        $this-&gt;_manager =&amp; $manager;
+        $this-&gt;_manager = $manager;
         $this-&gt;_iterator_position = 0;
         $this-&gt;_filters = array();
         $this-&gt;_sorting = array();
@@ -365,7 +377,7 @@ class Minim_Orm_ModelSet implements Iterator, Countable
     /**
      * Get a query object to apply to this modelset
      */
-    function &amp;where($fieldname)
+    function where($fieldname)
     {
         return $this-&gt;_filter($fieldname);
     }
@@ -373,17 +385,17 @@ class Minim_Orm_ModelSet implements Iterator, Countable
     /**
      * @access private
      */
-    function &amp;_filter($field_name, $conjunction='AND')
+    function _filter($field_name, $conjunction='AND')
     {
         $qo = new Minim_Orm_QueryObject($field_name, $conjunction, $this);
-        $this-&gt;_filters[] =&amp; $qo;
+        $this-&gt;_filters[] = $qo;
         return $qo;
     }
 
     /**
      * Syntactic sugar for building filter chain
      */
-    function &amp;__call($name, $params)
+    function __call($name, $params)
     {
         if ($name == 'and')
         {
@@ -445,7 +457,7 @@ class Minim_Orm_ModelSet implements Iterator, Countable
     {
         if (is_null($this-&gt;_count))
         {
-            $backend =&amp; $this-&gt;_manager-&gt;_orm-&gt;_backend;
+            $backend = $this-&gt;_manager-&gt;_orm-&gt;_backend;
             if (!$backend)
             {
                 throw new Minim_Orm_Exception(&quot;No backend set&quot;);
@@ -460,8 +472,8 @@ class Minim_Orm_ModelSet implements Iterator, Countable
      */
     function _fill_cache()
     {
-        $backend =&amp; $this-&gt;_manager-&gt;_orm-&gt;_backend;
-        $this-&gt;_cache =&amp; $backend-&gt;get_dataobjects($this);
+        $backend = $this-&gt;_manager-&gt;_orm-&gt;_backend;
+        $this-&gt;_cache = $backend-&gt;get_dataobjects($this);
     }
 
     /**
@@ -504,7 +516,7 @@ class Minim_Orm_ModelSet implements Iterator, Countable
     /**
      * Get model instance at the current iterator position
      */
-    function &amp;current()
+    function current()
     {
         return $this-&gt;_cache[$this-&gt;_iterator_position];
     }
@@ -561,7 +573,7 @@ class Minim_Orm_DataObject
     var $_in_db;
     var $_data;
 
-    function Minim_Orm_DataObject(&amp;$manager)
+    function Minim_Orm_DataObject($manager)
     {
         $this-&gt;_manager = $manager;
         $this-&gt;_in_db = FALSE;
@@ -645,11 +657,11 @@ class Minim_Orm_QueryObject
     var $_operator;
     var $_operand;
 
-    function Minim_Orm_QueryObject($fieldname, $conjunction, &amp;$modelset)
+    function Minim_Orm_QueryObject($fieldname, $conjunction, $modelset)
     {
         $this-&gt;_and = $conjunction == 'AND';
         $this-&gt;_field = $fieldname;
-        $this-&gt;_modelset =&amp; $modelset;
+        $this-&gt;_modelset = $modelset;
         $this-&gt;_operator = '';
         $this-&gt;_operand = '';
     }
@@ -657,7 +669,7 @@ class Minim_Orm_QueryObject
     /**
      * Enable syntactic sugar for defining criteria
      */
-    function &amp;__call($name, $params)
+    function __call($name, $params)
     {
         switch ($name)
         {
@@ -704,8 +716,27 @@ class Minim_Orm_Integer extends Minim_Orm_Field
 
 class Minim_Orm_Text extends Minim_Orm_Field
 {
+    var $params;
+
+    function __construct($params)
+    {
+        parent::__construct($params);
+        $this-&gt;params = array(
+            'max_length' =&gt; @$params['max_length']
+        );
+    }
+
     function accepts_value($value)
     {
         return is_string($value);
     }
+
+    function widget()
+    {
+        if ($this-&gt;params['max_length'])
+        {
+            return 'text';
+        }
+        return 'textarea';
+    }
 }</diff>
      <filename>plugins/orm/orm.php</filename>
    </modified>
    <modified>
      <diff>@@ -7,8 +7,8 @@ class Minim_TemplateEngine implements Minim_Plugin
     var $_def_stack;
     var $_blocks;
     var $_extends;
-    var $webroot = '/';
     var $plugin_path;
+    var $asset_paths;
 
     function Minim_TemplateEngine()
     {
@@ -19,16 +19,44 @@ class Minim_TemplateEngine implements Minim_Plugin
         $this-&gt;_extends = array();
         $this-&gt;_helpers = array();
         $this-&gt;plugin_path = dirname(__FILE__);
+        $this-&gt;asset_paths = array();
     }
 
     /**
      * Render a template
      */
-    function render($_template, $_context=array())
+    function render($templates, $context=array())
+    {
+        // make sure templates is an array
+        if (!is_array($templates))
+        {
+            $templates = array($templates);
+        }
+
+        // use the first template that can be found
+        $found = FALSE;
+        foreach ($templates as $template)
+        {
+            if ($found = $this-&gt;_find_template($template))
+            {
+                error_log(&quot;Found {$template} template at {$found}&quot;);
+                break;
+            }
+        }
+
+        if (!$found)
+        {
+            throw new Minim_TemplateEngine_Exception(
+                &quot;No matching templates found&quot;);
+        }
+
+        $this-&gt;_render($template, $found, $context);
+    }
+
+    function _render($_template, $_template_file, $_context)
     {
         // prefix all variables with _ to 'hide' them from the template
         error_log(&quot;Rendering $_template template&quot;);
-        $_template_file = $this-&gt;_find_template($_template);
         if (!$_template_file)
         {
             throw new Minim_TemplateEngine_Exception(
@@ -61,10 +89,12 @@ class Minim_TemplateEngine implements Minim_Plugin
     {
         foreach ($this-&gt;template_paths as $path)
         {
+            error_log(&quot;Searching for $name.php in $path&quot;);
+
             $dir = new DirectoryIterator($path);
             foreach ($dir as $file)
             {
-                if (strtolower($file-&gt;getFilename()) == &quot;$name.php&quot;)
+                if (strtolower($file-&gt;getFilename()) == strtolower(&quot;$name.php&quot;))
                 {
                     return $file-&gt;getPathname();
                 }
@@ -112,20 +142,10 @@ class Minim_TemplateEngine implements Minim_Plugin
      */
     function include_css($name)
     {
-        $cssfile = $this-&gt;webroot.'css/'.$name.'.css';
+        $cssfile = find(&quot;$name.css&quot;, $this-&gt;asset_paths);
         echo &lt;&lt;&lt;HTML
 &lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;$cssfile&quot;&gt;
-HTML;
-    }
 
-    /**
-     * Convenience method to include a js file
-     */
-    function include_js($name)
-    {
-        $jsfile = $this-&gt;webroot.'js/'.$name.'.js';
-        echo &lt;&lt;&lt;HTML
-&lt;script type=&quot;text/javascript&quot; src=&quot;$jsfile&quot;&gt;&lt;/script&gt;
 HTML;
     }
 </diff>
      <filename>plugins/templates/templates.php</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>ebf4962264acb5e1c0d80f7d2042a3fc8518055e</id>
    </parent>
  </parents>
  <author>
    <name>Andy Driver</name>
    <email>andy@pagezero.net</email>
  </author>
  <url>http://github.com/andyhd/minim/commit/62fd9f558fce6d036e8adeeb265f6edcf3f47d8f</url>
  <id>62fd9f558fce6d036e8adeeb265f6edcf3f47d8f</id>
  <committed-date>2009-05-31T23:29:47-07:00</committed-date>
  <authored-date>2009-05-31T23:29:47-07:00</authored-date>
  <message>Allow specifying fallback templates to render function
Tweaks to forms</message>
  <tree>2cb2083d20ce8789e8ed85f7d9613e61d4a9f8e0</tree>
  <committer>
    <name>Andy Driver</name>
    <email>andy@pagezero.net</email>
  </committer>
</commit>
