Hi --

I've got some ESI variables in a template, and am trying to assign
their values to Ruby variables. Strangely, it seems to work and not
work at the same time.

Here's the relevant part of the template, with some comments and
followed by explanation:

  <esi:vars>
  <% state = "$(GEO{'region_code'})" %>
  <% city = "$(GEO{'city'})" %>

  State: <%= state %><br/>            # CT
  City: <%= city %><br/>                # NEWHAVEN

  Massaged city: <%= CITIES[state][city] %>    # Uses the literal EIS
strings

  </esi:vars>

The CITIES hash provides corrected city names when the ESI value lacks
spaces -- so, for example, CITIES["CT"]["NEWHAVEN"] is "New Haven".
The state and city variables display correctly in those middle lines
-- but when addressing the CITIES hash with those same variables,
they're evaluated as the literal ESI strings ("$(GEO..."). The
evidence for this is that I've seeded the hash:

  CITIES["$(GEO{'region_code'})"]["$(GEO{'city'})"] = "KEYING LITERAL
ESI STRINGS"

and that "KEYING..." string appears next to "Massaged city".

So, strange as it sounds, the variables seem to be differently bound
depending on which line is being evaluated. So far I've not been able
to puzzle through the sequence of events in such a way as to come up
with a way to inject the state and city values into a call to the
CITIES hash. I'd be interested in any ideas or solutions people might
have.


David

--
David A. Black
The Well-Grounded Rubyist -- http://www.manning.com/black2
The Compleat Rubyist -- http://www.compleatrubyist.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@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to