module SproutCore::PageHelper
The PageHelper
is a singleton object that can render the Page javascript object.
Public Class Methods
add_styles(styles)
click to toggle source
# File lib/sproutcore/deprecated/view_helper.rb, line 49 def self.add_styles(styles) @@styles << styles end
current_render_context()
click to toggle source
This is the current helper state used when rendering the HTML. When a view helper is rendered, it may add itself as an outlet to the current helper state instead of to the page helper.
# File lib/sproutcore/deprecated/view_helper.rb, line 21 def self.current_render_context @@render_contexts.last end
pop_render_context()
click to toggle source
# File lib/sproutcore/deprecated/view_helper.rb, line 29 def self.pop_render_context @@render_contexts.pop end
push_render_context(state)
click to toggle source
# File lib/sproutcore/deprecated/view_helper.rb, line 25 def self.push_render_context(state) @@render_contexts.push(state) end
render_css()
click to toggle source
# File lib/sproutcore/deprecated/view_helper.rb, line 74 def self.render_css if @@styles.size > 0 %(<style type="application/css">\n#{ @@styles * "\n" }\n</style>) else '' end end
render_js(prefix = 'SC', bundle = nil)
click to toggle source
renders the page object for the current page. If you include a prefix that will be used to create a separate page object. Otherwise, the object will live in the SC
namespace. If you provide a bundle that is configured to minify sources the output will be compressed.
returns the text to insert into the HTML.
# File lib/sproutcore/deprecated/view_helper.rb, line 59 def self.render_js(prefix = 'SC', bundle = nil) outlets = [] @@outlets.each do | key, opts | outlet_path = opts[:outlet_path] || "##{opts[:id] || key}" outlets << %{ #{key}: #{opts[:class] || 'SC.View'}.extend({\n #{ opts[:properties].gsub("\n","\n ") }\n }).outletFor("#{outlet_path}") } end # defines let you define classes to include in your UI. ret = @@defines.each do | key, opts | %{#{key} = #{opts[:class] || 'SC.View'}.extend({\n #{ opts[:properties] }\n});} end ret << %{#{prefix}.page = SC.Page.create({\n#{ outlets * ",\n\n" }\n}); } bundle ? SproutCore::BuildTools::JavaScriptResourceBuilder.new(nil, nil, bundle, nil).join(ret) : ret*"\n" end
reset!()
click to toggle source
reset the page helper.
# File lib/sproutcore/deprecated/view_helper.rb, line 34 def self.reset! @@render_contexts = [] @@outlets = [] @@styles = [] @@defines = [] end
set_define(key, opts = {})
click to toggle source
# File lib/sproutcore/deprecated/view_helper.rb, line 41 def self.set_define(key, opts = {}) @@defines << [key, opts] end
set_outlet(key,opts = {})
click to toggle source
# File lib/sproutcore/deprecated/view_helper.rb, line 45 def self.set_outlet(key,opts = {}) @@outlets << [key, opts] end