Metadata-Version: 1.2
Name: django-shouty-templates
Version: 0.1.4
Summary: Applies a monkeypatch which forces Django's template language to error far more loudly about invalid assumptions
Home-page: https://github.com/kezabelle/django-shouty-templates
Author: Keryn Knight
Author-email: django-shouty-templates@kerynknight.com
Maintainer: Keryn Knight
Maintainer-email: django-shouty-templates@kerynknight.com
License: BSD License
Description: django-shouty-templates
        =======================
        
        :author: Keryn Knight
        :version: 0.1.4
        
        
        Rationale
        ---------
        
        Given a template like this::
        
            <html><head></head>
            <body>
            {% if chef.can_add_cakes %}
                <label class="alert alert-{{ chef.is_cake_chef|yesno:"success,danger,default" }}
            {% endif %}
        
        everything works fine, until any of the following happens:
        
        - ``chef`` is no longer the name of the variable.
        - ``can_add_cakes`` is refactored to be called ``can_add_pastries``
        - ``is_cake_chef`` is renamed ``is_pastry_king``
        
        If those happen, the template will either silently display nothing, or will
        display the label incorrectly.
        
        This app applies a monkeypatch which forces Django's template language to error
        far more loudly about invalid assumptions.
        
        Specifically:
        
        - ``chef`` would raise an exception if the variable were called ``sous_chef``
        - ``chef.can_add_cakes`` would raise an exception if ``can_add_cakes`` was no longer a valid attribute/property/method of ``chef``
        - ``chef.is_cake_chef`` would raise an exception for the same reasons.
        
        Thus you can refactor somewhat more freely, knowing that if the template renders
        it's OK. It ain't compile time safety, but it's better than silently swallowing
        errors because you forgot something!
        
        Setup
        -----
        
        Add ``shouty`` or ``shouty.Shout`` to your ``settings.INSTALLED_APPS``
        
        Optional configuration
        ^^^^^^^^^^^^^^^^^^^^^^
        
        - ``settings.SHOUTY_VARIABLES`` may be ``True|False`` and determines if the
          exception is raised when trying to use a variable which doesn't exist.
          Defaults to ``True``.
        - ``settings.SHOUTY_URLS`` may be ``True|False`` and determines if an
          exception is raised when doing ``{% url 'myurl' as my_var %}`` and ``myurl``
          doesn't actually resolve to a view.  Defaults to ``True``.
        - ``settings.SHOUTY_VARIABLE_BLACKLIST`` is a ``tuple`` of ``str`` where each one
          represents a template usage to ignore. Useful for if you are trying to fix up
          an existing project. eg: ``chef.can_add_cakes`` may be supressed if necessary.
        - ``settings.SHOUTY_URL_BLACKLIST`` is a ``tuple`` of ``2-tuple`` to prevent
          certain URLs and their output variables from shouting at you loudly. Useful for
          existing projects or third-party apps which are less strict.
          eg: ``{% url "myurl" as my_var %}`` may be suppressed with ``('myurl', 'my_var')``
          which would still let ``{% url "myurl as "my_other_var %}`` raise an exception.
        
        Default configuration
        ^^^^^^^^^^^^^^^^^^^^^
        
        There's a hard-coded blacklist of variables and URLs to make sure the Django admin and
        django-debug-toolbar work.
        
        Tests
        -----
        
        Literally none. Enjoy!
        
        The license
        -----------
        
        It's `FreeBSD`_. There's should be a ``LICENSE`` file in the root of the repository, and in any archives.
        
        .. _FreeBSD: http://en.wikipedia.org/wiki/BSD_licenses#2-clause_license_.28.22Simplified_BSD_License.22_or_.22FreeBSD_License.22.29
        
        
        ----
        
        Copyright (c) 2019, Keryn Knight
        All rights reserved.
        
        Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
        
        1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
        
        2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
        
        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
        
        
        ----
        
        Change history for django-shouty-templates
        ------------------------------------------
        0.1.4
        ^^^^^^
        * Feature: the patch methods themselves (``new_resolve_lookup`` and ``new_url_render``) are skipped during rendering the debug error page. The exception message and functionality remain the same.
        * Feature: exception messages now attempt to clarify what template name (loader relative) was rendering when the missing variable was encountered.
        * Chore: Updated the ``mypy`` type signatures for some of the variables and methods to indicate the only values I'm expecting to accept.
        
        0.1.3
        ^^^^^^
        * Feature: Silenced errors when using `debug` or `sql_queries` in a template, as they're conditionally set by `django.template.context_processors.debug`
        
        0.1.2
        ^^^^^^
        * Feature: Added 11 new tokens to the default blacklist, covering more of the default Django admin and the default exception reporter.
        * Bugfix: Changed the syntax of the `AppConfig.ready` method to be py2 type annotation compatible.
        
        0.1.1
        ^^^^^^
        * Initial release
        
Keywords: django templates DTL exception
Platform: UNKNOWN
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Natural Language :: English
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Framework :: Django
