Class: Jekyll::Assets::HTML
- Inherits:
-
Extensible
- Object
- Extensible
- Jekyll::Assets::HTML
- Defined in:
- lib/jekyll/assets/html.rb,
lib/jekyll/assets/plugins/html/js.rb,
lib/jekyll/assets/plugins/html/css.rb,
lib/jekyll/assets/plugins/html/img.rb,
lib/jekyll/assets/plugins/html/pic.rb,
lib/jekyll/assets/plugins/html/svg.rb,
lib/jekyll/assets/plugins/html/vid.rb,
lib/jekyll/assets/plugins/html/audio.rb,
lib/jekyll/assets/plugins/html/favicon.rb,
lib/jekyll/assets/plugins/html/component.rb
Defined Under Namespace
Classes: Audio, CSS, Component, Favicon, IMG, JS, Pic, SVG, Video
Instance Attribute Summary collapse
-
#doc ⇒ Object
readonly
Returns the value of attribute doc.
Attributes inherited from Extensible
#args, #asset, #ctx, #env, #jekyll
Class Method Summary collapse
-
.build(args:, asset:, ctx:) ⇒ String
-- Search for plugins and runners and then run them.
-
.make_doc(builders, asset:) ⇒ Nokogiri::Document
-- Make an HTML/XML doc to work on.
-
.skips ⇒ Object
--.
-
.wants_xml? ⇒ true, false
-- Allows a plugin to inform us if they want XML.
Instance Method Summary collapse
-
#initialize(doc:, **kwd) ⇒ HTML
constructor
--.
Methods inherited from Extensible
for?, for_args?, for_type?, inherited, internal!, internal?, requirements
Constructor Details
#initialize(doc:, **kwd) ⇒ HTML
--
19 20 21 22 |
# File 'lib/jekyll/assets/html.rb', line 19 def initialize(doc:, **kwd) super(**kwd) @doc = doc end |
Instance Attribute Details
#doc ⇒ Object (readonly)
Returns the value of attribute doc.
11 12 13 |
# File 'lib/jekyll/assets/html.rb', line 11 def doc @doc end |
Class Method Details
.build(args:, asset:, ctx:) ⇒ String
Note:
look inside of plugins for examples.
--
Search for plugins and runners and then run them.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/jekyll/assets/html.rb', line 33 def self.build(args:, asset:, ctx:) rtn = inherited.select do |o| o.for?({ type: asset.content_type, args: args, }) end doc = make_doc(rtn, asset: asset) rtn.each do |o| o = o.new({ doc: doc, asset: asset, args: args, ctx: ctx, }) o.run end # SVG will need to_xml! out = doc.is_a?(Nokogiri::XML::Document) ? doc.to_xml : doc.to_html rtn.select { |v| v.respond_to?(:cleanup) }.each do |o| out = o.cleanup(out) end out end |
.make_doc(builders, asset:) ⇒ Nokogiri::Document
Note:
see self.wants_html? to control this.
--
Make an HTML/XML doc to work on.
75 76 77 78 79 |
# File 'lib/jekyll/assets/html.rb', line 75 def self.make_doc(builders, asset:) wants = builders.map(&:wants_xml?).uniq raise "incompatible wants xml/html for builders" if wants.size > 1 !wants[0] ? Utils.html_fragment("") : Utils.xml(asset.to_s) end |
.skips ⇒ Object
--
14 15 16 |
# File 'lib/jekyll/assets/html.rb', line 14 def self.skips i(inline path data pic) | Proxy.keys end |
.wants_xml? ⇒ true, false
Note:
technically this can break sub-plugins later.
--
Allows a plugin to inform us if they want XML.
66 67 68 |
# File 'lib/jekyll/assets/html.rb', line 66 def self.wants_xml? false end |