Changeset 903
- Timestamp:
- 11/08/07 00:06:12 (1 year ago)
- Files:
-
- trunk/lib/merb/mixins/render.rb (modified) (2 diffs)
- trunk/lib/merb/template/erubis.rb (modified) (1 diff)
- trunk/script (deleted)
- trunk/spec/fixtures/views/examples/template_catch_content_from_partial.html.erb (modified) (1 diff)
- trunk/spec/fixtures/views/partials/_haml.html.haml (modified) (1 diff)
- trunk/spec/fixtures/views/partials/_haml_new.html.haml (modified) (1 diff)
- trunk/spec/merb/render_spec.rb (modified) (4 diffs)
- trunk/tools/allison/cache/BODY (modified) (3 diffs)
- trunk/tools/allison/cache/INDEX (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib/merb/mixins/render.rb
r902 r903 150 150 when status = opts[:nothing] 151 151 return render_nothing(status) 152 153 when partial = opts[:partial] 154 opts[:format] ||= :html 155 template = find_partial(partial, opts) 156 opts[:layout] = :none 157 158 # Add an instance variable that can be used to create the locals in the 159 # partial 160 if opts[:locals] 161 @_merb_partial_locals = opts[:locals] 162 end 163 opts[:clean_context] = true 164 152 165 when opts[:inline] 153 166 text = opts.delete(:inline) … … 269 282 # partials that live there like partial('shared/foo') 270 283 def partial(template, locals={}) 271 choose_template_format(Merb.available_mime_types, {}) unless @_template_format 272 template = find_partial(template) 273 @_merb_partial_locals = locals 274 unless template 275 raise TemplateNotFound, "No template matched at #{unmatched}" 276 end 277 278 engine = Template.engine_for(template) 279 options = { 280 :file => template, 281 :view_context => clean_view_context(engine), 282 :opts => {:locals => locals} 283 } 284 engine.transform(options) 285 end 284 options = {:partial => template, :locals => locals} 285 options.merge!(:format => @_template_format) if @_template_format 286 render options 287 end 286 288 287 289 # +catch_content+ catches the thrown content from another template trunk/lib/merb/template/erubis.rb
r902 r903 36 36 # Creates a new Erubis object to parse the template given in +path+. 37 37 def new_eruby_obj(path) 38 if @@erbs[path] && MERB_ENV ==' production'38 if @@erbs[path] && !cache_template?(path) 39 39 return @@erbs[path] 40 40 else trunk/spec/fixtures/views/examples/template_catch_content_from_partial.html.erb
r902 r903 1 <% partial"examples/throw_content" %>1 <% render :partial => "examples/throw_content" %> 2 2 3 3 <%= catch_content :from_partial %> 4 <% partial"examples/throw_content" %>4 <% render :partial => "examples/throw_content" %> 5 5 6 6 <%= catch_content :from_partial %> trunk/spec/fixtures/views/partials/_haml.html.haml
r902 r903 1 = respond_to?(:yo)? yo : "No Locals!"1 = defined?(yo) && yo ? yo : "No Locals!" trunk/spec/fixtures/views/partials/_haml_new.html.haml
r902 r903 1 = respond_to?(:yo)? yo : "No Locals!"1 = defined?(yo) && yo ? yo : "No Locals!" trunk/spec/merb/render_spec.rb
r902 r903 12 12 it "should render a partial" do 13 13 c = new_controller 14 content = c. partial"partials/#{@engine}"14 content = c.render :partial => "partials/#{@engine}" 15 15 content.clean.should == "No Locals!" 16 16 end … … 18 18 it "should render a partial with locals" do 19 19 c = new_controller 20 content = c. partial "partials/#{@engine}", :yo => "Locals!"20 content = c.render :partial => "partials/#{@engine}", :locals => { :yo => "Locals!" } 21 21 content.clean.should == "Locals!" 22 22 end … … 36 36 it "should render a partial using the .format.engine convention" do 37 37 c = new_controller 38 content = c. partial"partials/#{@engine}_new"38 content = c.render :partial => "partials/#{@engine}_new" 39 39 content.clean.should == "No Locals!" 40 40 end … … 86 86 it "should render #{@engine} partial using .format.engine convention#{" (caching on)" if defined?(cache) && cache}" do 87 87 c = new_controller 88 content = c. partial"partials/#{@engine}_new"88 content = c.render :partial => "partials/#{@engine}_new" 89 89 content.clean.should == "No Locals!" 90 90 end trunk/tools/allison/cache/BODY
r902 r903 1 <html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml"><head><meta content="text/html; charset=utf-8" http-equiv="Content-Type"/><title>%title%</title><link type="text/css" rel="stylesheet" href="%style_url%" media="screen"/><script type="text/javascript">1 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><meta content="text/html; charset=utf-8" http-equiv="Content-Type"/><title>%title%</title><link type="text/css" href="%style_url%" rel="stylesheet" media="screen"/><script type="text/javascript"> 2 2 // Javascript for Allison RDoc template 3 3 // Copyright 2006 Cloudburst LLC … … 402 402 </div> 403 403 ENDIF:methods 404 <div id="spacer"></div><div class="navigation dark index" id="class_wrapper"><div class="list_header"><h3>All classes</h3></div><div class="list_header_link"><a onclick="toggle('class'); toggleText('class_link'); return false;" id="class_link" href="#">Hide...</a></div><div class="clear"></div><div id="class"><form><label for="filter_class">Filter: </label><input type="text" onKeyPress="return disableSubmit(event);" id="filter_class" onKeyUp="return filterList('class', this.value, event);"></input></form></div></div><div class="navigation dark index" id="file_wrapper"><div class="list_header"><h3>All files</h3></div><div class="list_header_link"><a onclick="toggle('file'); toggleText('file_link'); return false;" id="file_link" href="#">Hide...</a></div><div class="clear"></div><div id="file"><form><label for="filter_file">Filter: </label><input type="text" onKeyPress="return disableSubmit(event);" id="filter_file" onKeyUp="return filterList('file', this.value, event);"></input></form></div></div><div class="navigation dark index" id="method_wrapper"><div class="list_header"><h3>All methods</h3></div><div class="list_header_link"><a onclick="toggle('method'); toggleText('method_link'); return false;" id="method_link" href="#">Show...</a></div><div class="clear"></div><div id="method"><form><label for="filter_method">Filter: </label><input type="text" onKeyPress="return disableSubmit(event);" id="filter_method" onKeyUp="return filterList('method', this.value, event);"></input></form></div></div><div class="curve" id="left_curve_0"></div><div class="curve" id="left_curve_1"></div><div class="curve" id="left_curve_2"></div><div class="curve" id="left_curve_3"></div><div class="curve" id="left_curve_4"></div><div class="curve" id="left_curve_5"></div><div class="curve" id="left_curve_6"></div><div class="curve" id="left_curve_7"></div><div class="curve" id="left_curve_8"></div><div class="curve" id="left_curve_9"></div></div><div id="content">404 <div id="spacer"></div><div class="navigation dark index" id="class_wrapper"><div class="list_header"><h3>All classes</h3></div><div class="list_header_link"><a href="#" onclick="toggle('class'); toggleText('class_link'); return false;" id="class_link">Hide...</a></div><div class="clear"></div><div id="class"><form><label for="filter_class">Filter: </label><input type="text" onKeyPress="return disableSubmit(event);" id="filter_class" onKeyUp="return filterList('class', this.value, event);"></input></form></div></div><div class="navigation dark index" id="file_wrapper"><div class="list_header"><h3>All files</h3></div><div class="list_header_link"><a href="#" onclick="toggle('file'); toggleText('file_link'); return false;" id="file_link">Hide...</a></div><div class="clear"></div><div id="file"><form><label for="filter_file">Filter: </label><input type="text" onKeyPress="return disableSubmit(event);" id="filter_file" onKeyUp="return filterList('file', this.value, event);"></input></form></div></div><div class="navigation dark index" id="method_wrapper"><div class="list_header"><h3>All methods</h3></div><div class="list_header_link"><a href="#" onclick="toggle('method'); toggleText('method_link'); return false;" id="method_link">Show...</a></div><div class="clear"></div><div id="method"><form><label for="filter_method">Filter: </label><input type="text" onKeyPress="return disableSubmit(event);" id="filter_method" onKeyUp="return filterList('method', this.value, event);"></input></form></div></div><div class="curve" id="left_curve_0"></div><div class="curve" id="left_curve_1"></div><div class="curve" id="left_curve_2"></div><div class="curve" id="left_curve_3"></div><div class="curve" id="left_curve_4"></div><div class="curve" id="left_curve_5"></div><div class="curve" id="left_curve_6"></div><div class="curve" id="left_curve_7"></div><div class="curve" id="left_curve_8"></div><div class="curve" id="left_curve_9"></div></div><div id="content"> 405 405 IF:title 406 406 <h1 id="item_name">%title%</h1> … … 572 572 573 573 IF:sourcecode 574 <p class="source_link" id="%aref%-show-link"><a onclick="toggle('%aref%-source'); toggleText('%aref%-link'); return false;" id="%aref%-link" href="#">Show source...</a></p><div class="source" id="%aref%-source"><pre>%sourcecode%</pre></div>574 <p class="source_link" id="%aref%-show-link"><a href="#" onclick="toggle('%aref%-source'); toggleText('%aref%-link'); return false;" id="%aref%-link">Show source...</a></p><div class="source" id="%aref%-source"><pre>%sourcecode%</pre></div> 575 575 ENDIF:sourcecode 576 576 </div></div> trunk/tools/allison/cache/INDEX
r902 r903 1 <html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml"><head><meta content="text/html; charset=utf-8" http-equiv="Content-Type"/><title>%title%</title><link type="text/css" rel="stylesheet" href="rdoc-style.css" media="screen"/><meta content="0;url=%initial_page%" http-equiv="refresh"/></head><body><div id="container"><div class="curve" id="preheader_curve_0"></div><div class="curve" id="preheader_curve_1"></div><div class="curve" id="preheader_curve_2"></div><div class="curve" id="preheader_curve_3"></div><div class="curve" id="preheader_curve_4"></div><div class="curve" id="preheader_curve_5"></div><div class="curve" id="preheader_curve_6"></div><div class="curve" id="preheader_curve_7"></div><div class="curve" id="preheader_curve_8"></div><div class="curve" id="preheader_curve_9"></div><div id="header"><span id="title"><p> </p><h1>Ruby Documentation</h1></span></div><div class="clear"></div><div id="redirect"><a href="%initial_page%"><h1>Redirect</h1></a></div></div></body></html>1 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><meta content="text/html; charset=utf-8" http-equiv="Content-Type"/><title>%title%</title><link type="text/css" href="rdoc-style.css" rel="stylesheet" media="screen"/><meta content="0;url=%initial_page%" http-equiv="refresh"/></head><body><div id="container"><div class="curve" id="preheader_curve_0"></div><div class="curve" id="preheader_curve_1"></div><div class="curve" id="preheader_curve_2"></div><div class="curve" id="preheader_curve_3"></div><div class="curve" id="preheader_curve_4"></div><div class="curve" id="preheader_curve_5"></div><div class="curve" id="preheader_curve_6"></div><div class="curve" id="preheader_curve_7"></div><div class="curve" id="preheader_curve_8"></div><div class="curve" id="preheader_curve_9"></div><div id="header"><span id="title"><p> </p><h1>Ruby Documentation</h1></span></div><div class="clear"></div><div id="redirect"><a href="%initial_page%"><h1>Redirect</h1></a></div></div></body></html>
