Merge branch 'release/2.4.1'
This commit is contained in:
@@ -15,6 +15,9 @@
|
|||||||
"require": {
|
"require": {
|
||||||
"php": ">=5.2.4"
|
"php": ">=5.2.4"
|
||||||
},
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"phpunit/phpunit": "*"
|
||||||
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-0": { "Mustache": "src/" }
|
"psr-0": { "Mustache": "src/" }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,9 +25,15 @@ class Mustache_Autoloader
|
|||||||
public function __construct($baseDir = null)
|
public function __construct($baseDir = null)
|
||||||
{
|
{
|
||||||
if ($baseDir === null) {
|
if ($baseDir === null) {
|
||||||
$this->baseDir = dirname(__FILE__).'/..';
|
$baseDir = dirname(__FILE__).'/..';
|
||||||
|
}
|
||||||
|
|
||||||
|
// realpath doesn't always work, for example, with stream URIs
|
||||||
|
$realDir = realpath($baseDir);
|
||||||
|
if (is_dir($realDir)) {
|
||||||
|
$this->baseDir = $realDir;
|
||||||
} else {
|
} else {
|
||||||
$this->baseDir = rtrim($baseDir, '/');
|
$this->baseDir = $baseDir;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -189,7 +189,7 @@ class Mustache_Compiler
|
|||||||
$source = %s;
|
$source = %s;
|
||||||
$buffer .= $this->mustache
|
$buffer .= $this->mustache
|
||||||
->loadLambda((string) call_user_func($value, $source, $this->lambdaHelper)%s)
|
->loadLambda((string) call_user_func($value, $source, $this->lambdaHelper)%s)
|
||||||
->renderInternal($context, $indent);
|
->renderInternal($context);
|
||||||
} elseif (!empty($value)) {
|
} elseif (!empty($value)) {
|
||||||
$values = $this->isIterable($value) ? $value : array($value);
|
$values = $this->isIterable($value) ? $value : array($value);
|
||||||
foreach ($values as $value) {
|
foreach ($values as $value) {
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
*/
|
*/
|
||||||
class Mustache_Engine
|
class Mustache_Engine
|
||||||
{
|
{
|
||||||
const VERSION = '2.4.0';
|
const VERSION = '2.4.1';
|
||||||
const SPEC_VERSION = '1.1.2';
|
const SPEC_VERSION = '1.1.2';
|
||||||
|
|
||||||
const PRAGMA_FILTERS = 'FILTERS';
|
const PRAGMA_FILTERS = 'FILTERS';
|
||||||
|
|||||||
@@ -0,0 +1,59 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Mustache.php.
|
||||||
|
*
|
||||||
|
* (c) 2013 Justin Hileman
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group lambdas
|
||||||
|
* @group functional
|
||||||
|
*/
|
||||||
|
class Mustache_Test_FiveThree_Functional_PartialLambdaIndentTest extends PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
|
||||||
|
public function testLambdasInsidePartialsAreIndentedProperly()
|
||||||
|
{
|
||||||
|
$src = <<<EOS
|
||||||
|
<fieldset>
|
||||||
|
{{> input }}
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
EOS;
|
||||||
|
$partial = <<<EOS
|
||||||
|
<input placeholder="{{# _t }}Enter your name{{/ _t }}">
|
||||||
|
|
||||||
|
EOS;
|
||||||
|
|
||||||
|
$expected = <<<EOS
|
||||||
|
<fieldset>
|
||||||
|
<input placeholder="ENTER YOUR NAME">
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
EOS;
|
||||||
|
|
||||||
|
$m = new Mustache_Engine(array(
|
||||||
|
'partials' => array('input' => $partial)
|
||||||
|
));
|
||||||
|
|
||||||
|
$tpl = $m->loadTemplate($src);
|
||||||
|
|
||||||
|
|
||||||
|
$data = new Mustache_Test_Functional_ClassWithLambda();
|
||||||
|
$this->assertEquals($expected, $tpl->render($data));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Mustache_Test_Functional_ClassWithLambda
|
||||||
|
{
|
||||||
|
public function _t()
|
||||||
|
{
|
||||||
|
return function($val) {
|
||||||
|
return strtoupper($val);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -29,6 +29,15 @@ class Mustache_Test_Loader_FilesystemLoaderTest extends PHPUnit_Framework_TestCa
|
|||||||
$this->assertEquals('one contents', $loader->load('one'));
|
$this->assertEquals('one contents', $loader->load('one'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testConstructorWithProtocol()
|
||||||
|
{
|
||||||
|
$baseDir = realpath(dirname(__FILE__).'/../../../fixtures/templates');
|
||||||
|
|
||||||
|
$loader = new Mustache_Loader_FilesystemLoader('file://' . $baseDir, array('extension' => '.ms'));
|
||||||
|
$this->assertEquals('alpha contents', $loader->load('alpha'));
|
||||||
|
$this->assertEquals('beta contents', $loader->load('beta.ms'));
|
||||||
|
}
|
||||||
|
|
||||||
public function testLoadTemplates()
|
public function testLoadTemplates()
|
||||||
{
|
{
|
||||||
$baseDir = realpath(dirname(__FILE__).'/../../../fixtures/templates');
|
$baseDir = realpath(dirname(__FILE__).'/../../../fixtures/templates');
|
||||||
|
|||||||
Reference in New Issue
Block a user