Is there any business at Haml-Coffee?

I would like to do the following in Haml-Coffee:

- case msg.type - when "usertext" = msg.body - when "direct" = msg.content.kbcontent_body 

But I get the error "Reserved word" "

I suspect this is not supported by Haml-Coffee.

+6
source share
2 answers

There is no case statement in CoffeeScript. You want a switch - the case keyword is the equivalent of JavaScript when , and, like many dropped JavaScript keywords, are reserved in CoffeeScript. Also, I'm not 100% positive and I don't have the Haml-Coffee test right now, but I think you need to indent the switch body.

+1
source

Before the question was edited, the main phrase was:

Is there a case argument in HAML?

Answer: there really is a case in vanilla Haml !

 %p - case 2 - when 1 = "1!" - when 2 = "2?" - when 3 = "3." 
+22
source

Source: https://habr.com/ru/post/908632/


All Articles