HamlPy icon indicating copy to clipboard operation
HamlPy copied to clipboard

{% include %} template tags do not work with non-VALID_EXTENSIONS

Open deanmalmgren opened this issue 13 years ago • 2 comments

I tend to embed inline javascript snippets by using {% include %} django template tags like this:

-# template.haml
!!! 5
%html
    %body
        %p hello world
        %script
            {% autoescape off %}
            {% include "path/to/file.js" %}
            {% endautoescape %}

This is convenient because my editor can then use the appropriate javascript syntax highlighting rather than the haml syntax highlighting. The problem is that this produces a RuntimeError (maximum recursion dept exceeded while calling a Python object) for any templates that are {% include %}-ed but do not end in one of the hamlpy.VALID_EXTENSIONS. Bummer.

I might recommend making VALID_EXTENSIONS a settings variable within the hamlpy app that can easily be extended in the site settings.py.

deanmalmgren avatar Jan 17 '13 21:01 deanmalmgren

+1

jpesce avatar Dec 26 '13 02:12 jpesce

I took a stab at incorporating this in a manner similar to how HAMLPY_ATTR_WRAPPER is written. I didn't see any tests for HAMLPY_ATTR_WRAPPER so I wasn't sure the best way to add tests for this new functionality. If you have any suggestions, etc, I'm happy to modify accordingly.

deanmalmgren avatar Jan 03 '14 00:01 deanmalmgren