Document that variable extend nodes are not supported in cms templates #1847

tobiasfuhlroth opened this Issue May 21, 2013 · 12 comments

8 participants


The limitation of the placeholder scanner to not support variable extend nodes should be documented.

Edited by ojii. Original content: (Support for {% extends variable %} in Template Inheritance (Placeholder Detection))

There is a comment in the function _extend_blocks in cms/utils/ that states explicitly that this is not supported: # we don't support variable extensions

Before further investigation of this topic i would like to ask if there was any specific reason behind this decision.

Supporting this would be nice in situations like this:
{% extends request.is_ajax|yesno:"site_base-ajax.html,site_base.html" %}


Yes there is, there's absolutely no way for us to know what possible values the variable could hold, thus where we have to look. Placeholders (and other things) in the extended template would never be caught by our placeholder-scanning code.


Thanks for your quick response! Maybe it would be worth mentioning that this is not supported somewhere in the docs?


absolutely. edited the ticket.

Divio AG member

actually we could implement this for 3.0 as there is no placeholder scanning needed anymore as we don't have get the placeholders anymore for the backend admin.


I would like to use something like {% extends request.is_ajax|yesno:"ajax_base.html,base.html" %} or context processor that would set variable to appropriate parent template. Then I found out this issue.

I've tried to exclude parts of template in base.html with {% if request.is_ajax %}...{% endif %} but some block tags don't like being inside of if .. else.

Do anyone know some workaround?

@digi604 digi604 added this to the 3.0 milestone Feb 10, 2014
Divio AG member

@yakky is this now supported? Just that you did that with the new CMS_TEMPLATE variable.


@digi604 , @dboczek, @tobiasfuhlroth we now have CMS_TEMPLATE ( context variable that holds the page template path.
It solves some of the use cases mentioned above, but not all of them.

I'll investigate whether we are able to support full expansion

@yakky yakky self-assigned this Mar 9, 2014

Aftr a brief check, apparently we're able to support full variable expansion.
A PR to remove the check and proper tests needed.
@ojii The same code exists in sekizai ( does sekizai has the same limitation?

@yakky yakky modified the milestone: 3.X, 3.0 Apr 5, 2014

Targeting future release. Too late in the release cycle and while I'm confident it should work in real world cases, test strategy it's not trivial

Divio AG member

@yakky is this still relevant?


@FinalAngel yes, it's still relevant. No planned work on this, though

@yakky yakky removed their assignment Nov 10, 2015

I created a template using a variable extend node, with a context processor like CMS_TEMPLATE.

My page rendered with just the static placeholders, so I stumbled upon this.

I then tried commenting out the if is_variable_extend_node line, and got a TemplateSyntaxError saying the extends tag is empty.

Any tips? Maybe I should try a different approach?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment