Permalink
Browse files

Created stylesheet_url and javascript_url liquid filters

  • Loading branch information...
1 parent 91aa975 commit 41472c88bda770b00be7c917ae1013f01ae532e1 Petr Blaho committed Jul 19, 2011
Showing with 27 additions and 7 deletions.
  1. +27 −7 lib/locomotive/liquid/filters/html.rb
@@ -3,9 +3,9 @@ module Liquid
module Filters
module Html
- # Write the link to a stylesheet resource
- # input: url of the css file
- def stylesheet_tag(input, media = 'screen')
+ # Write the url to a stylesheet resource
+ # input: name of the css file
+ def stylesheet_url(input)
return '' if input.nil?
unless input =~ /^(\/|http:)/
@@ -14,12 +14,22 @@ def stylesheet_tag(input, media = 'screen')
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" />}
end
- # Write the link to javascript resource
- # input: url of the javascript file
- def javascript_tag(input)
+ # Write the url to javascript resource
+ # input: name of the javascript file
+ def javascript_url(input)
return '' if input.nil?
unless input =~ /^(\/|http:)/
@@ -28,7 +38,17 @@ def javascript_tag(input)
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
def theme_image_url(input)

0 comments on commit 41472c8

Please sign in to comment.