public function testHtmlCommentRemoved() { $engine = $this->getEngine(); $engine->storeHtml('info', 'INFO'); $engine->storeHtml('XXX', 'XXX'); $engine->storeHtml('hello', 'HELLO'); $parser = new Parser($engine); $testTexts = ['<!--<##html:info##>--><b>InfoHello</b>TestText' => 'INFO<b>InfoHello</b>TestText', '<!--<##html:info##>--><b><##html:XXX##></b>TestText' => 'INFO<b>XXX</b>TestText', '<!-- <##html:info##> --><b><##html:XXX##></b><##html:hello##>' => 'INFO<b>XXX</b>HELLO', '<## html :info##><b><!--<## html : XXX ##> --></b><## html: hello##>' => 'INFO<b>XXX</b>HELLO']; foreach ($testTexts as $value) { $this->assertEquals($value, $parser->parse($value)); } }
/** * Replace vanilla tags * @param Request $request * @param Closure $next * @return mixed */ public function handle($request, Closure $next) { $response = $next($request); if (empty($this->engine)) { $selectedEngine = Config::get('vanilla.engine'); $engineName = Config::get('vanilla.engines.' . $selectedEngine . '.laravel'); $this->engine = new $engineName(Config::get('vanilla')); } $parser = new Parser($this->engine); $response->setContent($parser->parse($response->getContent(), storage_path('vanilla'))); return $response; }