Including Page Fragments

17 views
Skip to first unread message

Venkatraman S

unread,
Apr 16, 2014, 11:21:43 PM4/16/14
to django...@googlegroups.com
Just saw a weird problem while including template fragments:

Works : 
  {% include "page.html" with one_variable="1" %}   

Does not because of the space during the variable assignment : 
   {% include "page.html" with one_variable = "1" %}   

Regards,
Venkat

Ramón Carrillo

unread,
Apr 17, 2014, 10:40:47 PM4/17/14
to django...@googlegroups.com
I guess you are not supposed to use spaces there.

IIRC spaces aren't allowed when using filters, neither (e.g.
var|filter1 is ok, var | filter1 is not)

You could find the exact reason digging in the template compiler code.
https://github.com/django/django/blob/master/django/template/__init__.py
https://github.com/django/django/blob/master/django/template/base.py

Regards,
Ramon
> --
> 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...@googlegroups.com.
> To post to this group, send email to django...@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/CAN7tdFT-kAGYgw6nioN-JK4a8LSK1_jadx6u0J7fnSt7%2Bo6%3D5g%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.

Venkatraman S

unread,
Apr 18, 2014, 1:00:25 AM4/18/14
to django...@googlegroups.com
Well, the reason I sent this was due to the fact that while in templates when you are doing conditionals, the spaces are mandatory.

i.e,  
Works : {% if request.session.VARIABLE_NAME == "1"  %}
Doesn't : {% if request.session.VARIABLE_NAME=="1"  %}


Reply all
Reply to author
Forward
0 new messages