Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Support for partials #121

Open
wants to merge 1 commit into from

1 participant

Adam Scott
Adam Scott

This change should allow partials to be rendered using syntax like:

<%= render 'sidebar', :partial %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 16, 2012
  1. Adam Scott

    Adding support for partials.

    adscott authored
This page is out of date. Refresh to see the latest.
6 lib/toto.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")
2  test/templates/composite.rhtml
View
@@ -0,0 +1,2 @@
+<h1>Composite Page</h1>
+<%= render 'sidebar', :partial %>
1  test/templates/sidebar.rhtml
View
@@ -0,0 +1 @@
+<div id="sidebar">Sidebar</div>
6 test/toto_test.rb
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
Something went wrong with that request. Please try again.