From ff666397196bf7e66495dc33dedf50081e0b6632 Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Tue, 1 May 2012 22:28:35 -0700 Subject: [PATCH 1/3] Add Symfony ClassLoader (needed for bootstrap) --- .gitmodules | 3 +++ vendor/symfony/Symfony/Component/ClassLoader | 1 + 2 files changed, 4 insertions(+) create mode 160000 vendor/symfony/Symfony/Component/ClassLoader diff --git a/.gitmodules b/.gitmodules index 042ea4d..ee478af 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,3 +4,6 @@ [submodule "vendor/yaml"] path = vendor/yaml url = https://github.com/fabpot/yaml.git +[submodule "vendor/symfony/Symfony/Component/ClassLoader"] + path = vendor/symfony/Symfony/Component/ClassLoader + url = https://github.com/symfony/ClassLoader.git diff --git a/vendor/symfony/Symfony/Component/ClassLoader b/vendor/symfony/Symfony/Component/ClassLoader new file mode 160000 index 0000000..0e6ee8d --- /dev/null +++ b/vendor/symfony/Symfony/Component/ClassLoader @@ -0,0 +1 @@ +Subproject commit 0e6ee8d07dda6920106048247d41249201604e76 From 01bcf6a51a76173dc8a70d3227033997740ec698 Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Tue, 1 May 2012 23:14:03 -0700 Subject: [PATCH 2/3] Add a `build_bootstrap` script. Generates `mustache.php`, a single-file bootstrap library which is a lot easier to include in your project. --- .gitignore | 1 + bin/build_bootstrap.php | 147 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 148 insertions(+) create mode 100755 bin/build_bootstrap.php diff --git a/.gitignore b/.gitignore index 987e2a2..15977fb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ composer.lock vendor +mustache.php diff --git a/bin/build_bootstrap.php b/bin/build_bootstrap.php new file mode 100755 index 0000000..887eb29 --- /dev/null +++ b/bin/build_bootstrap.php @@ -0,0 +1,147 @@ +#!/usr/bin/env php + + */ +class SymfonyClassCollectionLoader +{ + static private $loaded; + + /** + * Loads a list of classes and caches them in one big file. + * + * @param array $classes An array of classes to load + * @param string $cacheDir A cache directory + * @param string $name The cache name prefix + * @param string $extension File extension of the resulting file + * + * @throws InvalidArgumentException When class can't be loaded + */ + static public function load(array $classes, $cacheDir, $name, $extension = '.php') + { + // each $name can only be loaded once per PHP process + if (isset(self::$loaded[$name])) { + return; + } + + self::$loaded[$name] = true; + + $content = ''; + foreach ($classes as $class) { + if (!class_exists($class) && !interface_exists($class) && (!function_exists('trait_exists') || !trait_exists($class))) { + throw new InvalidArgumentException(sprintf('Unable to load class "%s"', $class)); + } + + $r = new ReflectionClass($class); + $content .= preg_replace(array('/^\s*<\?php/', '/\?>\s*$/'), '', file_get_contents($r->getFileName())); + } + + $cache = $cacheDir.'/'.$name.$extension; + self::writeCacheFile($cache, self::stripComments(' Date: Sat, 12 Jan 2013 09:17:33 -0800 Subject: [PATCH 3/3] Add LambdaHelper and Logger to build_bootstrap. --- bin/build_bootstrap.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bin/build_bootstrap.php b/bin/build_bootstrap.php index 887eb29..fe7b632 100755 --- a/bin/build_bootstrap.php +++ b/bin/build_bootstrap.php @@ -37,11 +37,15 @@ SymfonyClassCollectionLoader::load(array( '\Mustache_Compiler', '\Mustache_Context', '\Mustache_HelperCollection', + '\Mustache_LambdaHelper', + '\Mustache_Loader', '\Mustache_Loader_ArrayLoader', '\Mustache_Loader_FilesystemLoader', '\Mustache_Loader_MutableLoader', '\Mustache_Loader_StringLoader', - '\Mustache_Loader', + '\Mustache_Logger', + '\Mustache_Logger_AbstractLogger', + '\Mustache_Logger_StreamLogger', '\Mustache_Parser', '\Mustache_Template', '\Mustache_Tokenizer',