Class: Liquid::Quote

Inherits:
DmCore::LiquidBlock
  • Object
show all
Defined in:
lib/dm_cms/liquid/tags/quote.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.detailsObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/dm_cms/liquid/tags/quote.rb', line 19

def self.details
  { name: self.tag_name,
    summary: 'HTML blockquote',
    category: 'structure',
    description: <<-END_OF_DESCRIPTION
Outpus an HTML 'blockquote' with optional author.  You can specify id, class, and style.

~~~
{% quote author: 'Favorite Person', id: some_id, class: some_class, style: some_style %}
  ...content
{% endquote %}
~~~
END_OF_DESCRIPTION
  }
end

Instance Method Details

#render(context) ⇒ Object




5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/dm_cms/liquid/tags/quote.rb', line 5

def render(context)
  @attributes.reverse_merge!  'class' => '', 'id' => '', 'style' => '', 'author' => ''

  output  = super
  style   = "style='#{@attributes["style"]}'" unless @attributes['style'].blank?
  dclass  = "class='#{@attributes["class"]}'" unless @attributes['class'].blank?
  id      = "id='#{@attributes["id"]}'" unless @attributes['id'].blank?
  
  out  = "<blockquote #{[id, dclass, style].join(' ')}>"
  out += output
  out += "\r\n<footer markdown='0'><cite>#{@attributes['author']}</cite></footer>" unless @attributes['author'].blank?
  out += "</blockquote>"
end