Hobo Cookbook

View Source



Wrap the body in the tag specified by the tag attribute, iff when is true.

Using regular DRYML conditional logic it is rather akward to conditionally wrap some tag in another tag. This tag makes it easy to do that.


For example, you might want to wrap an <img> tag in an <a> 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 <a> if href is not nil:

<wrap when="&this.href.present?" tag="a" href="&this.href"><img src="&this.img_filename"/></wrap>

Show Source


No comments to display