Reputation: 5648
I am new to Ruby on Rails, and I setup a starter package on my local machine.
As I looked through it I found this in one of the html.haml files:
%p
Welcome #{@email}!
%p You can confirm your account email through the link below:
%p= link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token => @token)
I think that the !
is part of the message to the user and I believe the @email
is a variable with string text and is the person's email address.
However, I don't quite understand what the #
does with the email. From the Haml documentation I believe that the #
symbol makes a div as show from the example on the Haml site, but this doesn't really make sense so if anyone could explain what it means I would greatly appreciate it.
Haml site example:
#content
.left.column
%h2 Welcome to our site!
%p= print_information
.right.column
= render :partial => "sidebar"
Upvotes: 0
Views: 121
Reputation: 79743
#
is for setting the id of an element if it is part of an element, possibly an implicit div
.
In plain text (i.e. not in an element definition) the #{...}
syntax does interpolation. The contents are evaluated as Ruby, and the result is inserted into the output at this point. In this case, if @email
had the value [email protected]
the result would be:
Welcome [email protected]!
If you want to start a line with some interpolation you can escape the #
with \
, otherwise it would be interpreted as the start of an element and you would likely get an error.
Upvotes: 5