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
--
Posted via http://www.ruby-forum.com/.
--
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit
https://groups.google.com/d/msgid/rubyonrails-talk/d400c14308cc25a4693051ff9fca34e6%40ruby-forum.com.
For more options, visit https://groups.google.com/groups/opt_out.
-----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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
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.
And, of course you know this, the first character of an ID cannot be numeric in HTML. (It must begin with an alpha character or an underscore.) Walter On Oct 19, 2013, at 5:55 PM, tiredpixel wrote:> -----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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > 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.-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/039678D4-6F65-48C1-BCB2-B420F1EC3182%40wdstudio.com. For more options, visit https://groups.google.com/groups/opt_out.