Added ability to set media attribute within stylesheet_tag
This commit is contained in:
parent
30eed79f2b
commit
57dff76d8e
@ -5,7 +5,7 @@ module Locomotive
|
||||
|
||||
# Write the link to a stylesheet resource
|
||||
# input: url of the css file
|
||||
def stylesheet_tag(input)
|
||||
def stylesheet_tag(input,media='screen')
|
||||
return '' if input.nil?
|
||||
|
||||
unless input =~ /^(\/|http:)/
|
||||
@ -14,7 +14,7 @@ module Locomotive
|
||||
|
||||
input = "#{input}.css" unless input.ends_with?('.css')
|
||||
|
||||
%{<link href="#{input}" media="screen" rel="stylesheet" type="text/css" />}
|
||||
%{<link href="#{input}" media="#{media}" rel="stylesheet" type="text/css" />}
|
||||
end
|
||||
|
||||
# Write the link to javascript resource
|
||||
|
@ -26,6 +26,24 @@ describe Locomotive::Liquid::Filters::Html do
|
||||
stylesheet_tag('/trash/main').should == result
|
||||
end
|
||||
|
||||
it 'should return a link tag for a stylesheet file and media attribute set to print' do
|
||||
result = "<link href=\"/sites/000000000000000000000042/theme/stylesheets/main.css\" media=\"print\" rel=\"stylesheet\" type=\"text/css\" />"
|
||||
stylesheet_tag('main.css','print').should == result
|
||||
stylesheet_tag('main','print').should == result
|
||||
stylesheet_tag(nil).should == ''
|
||||
end
|
||||
|
||||
it 'should return a link tag for a stylesheet file with folder and media attribute set to print' do
|
||||
result = "<link href=\"/sites/000000000000000000000042/theme/stylesheets/trash/main.css\" media=\"print\" rel=\"stylesheet\" type=\"text/css\" />"
|
||||
stylesheet_tag('trash/main.css','print').should == result
|
||||
end
|
||||
|
||||
it 'should return a link tag for a stylesheet file without touching the url and media attribute set to print' do
|
||||
result = "<link href=\"/trash/main.css\" media=\"print\" rel=\"stylesheet\" type=\"text/css\" />"
|
||||
stylesheet_tag('/trash/main.css','print').should == result
|
||||
stylesheet_tag('/trash/main','print').should == result
|
||||
end
|
||||
|
||||
it 'should return a script tag for a javascript file' do
|
||||
result = %{<script src="/sites/000000000000000000000042/theme/javascripts/main.js" type="text/javascript"></script>}
|
||||
javascript_tag('main.js').should == result
|
||||
|
Loading…
Reference in New Issue
Block a user