Forum OpenACS Q&A: Re: <include> template encodes html

Collapse
Posted by Gustaf Neumann on
Hi Stephen,

The best way to pass values to an includelet is either to use noquote on the include line or to pass the value by reference. The problem you are observing is that the passed argument value (between @-characters) is quoted during the @-substituion of the include arguments, and if the variable is used a second time in the @-notation (in the included snippet), it is quoted again.

Look below for the interesting cases. In (1). there is no @ involved, therefore it is passed as value and needs quoting in the included adp snippet. In (2) we assume we have a variable named 'var' with a value '<'. The value is quoted during the substitution of @var@. In case (3) we use noquote, and in case (4) we use the call-by reference pattern. I would assume that for most uses, call-by-reference is appropriate.

<master>
  <property name="doc(title)">@page_title;noquote@</property>
  <property name="context">@context;noquote@</property>

1: <include src="./i" attribute='<'><hr>
2: <include src="./i" attribute='@var@'><hr>
3: <include src="./i" attribute='@var;noquote@'><hr>
4: <include src="./i" &attribute='var'>
Hope this helps
-gustaf

Collapse
Posted by Stephen Saunders on
Gustaf,

Thank you for your response. The larger question I am trying to raise is should this property be mentioned in the tag documentation? I couldn't find it when I looked.

Collapse
Posted by Gustaf Neumann on
yes, it should. no question. -g
Collapse
Posted by Stephen Saunders on
How would I go about suggesting that?
Collapse
Posted by Gustaf Neumann on
Dear Stephen,

The easiest is probably to write a short bug-report on [1] and to provide - if possible - a patch for packages/acs-templating/www/doc/tagref/include.html

all the best
-gustaf

[1] http://openacs.org/bugtracker/openacs/

Collapse
Posted by Stephen Saunders on
I will do that. Thank you.