Module: RackPipeline::Sinatra::Helpers
- Defined in:
- lib/rack-pipeline/sinatra.rb
Instance Method Summary collapse
- #pipe_tag(type, asset) ⇒ Object
- #pipeline(pipes = [ :app ], types = [ :css, :js ], opts = {}) ⇒ Object
Instance Method Details
#pipe_tag(type, asset) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/rack-pipeline/sinatra.rb', line 17 def pipe_tag( type, asset ) case type.to_sym when :css %(<link href="#{request.script_name}/#{asset}" rel="stylesheet">) when :js %(<script src="#{request.script_name}/#{asset}"></script>) end end |
#pipeline(pipes = [ :app ], types = [ :css, :js ], opts = {}) ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/rack-pipeline/sinatra.rb', line 8 def pipeline( pipes = [ :app ], types = [ :css, :js ], opts = {} ) Array(types).map do |type| assets = env['rack-pipeline'].assets_for( pipes, type, opts ) assets.map do |asset| pipe_tag( type, asset ) end.join("\n") end.join("\n") end |