Class: Jekyll::Quote

Inherits:
JekyllSupport::JekyllBlock
  • Object
show all
Includes:
JekyllQuoteVersion
Defined in:
lib/jekyll_quote.rb

Overview

Usage: quote [break] [by] [cite=‘Joe Blow’] [noprep] [url=‘blabla.com’] %Bla bla.endquote % Output looks like: <div class=‘quote’>

Bla bla.
<br><br> <span style='font-style:normal;'>&nbsp;&ndash; From Source cite.</span>

</div>

Constant Summary collapse

PLUGIN_NAME =
'quote'.freeze

Constants included from JekyllQuoteVersion

JekyllQuoteVersion::VERSION

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#citeObject

Returns the value of attribute cite.



18
19
20
# File 'lib/jekyll_quote.rb', line 18

def cite
  @cite
end

#urlObject

Returns the value of attribute url.



18
19
20
# File 'lib/jekyll_quote.rb', line 18

def url
  @url
end

Instance Method Details

#outputObject



52
53
54
55
56
57
58
59
60
61
# File 'lib/jekyll_quote.rb', line 52

def output
  klass = "#{@class} " if @class
  styling = " style='#{@style}'" if @style
  <<~END_HERE
    <div#{@id} class='#{klass}quote'#{styling}>
      #{@text}#{@cite_markup}
      #{@helper.attribute if @helper.attribution}
    </div>
  END_HERE
end

#render_impl(text) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/jekyll_quote.rb', line 22

def render_impl(text)
  @helper.gem_file __FILE__ # This enables plugin attribution

  @break  = @helper.parameter_specified? 'break' # enforced by CSS if a list ends the body
  @by     = @helper.parameter_specified? 'by'
  @cite   = @helper.parameter_specified? 'cite'
  @class  = @helper.parameter_specified? 'class'

  @id = @helper.parameter_specified? 'id'
  @id = " id='#{@id}'" if @id

  @noprep = @helper.parameter_specified? 'noprep'
  @style  = @helper.parameter_specified? 'style'
  @url    = @helper.parameter_specified? 'url'
  preposition = 'From'
  preposition = 'By' if @by
  preposition = '' if @noprep
  if @cite
    cite_markup = if @url && !@url.empty?
                    "<a href='#{@url}' rel='nofollow' target='_blank'>#{@cite}</a>"
                  else
                    "#{@cite}\n"
                  end
    tag = @break ? 'div' : 'span'
    @cite_markup = "<#{tag} class='quoteAttribution'> &nbsp;&ndash; #{preposition} #{cite_markup}</#{tag}>\n"
  end
  @text = @break ? "<div class='quoteText clearfix'>#{text}</div>" : text
  output
end