I am trying to figure out how to put Ruby code into a HAML file so I can determine which controller the request came through, and set some appropriate settings.
I added this code to the top of the file:
ruby:
active_is = "#{request[:controller]}/#{action_name}"
But it crashed with the error saying:
Illegal nesting: nesting within plain text is illegal.
Does that mean that my syntax is off? How do I fix this?
Thanks!
Language filters are preceded by the colon, not the reverse:
:ruby
active_is = "#{request[:controller]}/#{action_name}"
More often than not, though, it's easier to just use -
:
- active_is = "#{request[:controller]}/#{action_name}"
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.