mirror of
https://github.com/Mibew/handlebars.php.git
synced 2025-03-20 07:31:24 +03:00
Merge branch 'master' of git://github.com/XaminProject/handlebars.php
This commit is contained in:
commit
e8ac333e43
@ -45,7 +45,7 @@ class Handlebars_Helpers
|
|||||||
*
|
*
|
||||||
* @throw InvalidArgumentException when $helpers is not an array (or traversable) or helper is not a caallable
|
* @throw InvalidArgumentException when $helpers is not an array (or traversable) or helper is not a caallable
|
||||||
*/
|
*/
|
||||||
public function __construct($helpers = null, $defaults = true)
|
public function __construct($helpers = null, $defaults = true)
|
||||||
{
|
{
|
||||||
if ($defaults) {
|
if ($defaults) {
|
||||||
$this->addDefaultHelpers();
|
$this->addDefaultHelpers();
|
||||||
@ -68,8 +68,7 @@ class Handlebars_Helpers
|
|||||||
{
|
{
|
||||||
$this->add(
|
$this->add(
|
||||||
'if',
|
'if',
|
||||||
function ($template, $context, $args, $source)
|
function ($template, $context, $args, $source) {
|
||||||
{
|
|
||||||
$tmp = $context->get($args);
|
$tmp = $context->get($args);
|
||||||
$buffer = '';
|
$buffer = '';
|
||||||
if ($tmp) {
|
if ($tmp) {
|
||||||
@ -81,8 +80,7 @@ class Handlebars_Helpers
|
|||||||
|
|
||||||
$this->add(
|
$this->add(
|
||||||
'each',
|
'each',
|
||||||
function($template, $context, $args, $source)
|
function ($template, $context, $args, $source) {
|
||||||
{
|
|
||||||
$tmp = $context->get($args);
|
$tmp = $context->get($args);
|
||||||
$buffer = '';
|
$buffer = '';
|
||||||
if (is_array($tmp) || $tmp instanceof Traversable) {
|
if (is_array($tmp) || $tmp instanceof Traversable) {
|
||||||
@ -98,8 +96,7 @@ class Handlebars_Helpers
|
|||||||
|
|
||||||
$this->add(
|
$this->add(
|
||||||
'unless',
|
'unless',
|
||||||
function ($template, $context, $args, $source)
|
function ($template, $context, $args, $source) {
|
||||||
{
|
|
||||||
$tmp = $context->get($args);
|
$tmp = $context->get($args);
|
||||||
$buffer = '';
|
$buffer = '';
|
||||||
if (!$tmp) {
|
if (!$tmp) {
|
||||||
@ -111,8 +108,7 @@ class Handlebars_Helpers
|
|||||||
|
|
||||||
$this->add(
|
$this->add(
|
||||||
'with',
|
'with',
|
||||||
function ($template, $context, $args, $source)
|
function ($template, $context, $args, $source) {
|
||||||
{
|
|
||||||
$tmp = $context->get($args);
|
$tmp = $context->get($args);
|
||||||
$context->push($tmp);
|
$context->push($tmp);
|
||||||
$buffer = $template->render($context);
|
$buffer = $template->render($context);
|
||||||
@ -120,6 +116,14 @@ class Handlebars_Helpers
|
|||||||
return $buffer;
|
return $buffer;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//Just for compatibility with ember
|
||||||
|
$this->add(
|
||||||
|
'bindAttr',
|
||||||
|
function ($template, $context, $args, $source) {
|
||||||
|
return $args;
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user