Method: Sinatra::CSS::Helpers#css
- Defined in:
- lib/sinatra/css.rb
#css(path = nil, attrs = {}, &block) ⇒ Object Also known as: stylesheet
Return stylesheet link tag to path. When a block is passed, a style tag will be created with the yielded value as its contents.
Examples
css do
"body {
color: blue;
}"
end
# => <style>body { ... }</style>
css('/css/style.css', :media => :print) # =>
<link rel="stylesheet" href="/css/style.css" media="print" type="text/css" charset="utf-8">
297 298 299 300 301 302 |
# File 'lib/sinatra/css.rb', line 297 def css(path = nil, attrs = {}, &block) attrs = { :type => 'text/css', :media => "screen" }.merge(attrs) return tag(:style, yield, attrs) if block_given? path = url_for("#{path.sub('.css','')}.css") unless remote_asset?(path) tag(:link, { :rel => 'stylesheet', :charset => "utf-8", :href => path, :newline => true }.merge(attrs)) end |