Hi,
One of the crucial pieces of my application is the ability to create
footnotes. I implemented these in Django a few months back. They
worked something like this:
... foo foo {% footnote %}This is a footnote{% endfootnote %} foo
foo ...
... bar bar {% footnote %}This is another footnote{% endfootnote
%} bar bar ...
...
...
{% all_footnotes %}
and were rendered like this:
... foo foo [1] foo foo ...
... bar bar [2] bar bar ...
...
...
1. This is a footnote
2. This is another footnote
Now that I'm switching over to Jinja2, I'd like to re-implement this
feature. If I can't, I'll probably stick with Django templates. An
ideal solution would introduce a minimum of syntax, and for
convenience's sake, it would define footnotes with tags instead of
functions.
I've been thinking about how to approach this problem for a while, but
I haven't had any success.
At first I thought about using macros, but I need some way to
"collect" the macros as I go and automatically replace them with links
to the notes at the bottom of the page. I don't know how to do this,
or if it can be done. This suggested that I look into writing an
extension instead. But having read more about Jinja2, I realize that I
was able to implement this footnote system because I had access to
Django's mutable context variable. Since Jinja2 has an immutable
context, I have no idea how I could do the same here. Eval context
seemed promising, but I'm not sure how to keep track of it while a
page is being rendered.
I'm totally out of ideas at this point and would really appreciate
some advice and guidance. How could I create a footnote system in
Jinja2? And is it possible to create one similar to the Django
templates system I described above?
Thanks for reading.
--
You received this message because you are subscribed to the Google Groups
"pocoo-libs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/pocoo-libs?hl=en.