<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
<br>
Martijn Faassen wrote:
<blockquote
 cite="mid:8928d4e90804230452x511738cbl7b945b3e08757a7f@mail.gmail.com"
 type="cite">
  <pre wrap="">On a slightly unrelated topic:

How hard is it to use Django templating outside of Django? Is it a
seperate library? If so, it wouldn't be too hard to integrate this
into a Grok extension, as we have a pluggable templating language
system. We could throw in this adaptation bit too. :)
  </pre>
</blockquote>
<br>
<p>Once upon a time I played with porting DJango templates to Zope3. It
worked, but since DJango templates were not separated out from the rest
of their packages, it didn't seem worth the time to maintain an
independent branch. Especially since it's quite limited(crippled) in
it's power and flexibility.<br>
</p>
I recommend checking out Jinja <br>
<a class="moz-txt-link-freetext" href="http://pypi.python.org/pypi/Jinja/1.2">http://pypi.python.org/pypi/Jinja/1.2</a><br>
<br>
>From their pypi page:<br>
<blockquote>Jinja is a <a class="reference"
 href="http://en.wikipedia.org/wiki/Sandbox_%28computer_security%29">sandboxed</a>
template engine written in pure Python. It
provides a <a class="reference" href="http://www.djangoproject.com/">Django</a>
like non-XML syntax and compiles templates into
executable python code. It's basically a combination of Django
templates
and python code.</blockquote>
<p>Also, it seems many people are enamored with DJango Template filters
and tags, which are very easy in to do in grok.<br>
</p>
<p><br>
e.g. <br>
</p>
<tt>from zope.traversing.interfaces import IPathAdapter<br>
from zope.tales.interfaces import ITALESFunctionNamespace<br>
<br>
class MyFilter(grok.Adapter):<br>
&nbsp;&nbsp;&nbsp; grok.context(interface.Interface)<br>
&nbsp;&nbsp;&nbsp; grok.implements(interface.Interface, ITALESFunctionNamespace,
IPathAdapter)<br>
&nbsp;&nbsp;&nbsp; grok.provides(IPathAdapter)<br>
&nbsp;&nbsp;&nbsp; grok.name('myfilter') # name to access 'filter'<br>
<br>
&nbsp;&nbsp;&nbsp; def upper(self):<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; return self.context.upper()<br>
<br>
&nbsp;&nbsp;&nbsp; def lower(self):<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; return self.context.lower()<br>
<br>
&nbsp;&nbsp;&nbsp; def cap_words(self):<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return ' '.join([x.capitalize() for x in self.context.split()])<br>
<br>
&nbsp;&nbsp;&nbsp; def myadapter(self):<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; return IMyAdapter(self.context).myattribute<br>
&nbsp;&nbsp; &nbsp;&nbsp; <br>
<br>
used like:<br>
&lt;span tal:replace="context/title/myfilter:upper" /&gt; <br>
<br>
</tt><br>
<blockquote
 cite="mid:8928d4e90804230452x511738cbl7b945b3e08757a7f@mail.gmail.com"
 type="cite">
  <pre wrap="">
I think having this would be great, as I've heard people say good
things about the Django templating language. Having this would also
make it easier for people familiar with Django to learn Grok.
  </pre>
</blockquote>
Jinja shouldn't be a big leap, very similar syntax and usage, just a
little more power and flexibilty, and alot more maintainability.<br>
<br>
<blockquote
 cite="mid:8928d4e90804230452x511738cbl7b945b3e08757a7f@mail.gmail.com"
 type="cite">
  <pre wrap="">
Regards,

Martijn
_______________________________________________
Grok-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Grok-dev@zope.org">Grok-dev@zope.org</a>
<a class="moz-txt-link-freetext" href="http://mail.zope.org/mailman/listinfo/grok-dev">http://mail.zope.org/mailman/listinfo/grok-dev</a>


  </pre>
</blockquote>
</body>
</html>