arnaud-lb / MtHaml

Multi target HAML (HAML for PHP, Twig, <your language here>)
Other
359 stars 54 forks source link

exeption thrown although valid haml-code #6

Closed ghost closed 12 years ago

ghost commented 12 years ago

In order to get this result in HTML:

<a href="/demo/secured/hello/admin/World">Hello resource secured for <strong>admin</strong> only.</a>

usually haml should look like this:

%a{:href => "/demo/secured/hello/admin/World"} Hello resource secured for %strong admin only.

instead of result Symfony throws an exeption:

CRITICAL - Twig_Error_Runtime: An exception has been thrown during the compilation of a template ("Inconsistent indentation: 6 is not a multiple of 4 in AcmeDemoBundle:Secured:hello.html.haml on line 8, column 7") in "/projects/symfony-test/src/Acme/DemoBundle/Resources/views/Secured/hello.html.haml". (uncaught exception) at /projects/symfony-test/app/cache/dev/classes.php line 6880

question:

why is it not possible to put nested haml tags inside of an anchor-tag?

arnaud-lb commented 12 years ago

The error message Inconsistent indentation: 6 is not a multiple of 4 means that you used different indentation width on different lines. From the error message it seems that you formatted your code like this:

    %a{:href => "/demo/secured/hello/admin/World"}
      Hello resource secured for

If the second line was indented with 8 spaces it would work.

ghost commented 12 years ago

Yeah, I did that - but still i get this error message. Correct me if I am wrong. My indentation seems to be right. this is how my code looks like:

%a{:href => "/demo/secured/hello/admin/World"}
  Hello resource secured for
  %strong admin
  only.

still getting exeption :-/

arnaud-lb commented 12 years ago

The message means that the first indented line in the file is indented with 4 spaces, which implies that every other line must be indented with multiples of 4 spaces

ghost commented 12 years ago

Yes, you are right.

wrong code:
- block content
    %h1 Hello #{ name }!
    %a{:href => "/demo/secured/hello/admin/World"}
      Hello resource secured for
      %strong admin
      only.
right code:
- block content
  %h1 Hello #{ name }!
  %a{:href => "/demo/secured/hello/admin/World"}
    Hello resource secured for
    %strong admin
    only.

That was the problem. Thank you so much for support! Great!