Class: Jekyll::AsciiDoc::Excerpt

Inherits:
Excerpt
  • Object
show all
Defined in:
lib/jekyll-asciidoc/excerpt.rb

Instance Method Summary collapse

Constructor Details

#initialize(primary_doc, excerpt_content) ⇒ Excerpt

Returns a new instance of Excerpt.



10
11
12
13
14
15
# File 'lib/jekyll-asciidoc/excerpt.rb', line 10

def initialize primary_doc, excerpt_content
  excerpt_doc = primary_doc.dup
  excerpt_doc.content = excerpt_content
  excerpt_doc.extend NoLiquid unless primary_doc.data['liquid']
  super excerpt_doc
end

Instance Method Details

#extract_excerpt(content) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/jekyll-asciidoc/excerpt.rb', line 17

def extract_excerpt content
  # NOTE excerpt_doctype has already been resolved from either the page attribute or front matter variable
  if (doctype = (excerpt_data = data)['excerpt_doctype'] ||
      (inherited = doc.site.config['asciidoc']['excerpt_doctype']))
    excerpt_data['doctype'] = doctype
    excerpt_data['excerpt_doctype'] = doc.data['excerpt_doctype'] = doctype if inherited
  end
  content
end

#outputObject



27
28
29
30
31
32
33
34
# File 'lib/jekyll-asciidoc/excerpt.rb', line 27

def output
  unless defined? @output
    renderer = ::Jekyll::Renderer.new doc.site, self, site.site_payload
    @output = renderer.run
    trigger_hooks :post_render
  end
  @output
end

#render_with_liquid?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/jekyll-asciidoc/excerpt.rb', line 36

def render_with_liquid?
  !(NoLiquid === doc)
end

#trigger_hooks(hook_name, *args) ⇒ Object



43
44
45
46
# File 'lib/jekyll-asciidoc/excerpt.rb', line 43

def trigger_hooks hook_name, *args
  #::Jekyll::Hooks.trigger collection.label.to_sym, hook_name, self, *args if collection
  ::Jekyll::Hooks.trigger :documents, hook_name, self, *args
end