Module: Sinatra::StaticAssets::Helpers
- Defined in:
- lib/sinatra/static_assets.rb
Instance Method Summary collapse
-
#image_tag(source, options = {}) ⇒ Object
In HTML <link> and <img> tags have no end tag.
- #javascript_script_tag(*sources) ⇒ Object (also: #javascript_include_tag)
- #link_to(desc, url, options = {}) ⇒ Object
- #stylesheet_link_tag(*sources) ⇒ Object
Instance Method Details
#image_tag(source, options = {}) ⇒ Object
In HTML <link> and <img> tags have no end tag. In XHTML, on the contrary, these tags must be properly closed.
We can choose the appropriate behaviour with closed
option:
image_tag "/images/foo.png", :alt => "Foo itself", :closed => true
The default value of closed
option is false
.
15 16 17 18 |
# File 'lib/sinatra/static_assets.rb', line 15 def image_tag(source, = {}) [:src] = url_for(source) tag("img", ) end |
#javascript_script_tag(*sources) ⇒ Object Also known as: javascript_include_tag
25 26 27 28 |
# File 'lib/sinatra/static_assets.rb', line 25 def javascript_script_tag(*sources) list, = (sources) list.collect { |source| javascript_tag(source, ) }.join("\n") end |
#link_to(desc, url, options = {}) ⇒ Object
32 33 34 35 36 |
# File 'lib/sinatra/static_assets.rb', line 32 def link_to(desc, url, = {}) tag("a", .merge(:href => url_for(url))) do desc end end |
#stylesheet_link_tag(*sources) ⇒ Object
20 21 22 23 |
# File 'lib/sinatra/static_assets.rb', line 20 def stylesheet_link_tag(*sources) list, = (sources) list.collect { |source| stylesheet_tag(source, ) }.join("\n") end |