Class: Marko::Markup::MacroProcessor
- Inherits:
-
Object
- Object
- Marko::Markup::MacroProcessor
- Extended by:
- Pluggable
- Defined in:
- lib/marko/markup/macro.rb
Overview
Macro processor
Instance Method Summary collapse
- #<<(macro) ⇒ Object
-
#initialize ⇒ MacroProcessor
constructor
A new instance of MacroProcessor.
- #process(text, obj) ⇒ Object (also: #call)
Methods included from Pluggable
Constructor Details
Instance Method Details
#<<(macro) ⇒ Object
159 160 161 162 163 |
# File 'lib/marko/markup/macro.rb', line 159 def <<(macro) MustbeMacro.(macro) @macros[macro.pattern] = macro macro end |
#process(text, obj) ⇒ Object Also known as: call
165 166 167 168 169 170 |
# File 'lib/marko/markup/macro.rb', line 165 def process(text, obj) fail 'No macro registered' unless @macros.any? String.new(text).tap {|str| @macros.values.each{|m| m.gsub!(str, obj) } } end |