mikeboers / PyHAML

Pythonic implementation of HAML, cross compiling to Mako template syntax.
BSD 3-Clause "New" or "Revised" License
97 stars 13 forks source link

Using PyHAML with Mako template inheritance... #3

Closed al-the-x closed 13 years ago

al-the-x commented 13 years ago

Hi. I'm using PyHAML for the first time, and I'm running into an issue while trying to use Mako's template inheritance model with HAML syntax. Specifically, I've got a layout file that contains:

%html
    %body
        %h1 I am the site name.

        ${self.body()}

And an interior file that looks like this:

<%inherit file="layout.haml">

<%def name="body()">
%h3 I am the page name.
%ul
    - for x in ( 'one', 'two', 'three' ):
        %li ${x}
</%def>

I've tried various tweaks of the indentation in both files to get the desired effect but no luck. Thoughts?

mikeboers commented 13 years ago

There is a small example using your pages in the most recent commit. The only things that tripped me up was that the blank line after %h1 was not indented enough (but this is a bug anyways), and the <%inherit /> was not self-closed.

mikeboers commented 13 years ago

And the blankline bug is fixed.

al-the-x commented 13 years ago

Awesome. That bug in my <%inherit /> tag was just a typing mistake. What version / revision has the blank line fix?

al-the-x commented 13 years ago

Oh yeah, the blank lines was totally the problem. I pulled them all out and the parser was fine.

mikeboers commented 13 years ago

The blank line fix was in https://github.com/mikeboers/PyHAML/commit/e59aec4f25483f8732ce3202e370a30af2842732, which was pushed to PyPi as 0.1.1 (with a really stupid bug) so everything should be fixed by 0.1.3.