Hi David,

I'd prefer getting the values from request.env[]. I'd reduce complexity across your application. It also reduces the number of times the document is processed.

As Jens said ERB comes before ESI.

    App (erb) => Server (esi) => World

Did you try accessing those HTTP vars (HTTP_GEO) in your Rails app?
Do you use Varnish using a pimped version of the GeoIP plugin?

best
Florian


David Black schrieb:
Hi --

On Wed, Jul 20, 2011 at 12:03 PM, "Florian Aßmann"<florian.assm...@email.de
wrote:


Hi David,

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.
Why mixing them anyway?


We need to correct/normalize the cities that have spaces removed, like
NEWYORK.


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

State:<%= state %><br/>  # CT
City:<%= city %><br/>  # NEWHAVEN
<% # becomes: %>
State: $(GEO{'region_code'})
City: $(GEO{'city'})
<% # so the ESI processor replaces them after ERB %>



But they display CT and NEWHAVEN, which suggests that they've already been
ESI-processed.


Massaged city:<%= CITIES[state][city] %>  # Uses the literal EIS strings
<% # becomes: %>
Massaged city:<%= CITIES["$(GEO{'region_code'})"]["$(GEO{'city'})"]
                    # =>  "KEYING LITERAL ESI STRINGS" %>
<% # so the ESI processor replaces ... nothing. %>


I'm still mystified as to why/how the same variables can behave in both ways
(literal strings and interpolated strings).


</esi:vars>
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.
You can:

[ideas snipped]

As I mentioned in my last response we're going to do it in JavaScript, but
I'll have a look at your ideas which will probably increase my ESI
understanding.


David


--
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