From 08f5746c10d60644a10789c14191c9ea3a3769e4 Mon Sep 17 00:00:00 2001 From: Mirco Babini Date: Fri, 5 Jul 2013 17:03:00 +0200 Subject: [PATCH 1/9] fix for paths like/begin with './' --- src/Mustache/Autoloader.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mustache/Autoloader.php b/src/Mustache/Autoloader.php index df48536..4c8a90e 100644 --- a/src/Mustache/Autoloader.php +++ b/src/Mustache/Autoloader.php @@ -61,7 +61,7 @@ class Mustache_Autoloader return; } - $file = sprintf('%s/%s.php', $this->baseDir, str_replace('_', '/', $class)); + $file = sprintf('%s/%s.php', realpath($this->baseDir), str_replace('_', '/', $class)); if (is_file($file)) { require $file; } From 339c94b2e1598d5986dfc42302c2683b040d7545 Mon Sep 17 00:00:00 2001 From: mlebrun Date: Thu, 18 Jul 2013 14:26:23 -0400 Subject: [PATCH 2/9] FilesystemLoader: removed all temp folder logic from testConstructorWithProtocol test. Conflicts: test/Mustache/Test/Loader/FilesystemLoaderTest.php --- test/Mustache/Test/Loader/FilesystemLoaderTest.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/Mustache/Test/Loader/FilesystemLoaderTest.php b/test/Mustache/Test/Loader/FilesystemLoaderTest.php index 3c7b2f4..3aa83fd 100644 --- a/test/Mustache/Test/Loader/FilesystemLoaderTest.php +++ b/test/Mustache/Test/Loader/FilesystemLoaderTest.php @@ -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'); From 408ff8d3451fe485b31de070f987c7e8658e0b51 Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Sun, 21 Jul 2013 00:48:18 -0700 Subject: [PATCH 3/9] Add a failing test for #128 --- .../Functional/PartialLambdaIndentTest.php | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 test/Mustache/Test/Functional/PartialLambdaIndentTest.php diff --git a/test/Mustache/Test/Functional/PartialLambdaIndentTest.php b/test/Mustache/Test/Functional/PartialLambdaIndentTest.php new file mode 100644 index 0000000..190c194 --- /dev/null +++ b/test/Mustache/Test/Functional/PartialLambdaIndentTest.php @@ -0,0 +1,59 @@ + + {{> input }} + + +EOS; + $partial = << + +EOS; + + $expected = << + + + +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); + }; + } +} From 1c945926bd26eb6cad1e655d7c2d35c8c919890b Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Sun, 21 Jul 2013 00:49:10 -0700 Subject: [PATCH 4/9] Fix indents in lambda sections inside indented partials. Fixes #128 --- src/Mustache/Compiler.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mustache/Compiler.php b/src/Mustache/Compiler.php index 437ea2c..a30e6f5 100644 --- a/src/Mustache/Compiler.php +++ b/src/Mustache/Compiler.php @@ -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) { From 07e96b2a1990bfdf306f6a108841e1c948da762a Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Sun, 21 Jul 2013 13:32:56 -0700 Subject: [PATCH 5/9] Only run partials + lambda indent test on 5.3+ --- .../Test/{ => FiveThree}/Functional/PartialLambdaIndentTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename test/Mustache/Test/{ => FiveThree}/Functional/PartialLambdaIndentTest.php (91%) diff --git a/test/Mustache/Test/Functional/PartialLambdaIndentTest.php b/test/Mustache/Test/FiveThree/Functional/PartialLambdaIndentTest.php similarity index 91% rename from test/Mustache/Test/Functional/PartialLambdaIndentTest.php rename to test/Mustache/Test/FiveThree/Functional/PartialLambdaIndentTest.php index 190c194..647905f 100644 --- a/test/Mustache/Test/Functional/PartialLambdaIndentTest.php +++ b/test/Mustache/Test/FiveThree/Functional/PartialLambdaIndentTest.php @@ -13,7 +13,7 @@ * @group lambdas * @group functional */ -class Mustache_Test_Functional_PartialLambdaIndentTest extends PHPUnit_Framework_TestCase +class Mustache_Test_FiveThree_Functional_PartialLambdaIndentTest extends PHPUnit_Framework_TestCase { public function testLambdasInsidePartialsAreIndentedProperly() From a8bd6a6cf6dd7ddcbcf99ce4c8189a45b4bcd7b1 Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Sun, 4 Aug 2013 12:10:36 -0700 Subject: [PATCH 6/9] Move realpath call into constructor Add an is_dir check, because realpath fails with things like stream wrappers --- src/Mustache/Autoloader.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Mustache/Autoloader.php b/src/Mustache/Autoloader.php index 4c8a90e..2a209dd 100644 --- a/src/Mustache/Autoloader.php +++ b/src/Mustache/Autoloader.php @@ -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; } } @@ -61,7 +67,7 @@ class Mustache_Autoloader return; } - $file = sprintf('%s/%s.php', realpath($this->baseDir), str_replace('_', '/', $class)); + $file = sprintf('%s/%s.php', $this->baseDir, str_replace('_', '/', $class)); if (is_file($file)) { require $file; } From 75b56da0c53db35065322c1d83a51cab78fdd0c6 Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Mon, 5 Aug 2013 16:04:50 -0700 Subject: [PATCH 7/9] markdown -> md --- CONTRIBUTING.markdown => CONTRIBUTING.md | 0 README.markdown => README.md | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename CONTRIBUTING.markdown => CONTRIBUTING.md (100%) rename README.markdown => README.md (100%) diff --git a/CONTRIBUTING.markdown b/CONTRIBUTING.md similarity index 100% rename from CONTRIBUTING.markdown rename to CONTRIBUTING.md diff --git a/README.markdown b/README.md similarity index 100% rename from README.markdown rename to README.md From f968f5fdcb624f65fb92247edb05a6a1127b8444 Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Wed, 7 Aug 2013 17:44:51 -0700 Subject: [PATCH 8/9] Add PHPUnit dev dependency. --- composer.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/composer.json b/composer.json index ebf9541..2969d03 100644 --- a/composer.json +++ b/composer.json @@ -15,6 +15,9 @@ "require": { "php": ">=5.2.4" }, + "require-dev": { + "phpunit/phpunit": "*" + }, "autoload": { "psr-0": { "Mustache": "src/" } } From e3cbc253c397f4fae60b24108115c97f4c626c53 Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Mon, 12 Aug 2013 21:49:14 -0700 Subject: [PATCH 9/9] Bump version for 2.4.1 --- src/Mustache/Engine.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mustache/Engine.php b/src/Mustache/Engine.php index 9869b98..5bf9c4d 100644 --- a/src/Mustache/Engine.php +++ b/src/Mustache/Engine.php @@ -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';