Template Toolkit - Parse Error on RTF files

T

Tony

Is the Template Toolkit supposed to work with RTF templates? They are
mentioned in the tutorial, but I'm getting the following error:

file error - parse error - unexpected token (})

My template document looks like this, when viewed within Word:

[% address_line_1 %]
[% address_line_2 %]

Here are the transactions:

[% FOREACH transaction = transactions -%]
[% transaction.date %]
[% transaction.time %]
[% transaction.amount %]
[% END%]

But when I look at the raw RTF, I see:
 
C

Clayton L. Scott

In comp.lang.perl.modules Tony said:
Is the Template Toolkit supposed to work with RTF templates? They are
mentioned in the tutorial, but I'm getting the following error:
For some reason, the RTF has put random "{" and "}" characters in the
middle of normal text - and the Template Toolkit is failing because of
this.
Has anyone come across this before?

Word is notorious for writting less than stellar RTF.

The first thing I would try is cleaning up the template by removing the
braces (and any that match ) that interfere with the parsing of the
template

\fs20\cgrid {[% address_line_1 %]
\par [% address_line_2 %]
\par
\par Here are the transactions:

[% FOREACH transaction = transactions -%]
\par [% transaction.date %]
\par [% transaction.time %]
\par [% transaction.amount %]
[% END%]
\par
\par
\par }

If that doesn't work I'd try making a sample output
file, and then add the TT directives in a text editor.

Also consider using some of the RTF modules on CPAN
to generate your RTF


A valid RTF file isn't always going to be a valid template and a valid
template isn't always going to be a valid RTF file.


Clayton
 
H

henq

Tony said:
Is the Template Toolkit supposed to work with RTF templates? They are
mentioned in the tutorial, but I'm getting the following error:
...
For some reason, the RTF has put random "{" and "}" characters in the
middle of normal text - and the Template Toolkit is failing because of
this.

Has anyone come across this before?



It's not "the RTF has" but "MS Word has". Don't type your TT tags using
Word.
Enter your TT tags in Notepad, copy them and then use Paste Special > Plain
Text form the Edit menu.

~henq
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top