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() protected function flushBuffer()
{ {
if (!empty($this->buffer)) { if (!empty($this->buffer) or $this->buffer === '0') {
$this->tokens[] = array( $this->tokens[] = array(
self::TYPE => self::T_TEXT, self::TYPE => self::T_TEXT,
self::VALUE => $this->buffer self::VALUE => $this->buffer

View File

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