Class: Octopress::Tags::PullQuote::Tag

Inherits:
Liquid::Block
  • Object
show all
Defined in:
lib/octopress-pullquote-tag.rb

Instance Method Summary collapse

Constructor Details

#initialize(tag_name, markup, tokens) ⇒ Tag

Returns a new instance of Tag.



9
10
11
12
# File 'lib/octopress-pullquote-tag.rb', line 9

def initialize(tag_name, markup, tokens)
  @markup = markup
  super
end

Instance Method Details

#render(context) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/octopress-pullquote-tag.rb', line 14

def render(context)
  output = super
  quotemarks = /\{"\s*(.+?)\s*"\}/m
  if output =~ quotemarks

    output.gsub!(quotemarks, '\1')

    quote = RubyPants.new($1).to_html

    alignment = @markup.scan(/(left|right|center)/i).first || 'right'
    classnames = @markup.sub(/left|right|center/i, '').strip

    output = "<span class='pullquote-#{alignment} #{classnames}' data-pullquote='#{quote}'></span>#{output}"

    Utils.parse_content(output, context)
  else
    raise "PullQuote Error: Surround your pullquote like this {\" text to be quoted \"}"
  end
end