replace __DIR__ with dirname(__FILE__)
This commit is contained in:
@@ -19,16 +19,16 @@ class Mustache_Autoloader {
|
|||||||
/**
|
/**
|
||||||
* Autoloader constructor.
|
* Autoloader constructor.
|
||||||
*
|
*
|
||||||
* @param string $baseDir Mustache library base directory (default: __DIR__.'/..')
|
* @param string $baseDir Mustache library base directory (default: dirname(__FILE__).'/..')
|
||||||
*/
|
*/
|
||||||
public function __construct($baseDir = null) {
|
public function __construct($baseDir = null) {
|
||||||
$this->baseDir = rtrim($baseDir, '/') ?: __DIR__.'/..';
|
$this->baseDir = rtrim($baseDir, '/') ?: dirname(__FILE__).'/..';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a new instance as an SPL autoloader.
|
* Register a new instance as an SPL autoloader.
|
||||||
*
|
*
|
||||||
* @param string $baseDir Mustache library base directory (default: __DIR__.'/..')
|
* @param string $baseDir Mustache library base directory (default: dirname(__FILE__).'/..')
|
||||||
*
|
*
|
||||||
* @return Mustache_Autoloader Registered Autoloader instance
|
* @return Mustache_Autoloader Registered Autoloader instance
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -14,14 +14,14 @@
|
|||||||
*
|
*
|
||||||
* An ArrayLoader instance loads Mustache Template source from the filesystem by name:
|
* An ArrayLoader instance loads Mustache Template source from the filesystem by name:
|
||||||
*
|
*
|
||||||
* $loader = new FilesystemLoader(__DIR__.'/views');
|
* $loader = new FilesystemLoader(dirname(__FILE__).'/views');
|
||||||
* $tpl = $loader->load('foo'); // equivalent to `file_get_contents(__DIR__.'/views/foo.mustache');
|
* $tpl = $loader->load('foo'); // equivalent to `file_get_contents(dirname(__FILE__).'/views/foo.mustache');
|
||||||
*
|
*
|
||||||
* This is probably the most useful Mustache Loader implementation. It can be used for partials and normal Templates:
|
* This is probably the most useful Mustache Loader implementation. It can be used for partials and normal Templates:
|
||||||
*
|
*
|
||||||
* $m = new Mustache(array(
|
* $m = new Mustache(array(
|
||||||
* 'loader' => new FilesystemLoader(__DIR__.'/views'),
|
* 'loader' => new FilesystemLoader(dirname(__FILE__).'/views'),
|
||||||
* 'partials_loader' => new FilesystemLoader(__DIR__.'/views/partials'),
|
* 'partials_loader' => new FilesystemLoader(dirname(__FILE__).'/views/partials'),
|
||||||
* ));
|
* ));
|
||||||
*
|
*
|
||||||
* @implements Loader
|
* @implements Loader
|
||||||
@@ -61,7 +61,7 @@ class Mustache_Loader_FilesystemLoader implements Mustache_Loader {
|
|||||||
/**
|
/**
|
||||||
* Load a Template by name.
|
* Load a Template by name.
|
||||||
*
|
*
|
||||||
* $loader = new FilesystemLoader(__DIR__.'/views');
|
* $loader = new FilesystemLoader(dirname(__FILE__).'/views');
|
||||||
* $loader->load('admin/dashboard'); // loads "./views/admin/dashboard.mustache";
|
* $loader->load('admin/dashboard'); // loads "./views/admin/dashboard.mustache";
|
||||||
*
|
*
|
||||||
* @param string $name
|
* @param string $name
|
||||||
|
|||||||
@@ -47,17 +47,17 @@ class Mustache_Mustache {
|
|||||||
* 'template_class_prefix' => '__MyTemplates_',
|
* 'template_class_prefix' => '__MyTemplates_',
|
||||||
*
|
*
|
||||||
* // A cache directory for compiled templates. Mustache will not cache templates unless this is set
|
* // A cache directory for compiled templates. Mustache will not cache templates unless this is set
|
||||||
* 'cache' => __DIR__.'/tmp/cache/mustache',
|
* 'cache' => dirname(__FILE__).'/tmp/cache/mustache',
|
||||||
*
|
*
|
||||||
* // A Mustache template loader instance. Uses a StringLoader if not specified
|
* // A Mustache template loader instance. Uses a StringLoader if not specified
|
||||||
* 'loader' => new Mustache_Loader_FilesystemLoader(__DIR__.'/views'),
|
* 'loader' => new Mustache_Loader_FilesystemLoader(dirname(__FILE__).'/views'),
|
||||||
*
|
*
|
||||||
* // A Mustache loader instance for partials.
|
* // A Mustache loader instance for partials.
|
||||||
* 'partials_loader' => new Mustache_Loader_FilesystemLoader(__DIR__.'/views/partials'),
|
* 'partials_loader' => new Mustache_Loader_FilesystemLoader(dirname(__FILE__).'/views/partials'),
|
||||||
*
|
*
|
||||||
* // An array of Mustache partials. Useful for quick-and-dirty string template loading, but not as
|
* // An array of Mustache partials. Useful for quick-and-dirty string template loading, but not as
|
||||||
* // efficient or lazy as a Filesystem (or database) loader.
|
* // efficient or lazy as a Filesystem (or database) loader.
|
||||||
* 'partials' => array('foo' => file_get_contents(__DIR__.'/views/partials/foo.mustache')),
|
* 'partials' => array('foo' => file_get_contents(dirname(__FILE__).'/views/partials/foo.mustache')),
|
||||||
*
|
*
|
||||||
* // An array of 'helpers'. Helpers can be global variables or objects, closures (e.g. for higher order
|
* // An array of 'helpers'. Helpers can be global variables or objects, closures (e.g. for higher order
|
||||||
* // sections), or any other valid Mustache context value. They will be prepended to the context stack,
|
* // sections), or any other valid Mustache context value. They will be prepended to the context stack,
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ class Mustache_Test_AutoloaderTest extends PHPUnit_Framework_TestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function testAutoloader() {
|
public function testAutoloader() {
|
||||||
$loader = new Mustache_Autoloader(__DIR__.'/../../fixtures/autoloader');
|
$loader = new Mustache_Autoloader(dirname(__FILE__).'/../../fixtures/autoloader');
|
||||||
|
|
||||||
$this->assertNull($loader->autoload('NonMustacheClass'));
|
$this->assertNull($loader->autoload('NonMustacheClass'));
|
||||||
$this->assertFalse(class_exists('NonMustacheClass'));
|
$this->assertFalse(class_exists('NonMustacheClass'));
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ class Mustache_Test_Functional_ExamplesTest extends PHPUnit_Framework_TestCase {
|
|||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getExamples() {
|
public function getExamples() {
|
||||||
$path = realpath(__DIR__.'/../../../../examples');
|
$path = realpath(dirname(__FILE__).'/../../../../examples');
|
||||||
$examples = array();
|
$examples = array();
|
||||||
|
|
||||||
$handle = opendir($path);
|
$handle = opendir($path);
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ class Mustache_Test_Functional_MustacheSpecTest extends PHPUnit_Framework_TestCa
|
|||||||
* simply to provide a 'skipped' test if the `spec` submodule isn't initialized.
|
* simply to provide a 'skipped' test if the `spec` submodule isn't initialized.
|
||||||
*/
|
*/
|
||||||
public function testSpecInitialized() {
|
public function testSpecInitialized() {
|
||||||
if (!file_exists(__DIR__.'/../../../../vendor/spec/specs/')) {
|
if (!file_exists(dirname(__FILE__).'/../../../../vendor/spec/specs/')) {
|
||||||
$this->markTestSkipped('Mustache spec submodule not initialized: run "git submodule update --init"');
|
$this->markTestSkipped('Mustache spec submodule not initialized: run "git submodule update --init"');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -156,7 +156,7 @@ class Mustache_Test_Functional_MustacheSpecTest extends PHPUnit_Framework_TestCa
|
|||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
private function loadSpec($name) {
|
private function loadSpec($name) {
|
||||||
$filename = __DIR__ . '/../../../../vendor/spec/specs/' . $name . '.yml';
|
$filename = dirname(__FILE__) . '/../../../../vendor/spec/specs/' . $name . '.yml';
|
||||||
if (!file_exists($filename)) {
|
if (!file_exists($filename)) {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,14 +14,14 @@
|
|||||||
*/
|
*/
|
||||||
class Mustache_Test_Loader_FilesystemLoaderTest extends PHPUnit_Framework_TestCase {
|
class Mustache_Test_Loader_FilesystemLoaderTest extends PHPUnit_Framework_TestCase {
|
||||||
public function testConstructor() {
|
public function testConstructor() {
|
||||||
$baseDir = realpath(__DIR__.'/../../../fixtures/templates');
|
$baseDir = realpath(dirname(__FILE__).'/../../../fixtures/templates');
|
||||||
$loader = new Mustache_Loader_FilesystemLoader($baseDir, array('extension' => '.ms'));
|
$loader = new Mustache_Loader_FilesystemLoader($baseDir, array('extension' => '.ms'));
|
||||||
$this->assertEquals('alpha contents', $loader->load('alpha'));
|
$this->assertEquals('alpha contents', $loader->load('alpha'));
|
||||||
$this->assertEquals('beta contents', $loader->load('beta.ms'));
|
$this->assertEquals('beta contents', $loader->load('beta.ms'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testLoadTemplates() {
|
public function testLoadTemplates() {
|
||||||
$baseDir = realpath(__DIR__.'/../../../fixtures/templates');
|
$baseDir = realpath(dirname(__FILE__).'/../../../fixtures/templates');
|
||||||
$loader = new Mustache_Loader_FilesystemLoader($baseDir);
|
$loader = new Mustache_Loader_FilesystemLoader($baseDir);
|
||||||
$this->assertEquals('one contents', $loader->load('one'));
|
$this->assertEquals('one contents', $loader->load('one'));
|
||||||
$this->assertEquals('two contents', $loader->load('two.mustache'));
|
$this->assertEquals('two contents', $loader->load('two.mustache'));
|
||||||
@@ -31,14 +31,14 @@ class Mustache_Test_Loader_FilesystemLoaderTest extends PHPUnit_Framework_TestCa
|
|||||||
* @expectedException \RuntimeException
|
* @expectedException \RuntimeException
|
||||||
*/
|
*/
|
||||||
public function testMissingBaseDirThrowsException() {
|
public function testMissingBaseDirThrowsException() {
|
||||||
$loader = new Mustache_Loader_FilesystemLoader(__DIR__.'/not_a_directory');
|
$loader = new Mustache_Loader_FilesystemLoader(dirname(__FILE__).'/not_a_directory');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \InvalidArgumentException
|
* @expectedException \InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public function testMissingTemplateThrowsException() {
|
public function testMissingTemplateThrowsException() {
|
||||||
$baseDir = realpath(__DIR__.'/../../../fixtures/templates');
|
$baseDir = realpath(dirname(__FILE__).'/../../../fixtures/templates');
|
||||||
$loader = new Mustache_Loader_FilesystemLoader($baseDir);
|
$loader = new Mustache_Loader_FilesystemLoader($baseDir);
|
||||||
|
|
||||||
$loader->load('fake');
|
$loader->load('fake');
|
||||||
|
|||||||
+2
-2
@@ -9,7 +9,7 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require __DIR__.'/../src/Mustache/Autoloader.php';
|
require dirname(__FILE__).'/../src/Mustache/Autoloader.php';
|
||||||
Mustache_Autoloader::register();
|
Mustache_Autoloader::register();
|
||||||
|
|
||||||
require __DIR__.'/../vendor/yaml/lib/sfYamlParser.php';
|
require dirname(__FILE__).'/../vendor/yaml/lib/sfYamlParser.php';
|
||||||
|
|||||||
Reference in New Issue
Block a user