page_url template tag fails silently when put in a custom inclusion tag
See original GitHub issueReproduction
I have defined an inclusion tag and registered it like so (example):
from django.template import Library
@register.inclusion_tag('/path/to/template.html', takes_context=True)
def my_tag(context):
return {'foo': 'bar'}
The file /path/to/template.html
contains:
{% load cms_tags %}
<span>{% page_url "PAGENAME" %}</span>
I use both the custom tag and ordinary reference to page_url
in the main cms template:
{% load my_tags cms_tags %}
<h1>{% page_url "PAGENAME" %}</h1>
{% my_tag %}
Expected output:
<h1>/url/to/page<h1>
<span>/url/to/page</span>
Actual output:
<h1>/url/to/page<h1>
<span></span>
Perhaps I am missing something in the tag registration…
Configuration
Virtualenv:
cmsplugin-newsplus==0.1.10
decorator==4.0.4
dj-database-url==0.3.0
Django==1.8.4
django-bower==5.0.4
django-classy-tags==0.6.2
django-cms==3.1.3
django-filebrowser-no-grappelli==3.6.1
django-reversion==1.9.3
django-sekizai==0.8.2
Django-Select2==4.3.1
django-templatetag-handlebars==1.3.0
django-treebeard==3.0
djangocms-admin-style==0.2.8
djangocms-column==1.5
djangocms-file==0.1
djangocms-flash==0.2.0
djangocms-googlemap==0.3
djangocms-inherit==0.1
djangocms-installer==0.8.0
djangocms-link==1.7.1
djangocms-picture==0.1
djangocms-style==1.5
djangocms-teaser==0.1
djangocms-text-ckeditor==2.8.0
djangocms-video==0.1
emencia-django-slideshows==0.9.4
html5lib==0.9999999
ipython==4.0.1
ipython-genutils==0.1.0
path.py==8.1.2
pexpect==4.0.1
pickleshare==0.5
Pillow==2.9.0
ptyprocess==0.5
pytz==2015.4
simplegeneric==0.8.1
six==1.9.0
traitlets==4.0.0
tzlocal==1.2
yolk==0.4.3
Issue Analytics
- State:
- Created 8 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
page_url template tag fails silently when put in a custom ...
Reproduction I have defined an inclusion tag and registered it like so (example): from django.template import Library ...
Read more >How to create custom template tags and filters
In case of input that represents a clear bug in a template, raising an exception may still be better than silent failure which...
Read more >Django inclusion tag with configurable template - Stack Overflow
I use simple_tag when i need to do that: from django.template import Library, loader, Context @register.simple_tag(takes_context=True) def my_tag(context, ...
Read more >Template Tags - django cms 3.11.0 documentation
The placeholder template tag defines a placeholder on a page. All placeholders in a template will be auto-detected and can be filled with...
Read more >Overriding template tags - django-pattern-library
This package uses custom behaviour for these tags only when rendering pattern library and falls back to Django's standard behaviour on all other ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@lukasz-virtualo there is a error in you templatetag. It should be :
By doing
return {'foo': 'bar'}
you are replacing the main context (with the data frompage_url
) with a custom context containing onlyfoo
(orfoo
andcontext
) in the second exampleThanks. Silly me.