bminer / node-blade

Blade - HTML Template Compiler, inspired by Jade & Haml
Other
320 stars 28 forks source link

URL resolving at runtime has issues with hashbangs in URL #113

Closed schlundd closed 11 years ago

schlundd commented 11 years ago

runtime.resolve() in runtime.js doesn't work correctly when using hashbangs. Fixed it by including:

  var hashbang = prefix.indexOf('#');
  if (hashbang != -1){
    prefix = prefix.substring(0,hashbang);
  }

after line 303.

bminer commented 11 years ago

Thanks for the bug report. Unfortunately, I cannot replicate this bug. What, specifically, is causing the problem?

schlundd commented 11 years ago

Yeah, sorry. I guess my report didn't really say much.

I have a single page ajax app. When someone navigates to /#cases/undefined I want to load a template called "caseCreate" by calling blade.Runtime.loadTemplate(). However, because of the slash after the hash in the URL, runtime.resolve() (used by loadTemplate) returns "eate.blade" instead of "caseCreate.blade". As far as I see, this could be fixed by cutting of the prefix variable at the hash.

Hope this helps.

bminer commented 11 years ago

@schlundd - Gotcha. I think I understand the problem now. So, what filename are you passing to loadTemplate? I am trying to figure out what string gets passed to runtime.resolve(), what you expect as output, and what it actually returns as output. Thanks!

bminer commented 11 years ago

Also... what browser are you using that causes this problem?

schlundd commented 11 years ago

Sure. I call loadTemplate("caseCreate", cb). This triggers the call runtime.resolve("caseCreate.blade"), wich returns "eate.blade", but should return "caseCreate.blade". window.location.href is "http://<host>:<port>/#cases/undefined". I don't think it's browser specific. Tested on FF 17 and Chrome 23.

bminer commented 11 years ago

@schlundd - Got it, thanks! This will be fixed shortly!