fix 0 being treated as empty string, fixes #76

This commit is contained in:
behrooz shabani (everplays) 2014-08-20 10:14:02 +04:30
parent 84c6e3006c
commit 35ea671fd7
2 changed files with 7 additions and 1 deletions

View File

@ -294,7 +294,7 @@ class Tokenizer
*/
protected function flushBuffer()
{
if (!empty($this->buffer)) {
if (!empty($this->buffer) or $this->buffer === '0') {
$this->tokens[] = array(
self::TYPE => self::T_TEXT,
self::VALUE => $this->buffer

View File

@ -198,6 +198,12 @@ class HandlebarsTest extends \PHPUnit_Framework_TestCase
array('data' => true),
'Yes'
),
# see the issue #76
array(
'{{#if data}}0{{/if}}',
array('data' => true),
'0'
),
array(
'{{#if data}}Yes{{/if}}',
array('data' => false),