namuit / phamlp

Automatically exported from code.google.com/p/phamlp
0 stars 0 forks source link

Haml Proper Indenting? #48

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I'm not seeing the source code indent properly.

I initialize pHAMLp like this:
$haml = new HamlParser(array('format' => 'html5', 'ugly' => FALSE, 'style' => 
'nested'));

I call the HAML template in index.php like this:
echo $haml->parse(WEB_ROOT.PROJECT_DIR.'/assets/tpl/layout.haml');

My template looks like this:
!!!
%html
  %head
    %title Hello, world!

  %body
    %header
      %nav
        %ul
          %li
            %a Home
    %section
      %header
        %h1 Hello, world!
      %article
        %p
          Foo, bar.

I get this:
<?php
require_once '/path/to/haml/HamlHelpers.php';
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>
Hello, world!
</title></head><body>
<header>
<nav>
<ul>
<li>
<a>
Home
</a></li></ul></nav></header><section>
<header>
<h1>
Hello, world!
</h1></header><article>
<p>

Foo, bar.
</p></article></section></body></html>

The indenting shouldn't be like that, I imagine, right?

Thanks :)

Todd

Original issue reported on code.google.com by t...@savagevenus.net on 9 Oct 2010 at 2:27

GoogleCodeExporter commented 9 years ago
Same here. Is quite annoying :S

Original comment by ecentin...@gmail.com on 13 Oct 2010 at 9:37

GoogleCodeExporter commented 9 years ago
Same, anyone have a fix?

Original comment by me%fredk...@gtempaccount.com on 24 Nov 2010 at 11:33

GoogleCodeExporter commented 9 years ago
so, the project is dead. :((

Original comment by VladikTa...@gmail.com on 9 Dec 2010 at 4:23

GoogleCodeExporter commented 9 years ago
bugs in class HamlNestedRenderer.php

Line 75
return str_repeat(' ', 2 * $node->line['indentLevel']);

should be
return str_repeat(' ', 2 * $node->level);

attached is my modified HamlNestedRenderer.php

Original comment by jalag...@gmail.com on 13 Jan 2011 at 7:21

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks dude for your HamlNestedRendere.php! It's a lifesaver!!

Original comment by conan...@gmail.com on 24 Feb 2011 at 9:16

GoogleCodeExporter commented 9 years ago
This patch has been applied to https://github.com/MarcWeber/phamlp

Original comment by gabriel%...@gtempaccount.com on 6 Mar 2011 at 5:39