简体   繁体   中英

Where is Ruby/Rails/Hobo dryml <if> documentation?

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM