creationix / haml-js

Haml ported to server-side Javascript. This is a traditional server-side templating language. Tested with node-js
MIT License
902 stars 110 forks source link

Parse error when tags are in a certain order #42

Open rmurphey opened 13 years ago

rmurphey commented 13 years ago

I have the following template:

.component.video-player
  :if !useHtml5Player
    .play-button{ dojoAttachPoint : 'playButton' }
    %img.poster{ src : poster, dojoAttachPoint : "videoPlaceholder" }

  .backdrop{ dojoAttachPoint : 'backdrop' }

And it results in the following error:

with(locals || {}) {
  try {
   var _$output="<div class=\"component video-player\">" + 
(function () { if (!useHtml5Player) { return (
"<div dojoAttachPoint=\"" + html_escape('playButton') + "\" class=\"play-button\">" + 
"</div>"
"<img src=\"" + html_escape(poster) + "\" dojoAttachPoint=\"videoPlaceholder\" class=\"poster\" />"
);} else { return ""; } }).call(this) +
"<div dojoAttachPoint=\"" + html_escape('backdrop') + "\" class=\"backdrop\">" + 
"</div></div>";
 return _$output;  } catch (e) {
    return "\n<pre class='error'>" + html_escape(e.stack) + "</pre>\n";
  }
}

The issue is that there is no "+" after the play-button div string; however, if I put the img before that div, then everything works fine. I'm having a hard time tracking down where in the code this is getting assembled, any help would be welcome :)

creationix commented 13 years ago

I haven't looked at this code in a long time. I'll try and see if it's an easy fix.

Also just curious, is this for client-side templating or are you generating it server-side with node or something?

If client-side and haml-js is causing trouble and you're not married to the idea of text-based templating, then https://github.com/creationix/dombuilder is really simple and fun.

creationix commented 13 years ago

Oops, sorry, I forgot that @aaronblohowiak is helping with this project. I'll still try to dig into the issue, but today is very busy for me today because of our product launch. Aaron, don't wait on me to diagnose the issue.

rmurphey commented 13 years ago

This is actually for client-side templating in a PhoneGap project with Dojo -- we're replacing the very basic Dojo templating with Haml instead. I don't think dombuilder would be a good fit for us for this, but I'll definitely check it out :)

aaronblohowiak commented 13 years ago

I am away from keyboard until July 7th, can investigate then.

On Jul 1, 2011, at 10:32 AM, creationixreply@reply.github.com wrote:

Oops, sorry, I forgot that @aaronblohowiak is helping with this project. I'll still try to dig into the issue, but today is very busy for me today because of our product launch. Aaron, don't wait on me to disgnose the issue.

Reply to this email directly or view it on GitHub: https://github.com/creationix/haml-js/issues/42#issuecomment-1484538

aaronblohowiak commented 13 years ago

Sorry for the delay, I am going to look into this during the next few days.