django-template-analyzer 1.5

Django Template Analyzer - Extract template nodes from a Django template
.. image::  https://travis-ci.org/edoburu/django-template-analyzer.png?branch=master
  :target: http://travis-ci.org/edoburu/django-template-analyzer
  :alt: build-status

Introduction
============

The ``template_analyzer`` package offers an API to analyze the Django template structure.
It can be used to find nodes of a particular type, e.g. to do automatic detection of placeholder tags.

Supported features
==================

The scanner finds tags in various situations, including:

* Extend nodes
* Include nodes
* Overwritten blocks with new definitions
* Blocks with or without ``{{ block.super }}``
* Reorganized blocks
* Ignoring nodes outside blocks in extending templates
* Handling multiple levels of super includes

The returned nodes are provided in a natural ordering,
as they would be expected to appear in the outputted page.

While Django offers a ``template.nodelist.get_nodes_of_type()`` function,
this function does not produce the same results.


API example
===========

::

    from django.template.loader import get_template
    from mycms.templatetags.placeholdertags import Placeholder
    from template_analyzer.djangoanalyzer import get_node_instances

    # Load a Django template
    template = get_template("mycms/default-page.html")

    # Find all tags in the template:
    placeholders = get_node_instances(template, Placeholder)

    # Read information from the template tag themselves:
    # (this is an example, accessing a custom method on the Placeholder object)
    placeholder_names = [p.get_name() for p in placeholders]

Installation
============

First install the module, preferably in a virtual environment. It can be installed from PyPI::

    pip install django-template-analyzer

Or the current folder can be installed::

    pip install .

.. include:: CHANGES.rst

Credits
=======

* This package is based on the work of
  `Django CMS <http://www.django-cms.org>`_. 
* Many thanks to the contributors of ``cms/utils/placeholder.py`` / ``cms/utils/plugins.py`` in Django CMS!
BSD License

Author

Diederik van der Boor & Django CMS developers

Pip

django-template-analyzer==1.5

Classifiers

  • Development Status :: 5 - Production/Stable
  • Environment :: Web Environment
  • Framework :: Django
  • Intended Audience :: Developers
  • Operating System :: OS Independent
  • Programming Language :: Python
  • Programming Language :: Python :: 2.6
  • Programming Language :: Python :: 2.7
  • Programming Language :: Python :: 3
  • Programming Language :: Python :: 3.3
  • License :: OSI Approved :: BSD License
  • Topic :: Software Development :: Libraries :: Python Modules
  • Topic :: Software Development :: Libraries :: Application Frameworks
  • Topic :: Software Development
  • Framework :: Django :: 1.6
  • Framework :: Django :: 1.7
  • Framework :: Django :: 1.8
  • Framework :: Django :: 1.4
  • Framework :: Django :: 1.5
File Type Python Version Uploaded On Downloads
django_template_analyzer-1.5-py2.py3-none-any.whl Wheel 2.7 April 13, 2015 4,177
django-template-analyzer-1.5.tar.gz Source April 13, 2015 1,306
Version Release Date
1.5 April 13, 2015
1.4 Sept. 22, 2014
1.3 July 7, 2014
1.2 June 4, 2014
1.1.0 May 5, 2012
1.0.0 Dec. 20, 2011
Date Package Version Action
Aug. 26, 2015, 12:28 a.m. django-template-analyzer 1.3 Release Created
Aug. 26, 2015, 12:28 a.m. django-template-analyzer 1.1.0 Release Created
Aug. 26, 2015, 12:28 a.m. django-template-analyzer 1.2 Release Created
Aug. 26, 2015, 12:28 a.m. django-template-analyzer 1.0.0 Release Created
Aug. 26, 2015, 12:28 a.m. django-template-analyzer 1.5 Release Created
Aug. 26, 2015, 12:28 a.m. django-template-analyzer 1.4 Release Created
Aug. 26, 2015, 12:28 a.m. django-template-analyzer Package Created