Assiging an attribute in rhtml


#1

This might be a stupid question, but I am quite the noob and I can’t
find it in agile.

I have this in my html:

<%= dynamic content %>

and I want to put

<%= dynamic content %>

so I can put it as a target from another page.

cheers,

Jason


#2

On 12/10/05, Jason removed_email_address@domain.invalid wrote:

<%= dynamic content %>

<%= dynamic content
%>


#3

jeremyevans0 wrote:

On 12/10/05, Jason removed_email_address@domain.invalid wrote:

<%= dynamic content %>

<%= dynamic content
%>

Thanks. I’m saying to myself duuuh! Brainfart.


#4

On Dec 10, 2005, at 3:06 PM, Jason wrote:

Rails mailing list
removed_email_address@domain.invalid
http://lists.rubyonrails.org/mailman/listinfo/rails

Try this:

<span class=‘class’ name=<%= @ruby_variable %> ><%= dynamic content
%>

-Ezra Z.
WebMaster
Yakima Herald-Republic Newspaper
removed_email_address@domain.invalid
509-577-7732


#5

I’m a noob also. I believe the answer is to rap the @ruby_variable
in the erb delimiters so

name=<%=@ruby_variable %>

bruce


#6

You should quote the name. Avoid problems and make “good” html.

 <span class='class' name='<%= ruby_var %>'><%= dynamic content 

%>

My current project uses many of these for using same structure with
different
classes:

 <span class='<%= class_var %>' id='<%= id_var %>'><%= dynamic 

content
%>

Also: ‘id’ should generally be used rather than ‘name’. I believe it’s
safe
to say that ‘id’ will respond
everywhere ‘name’ would, plus ‘id’ can be used as an object: xyz.style…
(But sometimes I use the same ‘name’ for multiple objects to do group
operations: document.all(‘myButtons’).style…)

Rich C.

----- Original Message -----
From: “Bruce B.” removed_email_address@domain.invalid
To: removed_email_address@domain.invalid
Sent: Saturday, December 10, 2005 4:37 PM
Subject: Re: [Rails] assiging an attribute in rhtml


#7

brucebalmer wrote:

I’m a noob also. I believe the answer is to rap the @ruby_variable
in the erb delimiters so

name=<%=@ruby_variable %>

bruce

hey bruce, the solution jeremy posted works. I had thought that putting
putting ruby code <%= @variable %> in quotes ‘<%= @variable %>’ would
force a string and not ruby.

But that works.


#8

By way of correction of myself…

Also: ‘id’ should generally be used rather than ‘name’. I believe it’s safe
to say that ‘id’ will respond everywhere ‘name’ would…

You still need to use ‘name’ in form variables, ‘id’ is not adequate.

<input type=text NAME=whatever…

Rich C.

----- Original Message -----
From: “Rich C.” removed_email_address@domain.invalid
To: removed_email_address@domain.invalid
Sent: Saturday, December 10, 2005 6:46 PM
Subject: Re: [Rails] assiging an attribute in rhtml