title: CodeIgniter "Template" system
body: <p>Whenever I start a new project I find myself remaking and rethinking my self made template library. I use some influences from dom manipulation, but don't want to make too much functions so that it still loads fast.</p>
  
  <p>This is how my current template system looks like:</p>
  
  <p>This is a layout file:</p>
  
  <pre><code>&lt;body&gt;
  &lt;div id="content"&gt;
      &lt;block:content&gt;This is a default text&lt;/block:content&gt;
  &lt;/div&gt;
  &lt;div id="sidebar"&gt;
      &lt;widget:advertisement type="wide" /&gt;
      &lt;block:sidebar this_param="is_passed_on" /&gt;
  &lt;/div&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>As you can see I made 2 sort of "extra" tags that will be replaced when eventually publishing the template. I load this layout like this:</p>
  
  <pre><code>$this-&gt;template-&gt;load("layout");
  </code></pre>
  
  <p>I then can manipulate the block tags like this:</p>
  
  <pre><code>$this-&gt;template-&gt;content = "I'm overwriting the default text";
  $this-&gt;template-&gt;content-&gt;prepend("I forgot something");
  
  $this-&gt;template-&gt;sidebar-&gt;view("viewfile_1", array(/*data*/));
  $this-&gt;template-&gt;sidebar-&gt;view("viewfile_2", array(/*data*/));
  </code></pre>
  
  <p>I can set text manually, I can load multiple views into 1 block, I can use a few dom-like manipulating functions like prepend, append, ...</p>
  
  <p>I can even extend the template with more layout options like:</p>
  
  <pre><code>$this-&gt;template-&gt;content-&gt;extend("2columns");
  </code></pre>
  
  <p>This layout file might look like:</p>
  
  <pre><code>&lt;div&gt;&lt;block:left/&gt;&lt;/div&gt;
  &lt;div&gt;&lt;block:right/&gt;&lt;/div&gt;
  </code></pre>
  
  <p>So that instead of the content block I now have an extra left and right block to put content in.</p>
  
  <p>I have also created a widget tag that loads the specific widget class (/widgets/advertisement in this case). The optional parameters added in the tags are passed on to the views files and/or widget display function together with the direct passed data array.</p>
  
  <p>In short, this is how my system now works. I haven't really found other systems like this to get inspiration from. Could you guys give me advice on anything so I can put together one decent system that I can keep using?</p>