Module: Spinebox::ERBContext
- Defined in:
- lib/spinebox/erb_context.rb
Instance Method Summary collapse
-
#javascript_include_tag(source) ⇒ Object
Includes javascript tags in the erb.
-
#render(params = {}) ⇒ Object
Renders, e.g.
-
#stylesheet_link_tag(source, options = {}) ⇒ Object
Includes javascript tags in the erb.
Instance Method Details
#javascript_include_tag(source) ⇒ Object
Includes javascript tags in the erb. If concatenation is disabled it returns multiple tags, otherwise it returns a single application tag.
8 9 10 11 12 13 14 |
# File 'lib/spinebox/erb_context.rb', line 8 def javascript_include_tag source if Spinebox.config.concatenate javascript_tag_for(asset_for(source, 'js')) else asset_for(source, 'js').to_a.map{ |asset| javascript_tag_for asset, :body => 1 }.join("\n") end end |
#render(params = {}) ⇒ Object
Renders, e.g. a partial into another view
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/spinebox/erb_context.rb', line 27 def render params = {} raise RenderError, "Render without :partial called" if params[:partial].nil? raise RenderError, "Partial needs a file extension" if params[:partial].split(".").size == 0 partial = Spinebox.views["_#{params[:partial]}"] raise RenderError, "Partial not found" if partial.nil? partial.to_s end |
#stylesheet_link_tag(source, options = {}) ⇒ Object
Includes javascript tags in the erb. If concatenation is disabled it returns multiple tags, otherwise it returns a single application tag.
18 19 20 21 22 23 24 |
# File 'lib/spinebox/erb_context.rb', line 18 def stylesheet_link_tag source, = {} if Spinebox.config.concatenate stylesheet_tag_for(asset_for(source, 'css'), ) else asset_for(source, 'css').to_a.map{ |asset| stylesheet_tag_for asset, .merge!({ :body => 1 }) }.join("\n") end end |