Also, what would be great is if you (or anyone else for that matter) could try to convert some plugins templates to Jinja2. That way, you could tell me what is not clear in the migration guide, or simply still missing from it.
That's something I wanted to try anyway, since I have a few plugins that use (relatively simple) templates.
I semi-randomly picked OnSiteNotificationsPlugin for a first
test. It only has two rather trivial templates.
https://trac-hacks.org/wiki/OnSiteNotificationsPlugin
https://trac-hacks.org/browser/onsitenotificationsplugin/trunk/onsitenotifications/templates/onsitenotification.html?rev=16170
https://trac-hacks.org/browser/onsitenotificationsplugin/trunk/onsitenotifications/templates/onsitenotification_list.html?rev=16170
Instead of actually properly reading through your nice, extensive
notes I first tried the lazy, impatient trial-by-error approach:
I changed the `return "...", data, None` to `return "...", data`
to actually use Jinja.
Then very briefly I looked at the first section of:
https://trac.edgewall.org/wiki/TracDev/PortingFromGenshiToJinja#ChangesintheHTML
I replaced the doctype and <html> as described.
I also searched and found the note about `# extends
"layout.html"`,
but didn't immediately see where that should go, so I switched to:
https://trac.edgewall.org/wiki/TracDev/PortingFromGenshiToJinja/Example#Conversionexample
Since the templates looked so simple, I naively assumed that I was
more or less done and tried running it.
But nothing showed up; not even an error.
So back to reading a tiny bit more, I found out about `#block
title` and `#block content`.
Still nothing, back to reading. I added `${ super() }`.
Finally, I got some errors about `idx`, so I remembered I had to
turn `py:for` into `# for`.
Error about `enumerate`. Found:
https://trac.edgewall.org/wiki/TracDev/PortingFromGenshiToJinja#Noneedforenumerate
But nothing about "odd / even".
The linked site has an example though: `loop.cycle('odd', 'even')`
http://jinja.pocoo.org/docs/dev/templates/#for
Now almost everything seemed to work, except `$item.resource_href
` showed up on the page uninterpreted.
I remembered that I had to use `${item.resource_href}` instead.
That was all I think. Everything seems to work now. That was not
too bad. Maybe I'll try another one later.
Just in case, the resulting templates:
# extends "layout.html"
<!DOCTYPE html>
<html>
<head>
<title>
# block title
Notification: ${message['subject']} ${ super() }
# endblock title
</title>
</head>
<body>
# block content
<h2>Notification: ${message['subject']}</h2>
<pre>${message['body']}</pre>
${ super() }
# endblock content
</body>
</html>
# extends "layout.html"
<!DOCTYPE html>
<html>
<head>
<title>
# block title
Notifications ${ super() }
# endblock title
</title>
</head>
<body>
# block content
<div id="content">
<h2>Notifications</h2>
<table class="listing">
<thead>
<tr
class="trac-columns"><th>Resource:</th><th>Details:</th></tr>
</thead>
<tbody>
# for item in items:
<tr class="${loop.cycle('odd', 'even')}">
<td><a
href="${item.resource_href}">${item['resource']}</a></td>
<td><a
href="${item.details_href}">${item['details']}</a></td>
</tr>
# endfor
</tbody>
</table>
</div>
<div class="buttons">
<form id="deletenotifications" action=""
method="post">
<input type="hidden" name="action"
value="deletenotifications" />
<input type="submit" class="trac-disable-on-submit"
value="${_('Delete notifications')}" />
</form>
</div>
${ super() }
# endblock content
</body>
</html>