Skip to content
This repository

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

Showing 1 unique commit by 1 author.

Apr 16, 2012
Adam Scott Adding support for partials. d2a5ba5
This page is out of date. Refresh to see the latest.
6  lib/toto.rb
@@ -165,10 +165,14 @@ def title
165 165
       end
166 166
 
167 167
       def render page, type
168  
-        content = to_html page, @config
  168
+        content = to_partial page
169 169
         type == :html ? to_html(:layout, @config, &Proc.new { content }) : send(:"to_#{type}", page)
170 170
       end
171 171
 
  172
+      def to_partial page
  173
+        to_html page, @config
  174
+      end
  175
+
172 176
       def to_xml page
173 177
         xml = Builder::XmlMarkup.new(:indent => 2)
174 178
         instance_eval File.read("#{Paths[:templates]}/#{page}.builder")
2  test/templates/composite.rhtml
... ...
@@ -0,0 +1,2 @@
  1
+<h1>Composite Page</h1>
  2
+<%= render 'sidebar', :partial %>
1  test/templates/sidebar.rhtml
... ...
@@ -0,0 +1 @@
  1
+<div id="sidebar">Sidebar</div>
6  test/toto_test.rb
@@ -280,6 +280,12 @@ def readme() "#{self[:name]}'s README" end
280 280
   context "extensions to the core Ruby library" do
281 281
     should("respond to iso8601") { Date.today }.respond_to?(:iso8601)
282 282
   end
  283
+
  284
+  context "rendering a partial" do
  285
+    setup { @toto.get('/composite') }
  286
+    should("include a sidebar")   { topic.body }.includes_elements("#sidebar", 1)
  287
+  end
  288
+
283 289
 end
284 290
 
285 291
 
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.