Class: Jekyll::Assets::Default::JS

Inherits:
Jekyll::Assets::Default show all
Defined in:
lib/jekyll/assets/plugins/html/defaults/js.rb

Instance Attribute Summary

Attributes inherited from Extensible

#args, #asset, #ctx, #env, #jekyll

Instance Method Summary collapse

Methods inherited from Jekyll::Assets::Default

#config, get, #run, set, set_static, static

Methods inherited from Extensible

for?, for_args?, for_type?, inherited, #initialize, internal!, internal?, requirements

Constructor Details

This class inherits a constructor from Jekyll::Assets::Extensible

Instance Method Details

#integrity?Boolean

Returns:

  • (Boolean)


38
39
40
41
# File 'lib/jekyll/assets/plugins/html/defaults/js.rb', line 38

def integrity?
  config[:integrity] && !@asset.is_a?(Url) &&
    !@args.key?(:integrity)
end

#set_integrityObject



29
30
31
32
33
34
35
# File 'lib/jekyll/assets/plugins/html/defaults/js.rb', line 29

def set_integrity
  return unless integrity?
  @args[:integrity] = @asset.integrity
  unless @args.key?(:crossorigin)
    @args[:crossorigin] = "anonymous"
  end
end

#set_srcObject



21
22
23
24
25
26
# File 'lib/jekyll/assets/plugins/html/defaults/js.rb', line 21

def set_src
  return if @args[:inline]
  return @args[:src] = @asset.url if @asset.is_a?(Url)
  @args[:src] = @env.prefix_url(@asset
    .digest_path)
end

#set_typeObject



15
16
17
18
# File 'lib/jekyll/assets/plugins/html/defaults/js.rb', line 15

def set_type
  return if @args.key?(:type) || !config[:type]
  @args[:type] = "text/javascript"
end