Hello Django users!

  Today I sat down and wrote a native template Loader for Chameleon support 
in Django.  For those not familiar with this template engine, it was used 
in the previously infamous Zope and later Plone web frameworks.  It uses 
mostly XHTML formatting and documentation generation, and is supposedly 
very fast!  You can find the project over on my BitBucket page here:

https://bitbucket.org/kveroneau/django-chameleon-templates

  The README file explains it's usage, and it also contains some example 
templates and a standard Django view to see it in action.  The project 
itself has drop-in replacements for Django's own filesystem.Loader and 
app_directories.Loader, so using it with your existing Django projects 
couldn't be easier.  On top of these drop-in replacement, it has another 
Loader which instead of using TEMPLATE_DIRS like filesystem.Loader does, it 
uses another settings variable called CHAMELEON_TEMPLATES, which uses the 
exact same format.

  This project can for example help those moving from either Pyramid or a 
Zope/Plone solution over to Django.  As it uses the Django API natively, 
including it's context variables.  Furthermore, I also included Django's 
URL Reversal into Chameleon, so you can still properly generate your URLs 
like normal.  There is even a METAL macro to generate the CSRF_TOKEN 
construct.

  It does not support Django's native template tags and filters, but most 
of them aren't really needed.  If you have your own custom tags or filters, 
they will need to be recoded for Chameleon.  Adding new METAL macros takes 
on a similar method to how you add new template tags and filters.  You mere 
just create a macros/ directory inside your apps directory, and place .pt 
template files in there with the macro definitions.  The filename is used 
for the namespace inside the Chameleon template engine.  For example, say 
you have a macro file called example.pt with the following contents:

<p metal:define-macro="hello">
  Hello, <strong metal:define-slot="name">World</strong></p>

To use this macro inside any other template in your project, you merely use 
either of the following:

<p metal:use-macro="example.hello" />

- Or -

<p metal:use-macro="example.hello" >
  <i metal:fill-slot="name">Kevin</i></p>


Wonderful, isn't it?  It makes working with Chamelon inside Django super 
simple and very Django-like.

I hope to soon add the ability to add new expressions into the template 
engine using some sort of registry, similar to how Django's own template 
engine adds new tags.

Let me know if you have any questions or comments about this Django app.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d691b6d2-a2e3-489f-b8e7-cd9a810e1d92%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to