Module: Redmine::WikiFormatting::Macros::Definitions
- Included in:
- ApplicationHelper
- Defined in:
- lib/redmine/wiki_formatting/macros.rb
Instance Method Summary collapse
- #exec_macro(name, obj, args, text) ⇒ Object
- #extract_macro_options(args, *keys) ⇒ Object
-
#macro_exists?(name) ⇒ Boolean
Returns true if
name
is the name of an existing macro.
Instance Method Details
#exec_macro(name, obj, args, text) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/redmine/wiki_formatting/macros.rb', line 27 def exec_macro(name, obj, args, text) = Redmine::WikiFormatting::Macros.available_macros[name.to_sym] return unless method_name = "macro_#{name}" unless [:parse_args] == false args = args.split(',').map(&:strip) end begin if self.class.instance_method(method_name).arity == 3 send(method_name, obj, args, text) elsif text raise "This macro does not accept a block of text" else send(method_name, obj, args) end rescue => e "<div class=\"flash error\">Error executing the <strong>#{h name}</strong> macro (#{h e.to_s})</div>".html_safe end end |
#extract_macro_options(args, *keys) ⇒ Object
49 50 51 52 53 54 55 56 |
# File 'lib/redmine/wiki_formatting/macros.rb', line 49 def (args, *keys) = {} while args.last.to_s.strip =~ %r{^(.+?)\=(.+)$} && keys.include?($1.downcase.to_sym) [$1.downcase.to_sym] = $2 args.pop end return [args, ] end |
#macro_exists?(name) ⇒ Boolean
Returns true if name
is the name of an existing macro
23 24 25 |
# File 'lib/redmine/wiki_formatting/macros.rb', line 23 def macro_exists?(name) Redmine::WikiFormatting::Macros.available_macros.key?(name.to_sym) end |