ruby-on-railshaml

How do I make a simple dot "." in HAML?


In my Ruby on Rails Project I use HAML, I need to translate something like this

<div>foo <a>bar</a>.<div>

into HAML. It should look like:

.divclass
  foo
  %a bar
  .     

The period at start is not working because its used by HAML. So how can I use a period as content?

Even with building a span around its not working, again the period is taken as something special.

I think there is an escape mechanism but I can't find it.


Solution

  • It is escaped with \

    like this

    \.
    

    See Escaping \ in the HAML reference.

    Update: Using HAML's succeed (as in this answer) is a better solution if you need a dot in the end of the sentence (to prevent unnecessary white space).