diff --git a/vendor/plugins/hobo/hobo/taglibs/core.dryml b/vendor/plugins/hobo/hobo/taglibs/core.dryml index 5b37bc5..47bb9ba 100644 --- a/vendor/plugins/hobo/hobo/taglibs/core.dryml +++ b/vendor/plugins/hobo/hobo/taglibs/core.dryml @@ -4,7 +4,10 @@ It's the DRYML equivalent of Ruby's `send` method. --> - <%= send(tag.gsub('-', '_'), attributes, parameters) %> + <% tag_ = tag.gsub('-', '_') %> + <%= self.class.method_defined?(tag_) ? + send(tag_, attributes, parameters) : + content_tag(tag, parameters.default, attributes) %> @@ -15,13 +18,22 @@ Using regular DRYML conditional logic it is rather akward to conditionally wrap ### Usage For example, you might want to wrap an `` tag in an `` tag but only under certain conditions. Say the current context has an `href` attribute that may or may not be nil. We want to wrap the img in `` if `href` is not nil: - + -{: .dryml} +{: .dryml} --> - <% parameter ||= :default %> - <%= when_ ? send(tag, attributes, { parameter.to_sym => parameters[:default] }) : parameters.default %> + <% parameter ||= :default + tag_ = tag.gsub('-', '_') if when_ %> + <%= if when_ + if self.class.method_defined?(tag_) + send(tag_, attributes, { parameter.to_sym => parameters[:default] }) + else + content_tag(tag, parameters.default, attributes) + end + else + parameters.default + end %>