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

%%namespace not parsing #24

Closed MarcUpsher closed 5 years ago

MarcUpsher commented 7 years ago

Hi

I'm upgrading from ver 1.0.1 to 1.1.0, and a file that previously parsed is now throwing up errors. The line in question is:

%%namespace(file="file.haml", *{'import': ''})

From reading the Mako docs, it appears that line should compile into the following:

<%namespace file="/file.haml" import="*"/>

Instead, I'm getting the following error:

SyntaxException: (SyntaxError) invalid syntax (, line 1) (u"namespace<% M_writer(__HAML.attribute_str({'ad") in file xxx

I'm not sure if this is an error in my code, or something the parser cannot deal with. Any assistance would be greatly appreciated!

DavidLemayian commented 5 years ago

I'm getting this same error. Would appreciate if anyone has figured out an answer?

mikeboers commented 5 years ago

Okay, so... this is the change that "broke" this behaviour.

Options are either:

  1. Add a few more hardcoded keywords that you can add an underscore postfix that is stripped. e.g. import_ here like class_.

  2. Better parsing.

mikeboers commented 5 years ago

I implemented the better parsing. Tests pass. Considering implementing option 1 as well...

mikeboers commented 5 years ago

I'm going to leave it there. v1.2.1 is on PyPI.