Announcement

Do not use the forums to submit bug reports, feature requests or patches, submit a New Ticket instead.

#1 2008-07-02 10:53:21

plungerman
New member
Registered: 2007-10-29
Posts: 6

Xinha and Django template tags mixed with HTML

greetings,

i posted a similar question back in may but received no feedback, so i thought that i would give it a go again with a similar problem and see if anyone has a bit of guidance to share.

basically, we have a table that is built dynamically using Django template tags, specifically the for loop tag.  here you can see the proper content:

<table>
    <tr>
        <th>Name</th>
        <th>Price</th>
    </tr>
    {% for wine in whites %}
    {% include "product/product_table.html" %}
    {% endfor %}
</table>

as you can see, we simply build the table rows dynamically with a for loop and an include that has the HTML for constructing the table row itself (not import to include here).

when you edit the above content with a xinha textarea, xinha seems to try to "correct" the HTML by moving the django tags  above the table code and adding the tbody tag:

{% for wine in whites %}
{% include "product/product_table.html" %}
{% endfor %}

  <table>
    <tbody>
      <tr>
        <th>Name</th>
        <th>Price</th>
      </tr>
    </tbody>
  </table>

is there anyway to prevent Xinha from trying to convert the code to valid HTML?  of course it is not valid, but we need it to be invalid for the server side code to provide the rest of the HTML, which then makes it valid.  perhaps there is an on/off switch for this behaviour.  any suggestions would be greatly appreciated.

thanks in advance.

yours,

steve

Offline

#2 2008-07-02 13:26:03

Pioden
Xinha Community Member
From: Bangor, Wales
Registered: 2008-06-06
Posts: 39
Website

Re: Xinha and Django template tags mixed with HTML

I guess you could write a regex which converts it back to Django template tags after Xinha has finished with it ... More of a simple workaround rather than a proper solution though!

Just an idea :-)

Offline

#3 2008-07-03 05:17:12

MyLocalFOCUS.com
Xinha Community Member
Registered: 2007-02-17
Posts: 31

Re: Xinha and Django template tags mixed with HTML

You could even perhaps rather than create the table and put the code inside it, make the whole table from code...

{ tableTop }
{ Your code }
{ your code }
{ your code }
{ tableBottom }

Offline

#4 2008-07-03 14:39:13

plungerman
New member
Registered: 2007-10-29
Posts: 6

Re: Xinha and Django template tags mixed with HTML

thanks for the suggestion about coding the entire table.  that is, in fact, exactly what i did, more or less.  as the HTML is handled by clients who do not have much experience with source level coding, let along template tags, i decided to remove as much of the template code as possible by using a type of include call.  i was blinded by the urge to have everything simply work perfectly well with mixed HTML and django content, but the fact is that you have to make certain sacrifices when using any wysiwyg editor with a serverside language.  clients become confused when they see strange code amongst their content, but we simply must educate them about it and tell them not to worry and not to touch it.  might be a bit delicate but i see no other option, short of hiding any not HTML tags like {% %} and {{ }}.  now that would be sweet!

Offline

#5 2008-07-06 10:29:53

MyLocalFOCUS.com
Xinha Community Member
Registered: 2007-02-17
Posts: 31

Re: Xinha and Django template tags mixed with HTML

Look up xinha_config.specialReplacements on http://xinha.webfactional.com/wiki/Docu … iablesList for a possible way around the issue.

Offline

Board footer

Powered by FluxBB