[Koha-devel] quoting " and ' in variables (was bugzilla #148)
paul POULAIN
paul.poulain at free.fr
Thu Dec 19 05:46:02 CET 2002
Here is the mail we exchanged in the html-template ml about " and ' in
variables.
We have to modify ALL our templates (in every languages) to do "right"
templates imho.
Stefan Seifert a écrit:
> paul POULAIN wrote:
>
>> Hi,
>> it's my 1st post here. I work on the koha project (www.koha.org) and
>> release manager, and we face a problem nobody can solve in our devel
>> list :-(((
>>
>> In the template we have :
>> <input type="text" name="test" value="<TMPL_VAR name="test">">
>>
>> and we "replace it with the $template->param(test => $test)
>>
>> Our problem is that when $test='here is "daddy"';
>> the result is :
>> <input type="text" name="test" value="here is "daddy"">
>> which is bad html, and result in a field containing "here is"
>> ("daddy" is lost)
>> If we replace " by ' in the template, we face the same problem with
>> "it's me again".
>>
>> So, how could we solve this ?
>>
> the easiest way is to just do an
> $test =~ /"/"/g;
> $template->param(test => $test);
>
> so the output would be <input type="text" name="test" value="here is
> "daddy"">
>
> another way is to use HTML::Templates escaping capabilities like this:
> <input type="text" name="test" value="<tmpl_var name="test"
> escape="HTML">">
> which does roughly the same but with more translations. This should
> be the prefered solution, if you don't need extended capabilities.
>
> Stefan Seifert
--
Paul POULAIN
Consultant indépendant en logiciels libres
responsable francophone de koha (SIGB libre http://fr.koha.org)
More information about the Koha-devel
mailing list