Created stylesheet_url and javascript_url liquid filters

This commit is contained in:
Petr Blaho 2011-07-19 16:27:42 +02:00
parent 91aa975973
commit 41472c88bd
1 changed files with 27 additions and 7 deletions

View File

@ -3,9 +3,9 @@ module Locomotive
module Filters module Filters
module Html module Html
# Write the link to a stylesheet resource # Write the url to a stylesheet resource
# input: url of the css file # input: name of the css file
def stylesheet_tag(input, media = 'screen') def stylesheet_url(input)
return '' if input.nil? return '' if input.nil?
unless input =~ /^(\/|http:)/ unless input =~ /^(\/|http:)/
@ -14,12 +14,22 @@ module Locomotive
input = "#{input}.css" unless input.ends_with?('.css') input = "#{input}.css" unless input.ends_with?('.css')
input
end
# Write the link to a stylesheet resource
# input: url of the css file
def stylesheet_tag(input, media = 'screen')
return '' if input.nil?
input = stylesheet_url(input)
%{<link href="#{input}" media="#{media}" rel="stylesheet" type="text/css" />} %{<link href="#{input}" media="#{media}" rel="stylesheet" type="text/css" />}
end end
# Write the link to javascript resource # Write the url to javascript resource
# input: url of the javascript file # input: name of the javascript file
def javascript_tag(input) def javascript_url(input)
return '' if input.nil? return '' if input.nil?
unless input =~ /^(\/|http:)/ unless input =~ /^(\/|http:)/
@ -28,7 +38,17 @@ module Locomotive
input = "#{input}.js" unless input.ends_with?('.js') input = "#{input}.js" unless input.ends_with?('.js')
%{<script src="#{input}" type="text/javascript"></script>} input
end
# Write the link to javascript resource
# input: url of the javascript file
def javascript_tag(input)
return '' if input.nil?
input = javascript_url(input)
%{<script src="#{input}" type="text/javascript"></script>}
end end
def theme_image_url(input) def theme_image_url(input)