Merge branch 'release/2.4.1'

This commit is contained in:
Justin Hileman
2013-08-12 21:49:23 -07:00
8 changed files with 81 additions and 4 deletions
View File
+3
View File
@@ -15,6 +15,9 @@
"require": {
"php": ">=5.2.4"
},
"require-dev": {
"phpunit/phpunit": "*"
},
"autoload": {
"psr-0": { "Mustache": "src/" }
}
+8 -2
View File
@@ -25,9 +25,15 @@ class Mustache_Autoloader
public function __construct($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 {
$this->baseDir = rtrim($baseDir, '/');
$this->baseDir = $baseDir;
}
}
+1 -1
View File
@@ -189,7 +189,7 @@ class Mustache_Compiler
$source = %s;
$buffer .= $this->mustache
->loadLambda((string) call_user_func($value, $source, $this->lambdaHelper)%s)
->renderInternal($context, $indent);
->renderInternal($context);
} elseif (!empty($value)) {
$values = $this->isIterable($value) ? $value : array($value);
foreach ($values as $value) {
+1 -1
View File
@@ -23,7 +23,7 @@
*/
class Mustache_Engine
{
const VERSION = '2.4.0';
const VERSION = '2.4.1';
const SPEC_VERSION = '1.1.2';
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'));
}
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()
{
$baseDir = realpath(dirname(__FILE__).'/../../../fixtures/templates');