lib/roda/plugins/assets.rb in roda-3.53.0 vs lib/roda/plugins/assets.rb in roda-3.54.0

- old
+ new

@@ -706,10 +706,13 @@ # the :css type. # # To return the tags for a specific asset group, use an array for # the type, such as [:css, :frontend]. # + # You can specify custom attributes for the tag by passing a hash + # as the attrs argument. + # # When the assets are not compiled, this will result in a separate # tag for each asset file. When the assets are compiled, this will # result in a single tag to the compiled asset file. def assets(type, attrs = OPTS) ltype = type.is_a?(Array) ? type[0] : type @@ -718,16 +721,16 @@ if o[:compiled] && (algo = o[:sri]) && (hash = _compiled_assets_hash(type)) attrs = Hash[attrs] attrs[:integrity] = "#{algo}-#{h([[hash].pack('H*')].pack('m').tr("\n", ''))}" end - attrs = attrs.map{|k,v| "#{k}=\"#{h(v)}\""}.join(' ') + attributes = attrs.map{|k,v| "#{k}=\"#{h(v)}\""}.join(' ') if ltype == :js - tag_start = "<script type=\"text/javascript\" #{attrs} src=\"" + tag_start = "<script#{' type="text/javascript"' unless attrs[:type]} #{attributes} src=\"" tag_end = "\"></script>" else - tag_start = "<link rel=\"stylesheet\" #{attrs} href=\"" + tag_start = "<link rel=\"stylesheet\" #{attributes} href=\"" tag_end = "\" />" end paths = assets_paths(type) if o[:early_hints]