lib/hanami/assets/helpers.rb in hanami-assets-1.3.0 vs lib/hanami/assets/helpers.rb in hanami-assets-1.3.1
- old
+ new
@@ -63,11 +63,11 @@
# @api private
ABSOLUTE_URL_MATCHER = URI::DEFAULT_PARSER.make_regexp
# @since 1.1.0
# @api private
- QUERY_STRING_MATCHER = /\?/
+ QUERY_STRING_MATCHER = /\?/.freeze
include Hanami::Helpers::HtmlHelper
# Inject helpers into the given class
#
@@ -179,11 +179,11 @@
def javascript(*sources, push: true, **options) # rubocop:disable Metrics/MethodLength
options = options.reject { |k, _| k.to_sym == :src }
_safe_tags(*sources) do |source|
attributes = {
- src: _typed_asset_path(source, JAVASCRIPT_EXT, push: push, as: :script),
+ src: _typed_asset_path(source, JAVASCRIPT_EXT, push: push, as: :script),
type: JAVASCRIPT_MIME_TYPE
}
attributes.merge!(options)
if _subresource_integrity? || attributes.include?(:integrity)
@@ -282,11 +282,11 @@
_safe_tags(*sources) do |source|
attributes = {
href: _typed_asset_path(source, STYLESHEET_EXT, push: push, as: :style),
type: STYLESHEET_MIME_TYPE,
- rel: STYLESHEET_REL
+ rel: STYLESHEET_REL
}
attributes.merge!(options)
if _subresource_integrity? || attributes.include?(:integrity)
attributes[:integrity] ||= _subresource_integrity_value(source, STYLESHEET_EXT)
@@ -443,11 +443,11 @@
def favicon(source = DEFAULT_FAVICON, options = {})
options = options.reject { |k, _| k.to_sym == :href }
attributes = {
href: asset_path(source, push: options.delete(:push) || false, as: :image),
- rel: FAVICON_REL,
+ rel: FAVICON_REL,
type: FAVICON_MIME_TYPE
}
attributes.merge!(options)
html.link(attributes)
@@ -907,12 +907,10 @@
options = src.to_hash
elsif src
options[:src] = asset_path(src, push: options.delete(:push) || false, as: as)
end
- if !options[:src] && !block_given?
- raise ArgumentError.new('You should provide a source via `src` option or with a `source` HTML tag')
- end
+ raise ArgumentError.new('You should provide a source via `src` option or with a `source` HTML tag') if !options[:src] && !block_given?
options
end
# @since 0.1.0