Module: SproutCore::ViewHelperSupport
- Extended by:
- Helpers::CaptureHelper, Helpers::TextHelper
- Defined in:
- lib/sproutcore/deprecated/view_helper.rb
Defined Under Namespace
Classes: HelperState, RenderContext
Constant Summary collapse
- @@helpers =
{}
Class Method Summary collapse
- .find_helper(helper_name) ⇒ Object
-
.render_view(view_helper_id, item_id, opts = {}, client_builder = nil, render_source = nil, &block) ⇒ Object
:outlet => define if you want this to be used as an outlet.
- .set_helper(helper_name, obj) ⇒ Object
Class Method Details
.find_helper(helper_name) ⇒ Object
87 88 89 |
# File 'lib/sproutcore/deprecated/view_helper.rb', line 87 def self.find_helper(helper_name) @@helpers[helper_name.to_sym] || @@helpers[:view] end |
.render_view(view_helper_id, item_id, opts = {}, client_builder = nil, render_source = nil, &block) ⇒ Object
:outlet => define if you want this to be used as an outlet. :prototype => define if you want this to be used as a prototype.
538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 |
# File 'lib/sproutcore/deprecated/view_helper.rb', line 538 def self.render_view(view_helper_id, item_id, opts={}, client_builder=nil, render_source=nil, &block) # item_id is optional. If it is not a symbol or string, then generate # an item_id if item_id.instance_of?(Hash) opts = item_id; item_id = nil end item_id = render_source.dom_id! if item_id.nil? # create the new render context and set it. client_builder = opts[:client] if opts[:client] rc = RenderContext.new(view_helper_id, item_id, opts, client_builder, render_source) hs = find_helper(view_helper_id) # render the inner_html using the block, if one is given. SproutCore::PageHelper.push_render_context(rc) rc.[:inner_html] = render_source.capture(&block) if block_given? # now, use the helper state to prepare the render context. This will # extract the properties from the options and setup the render procs. hs.prepare_context(rc) unless hs.nil? # now have the render context render the HTML content. This may also # make changes to the other items to render. ret = rc.render_content SproutCore::PageHelper.pop_render_context # get the JS. Save as an outlet or in the page. cur_rc = opts[:current_context] || SproutCore::PageHelper.current_render_context view_class = opts[:view] || rc.view_class unless view_class.nil? view_settings = { :id => item_id, :class => view_class, :properties => rc.render_view, :lazy => opts[:lazy], :outlet_path => opts[:outlet_path] } # if an outlet item is passed, then register this as an outlet. outlet = opts[:outlet] if outlet.nil? outlet = opts[:field].nil? ? !cur_rc.nil? : [opts[:field].to_s, 'field'].join('_').to_sym end define = opts[:define] if outlet && cur_rc outlet = item_id if outlet == true cur_rc.set_outlet(outlet, view_settings) elsif define define = define.to_s.camelize.gsub('::','.') SproutCore::PageHelper.set_define(define, view_settings) # otherwise, add it to the page-wide setting. else prop = item_id.to_s.camelize(:lower) SproutCore::PageHelper.set_outlet(prop, view_settings) end end # get the styles, if any styles = rc.render_styles SproutCore::PageHelper.add_styles(styles) if styles && styles.size > 0 # done. return the generated HTML render_source.concat(ret,block) if block_given? return ret end |
.set_helper(helper_name, obj) ⇒ Object
91 92 93 |
# File 'lib/sproutcore/deprecated/view_helper.rb', line 91 def self.set_helper(helper_name,obj) @@helpers[helper_name.to_sym] = obj end |