<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title>adams.co.tt blog - tagged with toto</title>
  <id>http://adams.co.tt/</id>
  <updated>2012-04-19</updated>
  <author>
    <name></name>
  </author>
  <entry>
    <title>Rendering partials in toto</title>
    <link rel="alternate" href="http://adams.co.tt/blog/2012/04/19/rendering-partials-in-toto/"/>
    <id>http://adams.co.tt/blog/2012/04/19/rendering-partials-in-toto/</id>
    <published>2012-04-19</published>
    <updated>2012-04-19</updated>
    <author>
      <name></name>
    </author>
    <content type="html">&lt;p&gt;&lt;a href="https://github.com/cloudhead/toto"&gt;toto&lt;/a&gt; is a fantastic lightweight blogging engine. In fact, at the time of writing, this very blog is running on it. By looking at &lt;a href="https://github.com/cloudhead/dorothy"&gt;dorothy&lt;/a&gt; you can see how it uses a layout and templates to render content. However, by default, it does not provide support for template partials.&lt;/p&gt;

&lt;p&gt;However, that&amp;rsquo;s easily solved with a little monkey patching:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;module Toto
  class Site
    class Context
      def to_partial(page)
        to_html page, @config
      end
    end
  end
end
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Now you can include partials in your templates like this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;%= render 'sidebar', :partial %&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Now, I&amp;rsquo;m not a fan of monkey patching for a number reasons, not least of which is the fact that a good monkey patch is often a missed opportunity to improve an open source project. With that in mind, &lt;a href="https://github.com/cloudhead/toto/pull/121"&gt;here&lt;/a&gt; is the pull request to have this functionality added to toto itself.&lt;/p&gt;
</content>
  </entry>
</feed>
