Can the result of an esi:include or esi:eval statement be stored in an esi variable?

StackOverflow https://stackoverflow.com/questions/11870566

  •  25-06-2021
  •  | 
  •  

Вопрос

I would like to store the result of an ESI include or eval block in an ESI variable. The contents of the include is outside of my control. Its format is JSON. I've tried all of the following to no avail. The variable ends up as an empty string.

<esi:assign name="variable_name">
'<esi:include src="$(url)" method="post" entity="$(param)" />'
</esi:assign>
<esi:assign name="variable_name">
'<esi:eval src="$(url)" method="post" entity="$(param)" />'
</esi:assign>

<esi:assign name="variable_name">
'''<esi:include src="$(url)" method="post" entity="$(param)" />'''
</esi:assign>
<esi:assign name="variable_name">
'''<esi:eval src="$(url)" method="post" entity="$(param)" />'''
</esi:assign>

The ESI server I'm testing on is Akamai's ETS.

Это было полезно?

Решение

This is the solution as provided by Akamai's support team. Quite convoluted, but it works wonderfully.


File: json.txt

{ "a" : 1, "b" : 2 }

File: frag.esi

<esi:text><esi:assign name="val">'''</esi:text><esi:include
src="json.txt"/><esi:text>'''</esi:assign></esi:text>

File: container.esi

<esi:eval src="frag.esi" dca="esi" />

<esi:vars>
val = $(val)
</esi:vars>
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top