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, options = {}) ⇒ 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, options = {}) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/redmine/wiki_formatting/macros.rb', line 29 def exec_macro(name, obj, args, text, ={}) = Redmine::WikiFormatting::Macros.available_macros[name.to_sym] return unless if [:inline_attachments] == false Redmine::WikiFormatting::Macros. = false else Redmine::WikiFormatting::Macros. = true end 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 t(:error_macro_does_not_accept_block) else send(method_name, obj, args) end rescue => e %|<div class="flash error">#{t(:error_can_not_execute_macro_html, :name => name, :error => e.to_s)}</div>|.html_safe end end |
#extract_macro_options(args, *keys) ⇒ Object
57 58 59 60 61 62 63 64 |
# File 'lib/redmine/wiki_formatting/macros.rb', line 57 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
25 26 27 |
# File 'lib/redmine/wiki_formatting/macros.rb', line 25 def macro_exists?(name) Redmine::WikiFormatting::Macros.available_macros.key?(name.to_sym) end |