On 03/17/2018 07:37 PM, Dmitriy Sintsov wrote:
Hi!
Template languages are my favorite topic in programming.
Having written a few template engines myself... I guess it's high on my
list too :)
If you implement html library yourself, it is much better to define tags
not as functions but as classes with base Tag class which has properties
for tag name, attributes and the nested list of tags. Such way you will
re-implement DOM, although it is already available in lxml library.
So maybe it's a better idea to figure out whether lxml can be used as
template engine for Django, because it can load source html into nested
structures via binary optimized code. It should be cleaner and faster
than manual composition of html in Python code.
Now, I like this idea as a line of inquiry.
Despite the Django Template Language being explicitly designed to _not_
use HTML syntax [like so many before it did] so as (a) not create
torturous syntaxs, and (b) not restrict it to just HTML...
I think for the case of knowingly generating HTML, using lxml opens the
door to:
1. ensuring valid markup
2. faster processing [maybe?]
3. minifying on the fly -- readable templates, minimal output.
--
Curtis
--
You received this message because you are subscribed to the Google Groups "Django
developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-developers/f690efb3-7d6b-042b-68dc-76cfa8afec5c%40tinbrain.net.
For more options, visit https://groups.google.com/d/optout.