Module: Jekyll::Minibundle::AssetTagMarkup
- Defined in:
- lib/jekyll/minibundle/asset_tag_markup.rb
Class Method Summary collapse
- .make_attribute(name, value) ⇒ Object
- .make_attributes(attributes) ⇒ Object
- .make_markup(type, url, attributes) ⇒ Object
Class Method Details
.make_attribute(name, value) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/jekyll/minibundle/asset_tag_markup.rb', line 25 def self.make_attribute(name, value) if value.nil? %( #{name}) else %( #{name}="#{CGI.escape_html(value.to_s)}") end end |
.make_attributes(attributes) ⇒ Object
21 22 23 |
# File 'lib/jekyll/minibundle/asset_tag_markup.rb', line 21 def self.make_attributes(attributes) attributes.map { |name, value| make_attribute(name, value) }.join end |
.make_markup(type, url, attributes) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/jekyll/minibundle/asset_tag_markup.rb', line 7 def self.make_markup(type, url, attributes) url_str = CGI.escape_html(url) attributes_str = make_attributes(attributes) case type when :js %(<script type="text/javascript" src="#{url_str}"#{attributes_str}></script>) when :css %(<link rel="stylesheet" href="#{url_str}"#{attributes_str}>) else raise ArgumentError, "Unknown type for generating bundle markup: #{type}, #{url}" end end |