Permalink
Browse files

Adding support for partials.

  • Loading branch information...
adscott committed Apr 16, 2012
1 parent 7af9a05 commit d2a5ba569a1f81be4fc07d1b806676cdaa2881c8
Showing with 14 additions and 1 deletion.
  1. +5 −1 lib/toto.rb
  2. +2 −0 test/templates/composite.rhtml
  3. +1 −0 test/templates/sidebar.rhtml
  4. +6 −0 test/toto_test.rb
View
@@ -165,10 +165,14 @@ def title
end
def render page, type
- content = to_html page, @config
+ content = to_partial page
type == :html ? to_html(:layout, @config, &Proc.new { content }) : send(:"to_#{type}", page)
end
+ def to_partial page
+ to_html page, @config
+ end
+
def to_xml page
xml = Builder::XmlMarkup.new(:indent => 2)
instance_eval File.read("#{Paths[:templates]}/#{page}.builder")
@@ -0,0 +1,2 @@
+<h1>Composite Page</h1>
+<%= render 'sidebar', :partial %>
@@ -0,0 +1 @@
+<div id="sidebar">Sidebar</div>
View
@@ -280,6 +280,12 @@ def readme() "#{self[:name]}'s README" end
context "extensions to the core Ruby library" do
should("respond to iso8601") { Date.today }.respond_to?(:iso8601)
end
+
+ context "rendering a partial" do
+ setup { @toto.get('/composite') }
+ should("include a sidebar") { topic.body }.includes_elements("#sidebar", 1)
+ end
+
end

0 comments on commit d2a5ba5

Please sign in to comment.