Re: [Rails] .erb question
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
In ERB, `<%` denotes code, the 'result' of which doesn't get inserted,
and `<%=` denotes code, the 'result' of which does get inserted. Thus,
I expect you're finding that the `picture.title` gets inserted, but
the `n` doesn't. Try changing the line to something like:
<span id= "<%= n %>" ><%= picture.title %></span>
Peace,
tiredpixel
On 19/10/2013 22:15, Dave Castellano wrote:
> Hi,
>
> I need to use a variable set in erb to give an element an ID...
>
> For example:
>
> In view...
>
> <% n = 1 %>
>
> then
>
> <span id= "<% n %>" ><%= picture.title %></span>
>
>
> ...can't figure out how to set the ID of the span element above.
>
> Any help would be appreciated
>
> Dave
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.20 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
iQEcBAEBAgAGBQJSYv/gAAoJEOFolTkanF7V+tgIAIZnBNq7YSVviwSsmG0rG0Ty
d1uCRHJ7zmkoI3a6wMe8jIFGcrJHZKLCnhuP61PN1J8JKbOfl3TR544jy0YDV+N0
wUz2+wOw8JEF/oqBBVOb2eiwB4A8HsshkTb2P9n+yLkXDVp+OdhJzqDX/yROJvUp
GdQw8Ihnoje88F9UVVRzDjsaxF7MO25fhGaC2od9Q8a6eun6fOGHTApncyTim8Sd
OeSW7Ez9Ucbr1bUK5AzVdTZwDcdrjfOpdaGxChS5WNpMQAZAQt2buYw9g4z+zCaq
8jsANN71pGCqZDlW2JV8Ary143WKhN6eSm0nNxOISs33pN81FdLCmlFJ2EPfbu0=
=YOpg
-----END PGP SIGNATURE-----
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/5262FFE0.1080802%40tiredpixel.com.
For more options, visit https://groups.google.com/groups/opt_out.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home