hamlphp / HamlPHP

Yet another Haml to HTML converter written in PHP.
http://hamlphp.github.com/HamlPHP
MIT License
84 stars 15 forks source link

ErrorException [ Notice ]: Undefined index: t #10

Closed codeho closed 13 years ago

codeho commented 13 years ago

Hi, I'm getting the following error:

ErrorException [ Notice ]: Undefined index: t

as soon as i add any element but regular text past body in my haml template.

basically !!! 5 %html %head %meta(http-equiv = 'Content-Type' content = 'text/html' charset = 'iso-8859-1') %meta(name = 'robots' content = 'noindex') %title= $content->title

is fine,

but !!! 5 %html %head %meta(http-equiv = 'Content-Type' content = 'text/html' charset = 'iso-8859-1') %meta(name = 'robots' content = 'noindex') %title= $content->title

throws the error. on the other hand:

!!! 5 %html %head %meta(http-equiv = 'Content-Type' content = 'text/html' charset = 'iso-8859-1') %meta(name = 'robots' content = 'noindex') %title= $content->title

does not throw an error.

any idea?

here's the rest of the exception:

MODPATH/kohana3-haml/vendor/HamlPHP/src/HamlPHP/Element.php [ 182 ]

177 178 private function _containsPhpAttribute(array $att_arr) 179 { 180 foreach ($att_arr as $att) 181 { 182 if ($att['t'] == 'php' || $att['t'] == 'function') 183 return true; 184 } 185
186 return false; 187 }

any help is greatly appreciated.

codeho commented 13 years ago

seems like the indentation has been broken by the form here, just to make sure, i have correct indentation using two spaces in my template.

sniemela commented 13 years ago

Hello,

I tried to reproduce that error but I couldn't. I had error_reporting set to E_ALL | E_STRICT in my php.ini.

Could you try this code if it works:

!!! 5
%html
  %head
    %meta(http-equiv = 'Content-Type' content = 'text/html' charset = 'iso-8859-1')
    %meta(name = 'robots' content = 'noindex')
    %title $content->title
    - if(isset($styles))
      - foreach ($styles as $file => $type)
        = HTML::style($file, array('media' => $type)) . "\n"
%body
  #hello
codeho commented 13 years ago

tried that. still throwing the error.

codeho commented 13 years ago

hm so this issue is still going on. i figured that if i do this it works:

!!! 5
%html
  %head
  %body
    %content= 
      $content
    %footer
      asdasd

but

!!! 5
%html
  %head
  %body
    %content= 
      $content
    #footer
      asdasd

Does not.
as soon as i create a tag by its id with the hash, it'll bail.

Here's the dump of $att from within _containsPhpAttribute line 177 in Element.php:

array(1) (
    0 => array(2) (
        "t" => string(3) "str"
        "v" => string(6) "footer"
    )
)
sniemela commented 13 years ago

OK, I forgot to update this branch :) I picked few commits from the official branch which apparently fixed this problem. I recommend to use our official branch which is on https://github.com/hamlphp/HamlPHP.

Did it work?

codeho commented 13 years ago

ahh. yep. that worked! thanks :)