HAML - what does the “!=” operator do?

本秂侑毒 提交于 2019-12-02 13:48:13

问题


I am looking at some seemlingly standard Haml code right now, but just noticed it starts off with a "!=", and 5 minutes of googling has failed to give me the answer for what it does:

#What does the '!=' mean? 
!= cache_content_if_not_prefetched(params) do
  -if product_live?
    =render :partial => 'products/product_tile'
  -else
    =render :partial => 'products/unavailable_product_tile'

回答1:


Same as using = but doesn't sanitize the HTML

See http://haml.info/docs/yardoc/file.REFERENCE.html#unescaping_html

!= "Look  <up>!"

compiles to

Look <up>!

instead of

Look &ltg;up&gt;



回答2:


That is used for Unescaping html




回答3:


Read this HAML Documentation. It will give you all the answers you require. I just searched for HAML tags.

Do a CTRL+F for !=. != basically valuates Ruby code just like the equals would



来源:https://stackoverflow.com/questions/15489904/haml-what-does-the-operator-do

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