Module: XanMarkup::Helper

Defined in:
lib/xan_markup/helper.rb

Instance Method Summary collapse

Instance Method Details

#markupize(content) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/xan_markup/helper.rb', line 8

def markupize(content)
  content.to_s.dup.to_str.gsub(MarkupSyntax) do |markup|
    args   = {}
    tag    = $1.split.first
    method = "markup_#{tag}"
    $1.scan(TagAttributes) do |key, value|
      args[key.to_sym] = value.gsub(CleanAttributeValue, "")
    end
    if respond_to?(method)
      (args.empty? ? send(method) : send(method, args)).to_s
    else
      "missing tag: #{tag}"
    end
  end
end