Note that you don't have to use the Django template engine to render things.

For one thing, if you found a less problematic templating engine, using it
as
well doesn't prevent you from using Django's template engine for other
pages.

You could also roll your own by coming up with, for example, a TeX friendly
syntax for variable substitution (by which I mean, doesn't collide with
syntax
that you will be using - best would be coming up with something that is
actually illegal in TeX), and process things with a big regex or had coded
parser..  You could parse this directly into the output, or this could be a
loading stage that converts the file to a Django template (or engine of your
choice) file, where the TeX/LaTeX stuff that looks like template specials is
converted to a quoted structure that renders as the original.

A final approach would be to use TeX definitions to perform your variable
substitutions, prepending a stanza that makes the definitions at render
time.  (Though making this work where you want template loops is much
harder.)

On Wed, Mar 13, 2013 at 2:15 PM, Ken <t...@anl.gov> wrote:

> Actually, that's exactly what I'm trying to do.  I have database tables
> whose
> columns contain TeX fragments.  I am trying to generate various file
> outputs
> from database searches - TeX, pdf, etc.
>
> I could construct the tex file on the fly with python strings as you
> suggest but
> that's rather cumbersome.  It's simpler with a template.
>
> I've also considered using the xml.element api to construct my own template
> but that would set me back several weeks.  I'm trying to finish. :/
>
> I have something that almost resembles a template.  It is not the most
> flexible
> or elegant but it works.  I have a single replacement string between
> \begin{document} and \end{document} and I simply replace this one token
> with a
> string.replace()
>
>
>
>
> On Wednesday, March 13, 2013 11:39:18 AM UTC-5, Drew Ferguson wrote:
>
>> On Wed, 13 Mar 2013 07:01:45 -0700 (PDT)
>> Ken <t...@anl.gov> wrote:
>>
>> > I would like to write a tex/latex file with django tags in it.  Load it
>> > with the template loader and render it with a context.  The problem is
>> > that my tex/latex file has quite a few '{%' in them.   They are
>> > conventional in TeX for writing readable macros and are used to escape
>> > the newline.  I could try rewriting them but before I do, I thought I'd
>> > ask if this is even worth tackling.  TeX uses curly braces as grouping
>> > and percent signs as a comment.
>> >
>> > The TeX file would look rather confusing but the more important
>> question
>> > is what the loader does when it sees braces and brace comments.  Is it
>> > possible to reassign the block and variable tags?
>> >
>> > Thanks
>> >
>> >
>>
>> I have done this in the past (with Plone rather than django) by calling a
>> python wrapper script to generate a file which latex can process;
>> essentially construct the Latex source as python strings
>> and have the script assemble the components you want. The objective was
>> to
>> generate a PDF file by Latex with variables fed from SQL & a web page.
>> But
>> this may not be what you are interested in.
>>
>> Are you trying to render a Latex source document as a web page?
>>
>> --
>> Drew
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to