Search code examples
pythonpyramidmako

Mako's analog of Django's "spaceless" tag?


Is there a mechanism in Mako templates that would allow me to remove extra spaces from the template output, similar to Django's {% spaceless %} tag?


Solution

  • There are some clues here, but basically it doesn't look like it's supported under Mako directly.

    I do want to point out, however that Jinja2 does support whitespace removal via the {%- and -%} opening and closing tags. It is very easy to use under Pyramid via:

    pip install pyramid_jinja2
    
    config.include('pyramid_jinja2')
    

    From that point forward you can just use the .jinja2 file extension and build your templates.

    Anyway, sorry I couldn't give you better news!