Thanks, Colin!  I'd like to give the user the flexibility to make a
template that interpolates objects within it.  Sort of like a mail
merge.  The templates are stored as text entries in a database.  The
idea is, say you have something like this as a text entry in the
database

Dear Mr. <%= @person.lastname %>,
We understand that your favorite programming language is <%=
@person.language %>.

Then, if the user was accessing the person show form for @person 2
with lastname Smith and language Ruby, it would display

Dear Mr. Smith,
We understand that your favorite programming language is Ruby.

I am so open to ideas :)  Right now I'm imagining building an XML
parser, and identifying the fields as tags, then replacing them with
the appropriate objects, but I was wondering if there was a more
direct (or better) way.

Again, thanks,
Craig

On Feb 27, 11:43 am, Colin Law <[email protected]> wrote:
> On 27 February 2010 16:30, Dudebot <[email protected]> wrote:
>
> > OK, here's what I have in app/views/molds/show.html.erb:
>
> > <tr><td><%= @mold.body.gsub( "\n", "<br />" ) %></td></tr>
>
> > The controller finds @patient, and @patient.id = 2
>
> > If @mold.body = "The patients id is <%= @patient.id %>"
>
> > Then the view displays
>
> > The patients id is <%= @patient.id %>
>
> > rather than
>
> > The patients id is 2
>
> I don't think many of the readers have actually worked out what you
> are asking.  That is, if I am correct, have a string produced by a
> controller where the string includes the literal text <%= .. %> and
> have this interpolated somehow in the view.  Perhaps if you were to
> explain why you are trying to achieve this someone may suggest a
> better way of solving the problem.  Are the strings containing <%= ..
> %> stored in the db for example?
>
> Colin

-- 
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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to