Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/toto.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 2 additions & 0 deletions test/templates/composite.rhtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<h1>Composite Page</h1>
<%= render 'sidebar', :partial %>
1 change: 1 addition & 0 deletions test/templates/sidebar.rhtml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<div id="sidebar">Sidebar</div>
6 changes: 6 additions & 0 deletions test/toto_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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