Feature question: substitute to parent element in loops

27 views
Skip to first unread message

Florian Lagg

unread,
Jul 4, 2012, 1:25:38 PM7/4/12
to we...@googlegroups.com
Hi, 

I currently use Templetor to create pdf-files out of an xml-document (more exactly: rml). To make it possible for non-programmers to write templates i've a nice feature idea:

let me give you an example:

This is a snippet out of this document - as you can see a loop:
    <blockTable colWidths="161.0,161.0,161.0" style="Tabelle1">
      $for c in ["a", "b", "c", "d"]:
     <tr>
       <td>
         <para style="Table Contents">${loop.index}. Zeile:</para>
       </td>
       <td>
         <para style="Table Contents">$c</para>
       </td>
       <td>
         <para style="Table Contents">escaping $$</para>
       </td>
     </tr>
    </blockTable>
 
the for-loop has to start before the <tr> element - therefore it cannot be entered in openoffice.
It would be cool to do something like that:

    <blockTable colWidths="161.0,161.0,161.0" style="Tabelle1">
      <tr>
        <td>
          <para style="Table Contents">$:parent.tr{for c in ["a", "b", "c", "d"]:}${loop.index}. Zeile:</para>
        </td>
        <td>
          <para style="Table Contents">$c</para>
        </td>
        <td>
          <para style="Table Contents">escaping $$</para>
        </td>
      </tr>
    </blockTable>

I didn't think a lot 'bout syntax, but I think this gives you the idea:
the '$:parent' should advice Templetor to the parent element of given type. Therefore the for-loop is moved just before the parent <tr> and the document is perfectly editable in OpenOffice.

What do you guys think?

Hope you like it.
Thanks, Florian.
Reply all
Reply to author
Forward
0 new messages