XaminProject / handlebars.php

Handlebars processor for php
331 stars 134 forks source link

Partial parameters #116

Closed SerenadeX closed 9 years ago

SerenadeX commented 9 years ago

So when I load in a hbs file that uses a partial

<div class="topics-search">
  <input type="text" class="topics-search__text-input">
  <button class="topics-search__submit">
    {{> icon iconClass=search}}
  </button>
</div>

I get the following error

Fatal error: Uncaught exception 'InvalidArgumentException' with message 'variable name is invalid' in includes/handlebars.php/src/Handlebars/Context.php:301 
Stack trace: 
#0 includes/handlebars.php/src/Handlebars/Context.php(237): Handlebars\Context->_splitVariableName('iconClass='sear...') 
#1 includes/handlebars.php/src/Handlebars/Template.php(503): Handlebars\Context->get('iconClass='sear...') 
#2 includes/handlebars.php/src/Handlebars/Template.php(241): Handlebars\Template->_partial(Object(Handlebars\Context), Array) 
#3 includes/handlebars.php/src/Handlebars/Template.php(180): Handlebars\Template->_renderInternal(Array, Object(Handlebars\Context)) 
#4 includes/handlebars.php/src/Handlebars/Handlebars.php(184): Handlebars\Template->render(A in includes/handlebars.php/src/Handlebars/Context.php on line 301

I don't know why my partial variable is getting rejected or what is wrong with my variable name. There isn't much documentation on this either. I am not sure if there is a bug breaking this, or if I am just doing it wrong.

majortom731 commented 9 years ago

Maybe what you mean is iconClass="search", with quotes?

SerenadeX commented 9 years ago

I've done it both with and without quotes and I get the same result

JustBlackBird commented 9 years ago

It seems to be a bug. I've made a js fiddle that illustrates Handlebars.js behavior: http://jsfiddle.net/q9emfa80/

SerenadeX commented 9 years ago

Good I'm glad I'm not crazy 😁

SerenadeX commented 9 years ago

Has anyone made any progress on this?

thormeier commented 9 years ago

Fixed with https://github.com/XaminProject/handlebars.php/pull/124 I guess

JustBlackBird commented 9 years ago

It seems that the problem is fixed with #124. @SerenadeX could you confirm it?

SerenadeX commented 9 years ago

Confirmed. Works like a charm 👍🏻

JustBlackBird commented 9 years ago

Good to hear! Thank you @thormeier for the fix!

thormeier commented 9 years ago

Thanks @SerenadeX for testing. @JustBlackBird You're welcome! Is it possible to create a version tag, for instance v0.10.1 for that?