In a controller I have @message = "The size is <% @a.size %>." In the view I have <%= @message %> which, sadly, produces The size is <% @a.size %>. rather than, say, The size is 4. If I try <%= <%= @ message %> %> I get a syntax error. Is there a solution? -- 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 post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
The <% ... %> style of interpolation is specific to ERB templates;
it''s not used to interpolate in Ruby strings. What you''re
looking for
is:
@message = "The size is #{@a.size}"
I suggest familiarizing yourself with Ruby before diving into Rails.
On Thu, Feb 11, 2010 at 13:43, Ralph Shnelvar
<lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>
wrote:> In a controller I have
> @message = "The size is <% @a.size %>."
>
> In the view I have
>
> <%= @message %>
>
> which, sadly, produces
> The size is <% @a.size %>.
>
> rather than, say,
> The size is 4.
>
>
> If I try
> <%= <%= @ message %> %>
> I get a syntax error.
>
>
> Is there a solution?
> --
> 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 post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com.
> For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
Mat Brown wrote:> The <% ... %> style of interpolation is specific to ERB templates; > it''s not used to interpolate in Ruby strings. What you''re looking for > is: > > @message = "The size is #{@a.size}" > > I suggest familiarizing yourself with Ruby before diving into Rails.Ok ... I tried to make my problem too simple. Stupid me. The real problem is closer to this: --------------------------------------- Controller: @message = I18n.t(''some_msg_id'') - - - - - somefile.yml: some_msg_id: "The size is #{@a.size}" - - - - - view: <%= @message %> --------------------------------------- How do I do what I want to do. I want to do the interpolation in the view and not beforehand. -- 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 post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Feb 11, 7:01 pm, Ralph Shnelvar <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> How do I do what I want to do. I want to do the interpolation in the > view and not beforehand.The I18n stuff has a convention for interpolation - take a look at the docs Fred -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Frederick Cheung wrote:> On Feb 11, 7:01�pm, Ralph Shnelvar <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: > >> How do I do what I want to do. �I want to do the interpolation in the >> view and not beforehand. > > The I18n stuff has a convention for interpolation - take a look at the > docsAlso check out fast_gettext. To me, at least, it''s a lot nicer.> > FredBest, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- 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 post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.