Reputation: 1355
I'm trying to port a ruby/rails/hobo app. How do I use the "if" tag in dryml?
<if:dist_image>
<div>
<a href="#{image.url}">
<img src="#{image.url :thumbnail}" title="Click to enlarge"/>
</a>
</div>
</if>
dist_image may be an object (containing an image), or it may be nil. Nothing seems to work. Also I can't find any documentation for conditional operators in dryml.
I get the error:
"undefined method `url' for "<img alt=\"Assets\" src=\"/assets/\">":ActionView::OutputBuffer"
Update: Hi everyone, thanks for your suggestions.. I tried all of the following:
<if test="&dist_image">
<if test="&dist_image.blank?">
<if test="dist_image.blank?">
<if test="dist_image">
all of them produce the same error. :( I followed the syntax in the documentation but it doesn't work.
Upvotes: 0
Views: 247
Reputation: 10026
The problem isn't with your if statement, it's with #{image.url}. You probably want #{this.image.url} or #{this.url} or something. <if:dist_image>
sets the context to this.dist_image
, so it does the equivalent of this = this.dist_image
.
Calling it the way you do means that you're calling a helper called 'image' instead of getting the image attribute from your object.
BTW, you probably don't need to look up the documentation for <if>
, what you probably need is the documentation for the DRYML context, which is also in the DRYML guide.
Upvotes: 1