String strangely turned into mako expression
opened this issue · comments
hi
In this environment setup:
- A py3.4 virtual-env
- Created a Pyramid application (www.pylonsproject.org) using sqlalchemy starterkit.
- Manually replaced chamelion templating system with mako (everything works fine so far and the page is rendering in browser with no problem).
- Converted PyHAML using 2to3 (everything went fine).
- Added "mako.preprocessor = haml.preprocessor" to application's .ini file which will be picked up by mako later.
- Running (in virtual-env)
pserve development.ini
- Visiting application's web page will raise a mako exception.
I put a open('/tmp/x', 'w').write(generate_mako(parse_string(source))) in init.py file to investigate it more, looking at the file 'x' I can see this comment which is by default in pyramid's page has turned to Mako expression:
Original in mytemplate.mako:
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
Output by PyHAML:
<!-- Bootstrap core JavaScript -->
${================================================== -->}
<!-- Placed at the end of the document so the pages load faster -->
Simply removing the offending line like this:
fixed the problem (for now).
is this really an issue or did I miss something in the docs? That 2to3 thing seems fishy though.
best wishes
What is happening is the first =
is signalling that the rest of the line is a Python expression that should be inserted. See the ruby docs.
The question then becomes if we are being too accepting in taking =expr
vs = expr
(note the space).
I am also surprised at the 2to3 being necessary; it has been a while since I worked on the Python 3 aspect of this package, but I remember getting it to work seamlessly in both.
maybe 2to3 wasn't necessary. It was ran before using/running PyHAML under py3, it found some py2 print statements though. Sorry about my carelessness.
And about the question, I guess decision is all yours! Thanks for the quick response + I leave this issue open so you can close it if you think it's not a major problem.
No apologies necessary. I'm not even sure it doesn't need 2to3 honestly. I'll take a look in the future.
The thing for me to check is if the Ruby HAML requires that space or not, and then do that.
I'll leave this open until I check that out.
Cheers,
Mike
On Jul 30, 2014, at 11:40 AM, Koosha Hosseiny notifications@github.com wrote:
maybe 2to3 wasn't necessary. It was ran before using/running PyHAML under py3, it found some py2 print statements though. Sorry about my carelessness.
And about the question, I guess decision is all yours! Thanks for the quick response + I leave this issue open so you can close it if you think it's not a major problem.
—
Reply to this email directly or view it on GitHub.