public function testReRegistration() { $handlebarsSource = file_get_contents($this->baseDir . '/components/handlebars/handlebars.js'); Handlebars::registerHandlebarsExtension($handlebarsSource); $registered = V8Js::getExtensions(); $this->assertArrayHasKey(Handlebars::EXTN_HANDLEBARS, $registered); }
private function getHandlebars($resolver, $sourceFile) { $source = $this->getHandlebarsSource($resolver, $sourceFile); // @fixme - this should probably be handled by v8js-handlebars // If the handlebars extension does not compile this bars text that even ob_start() won't catch, as well // as throwing an E_WARNING :( set_error_handler(function ($errno, $errstr) use($sourceFile) { restore_error_handler(); throw new InvalidSourceException(sprintf("An error occurred creating handlebars instance from source '%s': %s", $sourceFile, $errstr)); }, E_WARNING); if (!Handlebars::isRegistered()) { Handlebars::registerHandlebarsExtension($source); } $handlebars = new Handlebars(); restore_error_handler(); return $handlebars; }