Class: Jekyll::Minibundle::MiniBundleBlock
- Inherits:
-
Liquid::Block
- Object
- Liquid::Block
- Jekyll::Minibundle::MiniBundleBlock
- Defined in:
- lib/jekyll/minibundle/mini_bundle_block.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(tag_name, type, _tokens) ⇒ MiniBundleBlock
constructor
A new instance of MiniBundleBlock.
- #render(context) ⇒ Object
Constructor Details
#initialize(tag_name, type, _tokens) ⇒ MiniBundleBlock
Returns a new instance of MiniBundleBlock.
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_config ⇒ Object
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 |