[ckan-dev] Jinja extensions and templating

Aron Carroll aron.carroll at okfn.org
Mon Aug 13 15:08:38 UTC 2012


With Toby's latest changes the {% ckan_extends %} tag now works recursively.

This means that we can use it to extend the core CKAN templates without having to create a theme extension. Simply extend the page you want your extension added to and include your snippet. Be sure to wrap your snippet in a block so that others can remove it if necessary.

For example adding disqus comments looks like:

    // ckanext/disqus/templates/package/read.html
    {% ckan_extends %}

    {% block primary_content %}
        {{ super() }}
        {% block disqus_comments %}{{ h.disqus_comments() }}{% endblock %}
    {% endblock %}

I've updated the documentation to reflect this.

https://github.com/okfn/ckan/blob/a4780ad9a5b53d7837bfbe15f5fcaf908e55ba90/doc/extension-templating.rst#functional-extensions

And as mentioned I've already updated disqus extension.

https://github.com/okfn/ckanext-disqus/commit/f5d728c1310fd93b20e5b9bc2edbaef2f62d1698

Now when the disqus plugin is loaded the comments will automatically be added to the package/read page.

Cheers,
Aron



More information about the ckan-dev mailing list