conditional haml - if else nesting

笑着哭i 提交于 2019-12-02 22:46:51

You can use a ternary operator to conditionally apply the style attribute:

#content-inner{ :style => @transparency ? "background: url(../../../images/illustrations/" + @transparency + ") no-repeat 88% 50%" : '' }
  #main-block

For a more complicated arrangement, for example manipulating multiple hash attributes, it's best to either use a helper method, or to move the common content to a partial.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!