Method: Zafu::Process::Conditional#expand_if
- Defined in:
- lib/zafu/process/conditional.rb
#expand_if(condition, new_node_context = self.node, alt_markup = @markup) ⇒ Object
Expand blocks with conditional processing enabled (else, elsif, etc).
Parameters
-
condition- ruby condition for the conditional execution. -
new_node_context- (optional) new node context to enter if the clause succeeds. -
alt_markup- (optional) alternative markup to use for the ‘else’, ‘elsif’ clauses.
65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/zafu/process/conditional.rb', line 65 def (condition, new_node_context = self.node, alt_markup = @markup) res = "" res << "<% if #{condition} %>" with_context(:node => new_node_context) do res << wrap() end only = method == 'case' ? %r{^[A-Z]|else|elsif|when} : %w{else elsif when} res << (:in_if => true, :only => only, :markup => alt_markup) res << "<% end %>" res end |