Class: Jekyll::Minibundle::MiniBundleBlock

Inherits:
Liquid::Block
  • Object
show all
Defined in:
lib/jekyll/minibundle/mini_bundle_block.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tag_name, type, _tokens) ⇒ MiniBundleBlock

Returns a new instance of MiniBundleBlock.

Raises:

  • (ArgumentError)


8
9
10
11
12
# File 'lib/jekyll/minibundle/mini_bundle_block.rb', line 8

def initialize(tag_name, type, _tokens)
  super
  @type = type.strip.downcase.to_sym
  raise ArgumentError, "No asset type for minibundle block; pass value such as 'css' or 'js' as the argument" if @type.empty?
end

Class Method Details

.default_bundle_configObject



25
26
27
28
29
30
31
32
33
# File 'lib/jekyll/minibundle/mini_bundle_block.rb', line 25

def self.default_bundle_config
  {
    'source_dir'       => '_assets',
    'destination_path' => 'assets/site',
    'baseurl'          => '',
    'assets'           => [],
    'attributes'       => {}
  }
end

Instance Method Details

#render(context) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/jekyll/minibundle/mini_bundle_block.rb', line 14

def render(context)
  site = context.registers.fetch(:site)
  bundle_config = get_current_bundle_config(::SafeYAML.load(super), site)
  baseurl = bundle_config.fetch('baseurl')
  attributes = bundle_config.fetch('attributes')

  register_asset_files(site, bundle_config).map do |file|
    AssetTagMarkup.make_markup(@type, baseurl, file.destination_path_for_markup, attributes)
  end.join("\n")
end