You are not logged in.
I use Template Toolkit (http://www.template-toolkit.org/ - template processing system). Directives are inserted in the document within the special markup tags which are '[%' and '%]'.
For example:
[% IF color=="blue" %]
Xinha changes in:
[% IF color=="e;blue"e; %]
or
<input type=hidden name=component_id value=[% component.component_id %]>
Xinha chages in
<input type="hidden" value="[%" name="component_id" />
How I can "say" to Xinha that text within [% %] it mustn't processing?
Offline
It can't really not process them as it causes problems having HTML 'special' characters as input values. What you'd have to do is change the values within the [% %] tags back again before you save.
I don't know if you use PHP or not, but if you do you could do something like this before saving:
<?php
$text = $_POST['text'];
function addquotes ($matches) {
$fixed_tag = str_replace(""e;", "\"", $matches[1]);
return $fixed_tag;
}
$text = preg_replace_callback("/\[%(.*?)%\]/si", "addquotes", $text);
?>
I haven't tested the above, but it should at the least give you an idea of what to do.
Offline
adamp, your offer doesn't solve problem. I can't correctly process on the server side changes like following:
when string
<input type=hidden name=component_id value=[% component.component_id %]>
transformes into
<input type="hidden" value="[%" name="component_id" />
Offline
<input type=hidden name=component_id value=[% component.component_id %]>
it is always recommended to put quotes around your attribute values anyways, maybe if you insert them yourself before hand, like so:
<input type="hidden" name="component_id" value="[% component.component_id %]" />
then maybe the problem will be solved!
Offline
adamp, your offer doesn't solve problem. I can't correctly process on the server side changes like following:
when string<input type=hidden name=component_id value=[% component.component_id %]>
transformes into
<input type="hidden" value="[%" name="component_id" />
This example is a different problem to your original question though.
If you don't put quotes around values, then browsers will split them off wherever a space occurs. It should be simple enough for your users to put quotes around values and at least that way they're writing correct HTML.
Offline
adamp, read my first posting more attentively. I wrote this example in my first posting.
If [% component.component_id %] after work of template processor converts in 843. We also recive correct HTML:
<input type=hidden name=component_id value=843>
Quotes are not required in this case. Especially because we may have following code:
<input type=hidden name=component_id value="[% IF my_param == "2" %][% some_function %][% ELSE %]none[% END %]">
I put quotes. As you see. But it doesn't solve problem:(
Offline
In which case what you're trying to do is not feasible as standard. Xinha is a WYSIWYG, so it has to display any code you give it, but it of course doesn't have the functionality of the template engine.
You could try writing a 'code shielding' function as has been suggested for hiding PHP code, but there's no ready-made solution.
Basically what you would do is have some kind of image that is shown when in WYSIWYG view, where the alt tag of the image has the code being hidden. This wouldn't necessarily work for you however, as putting an image inside an input value causes even more problems.
As long as you don't want to edit the template codes (the [% ... %] bits), you could write a script to pull them all out (using a similar regex to the code I gave before) and hide them in a set of hidden inputs which are then put back in when you save the template.
e.g. say you had this code:
<form action="[% component.formpath %]" method="post">
<input type=hidden name=component_id value=[% component.component_id %]>
<input type="submit" />
You would write some code where each template tag is pulled out into an array that gets passed separately from the WYSIWYG contents, so the first tag becomes something like [tag_1], the second becomes [tag_2] and so on and you then have an array where $array[1] has the value "[% component.formpath %]" and $array[2] has the value "[% component.component_id %]"
You can then pass the array either with the form or as a session value and put them back in before saving the template (i.e. you swap bacl [tag_1] for $array[1] etc.)
In other words, there's no easy solution from the info you've given.
Offline
<input type=hidden name=component_id value=843>
Quotes are not required in this case.
Quotes should always be used.
Especially because we may have following code:
<input type=hidden name=component_id value="[% IF my_param == "2" %][% some_function %][% ELSE %]none[% END %]">
That's invalid HTML, the inner quotes must be entities.
To put it simply, in WYSIWYG mode, Xinha can only deal with perfectly valid HTML. That means that quotes will, and must, be entities except where they delimit an attribute value.
If you want to use invalid HTML such as the above you will have to "massage" it so that is IS valid html when you give it to Xinha, and "massage" the valid html that Xinha gives you back into your invalid-html markup.
James Sleeman
Offline