/** * Replace critical content with a temporary placeholder. * * @param \ArjanSchouten\HtmlMinifier\MinifyContext $context * * @return \ArjanSchouten\HtmlMinifier\MinifyContext */ public function process($context) { $contents = $context->getContents(); $contents = $this->whitespaceBetweenInlineElements($contents, $context->getPlaceholderContainer()); $contents = $this->whitespaceInInlineElements($contents, $context->getPlaceholderContainer()); $contents = $this->replaceElements($contents, $context->getPlaceholderContainer()); return $context->setContents($contents); }
/** * Replace PHP tags with a temporary placeholder. * * @param \ArjanSchouten\HtmlMinifier\MinifyContext $context * * @return \ArjanSchouten\HtmlMinifier\MinifyContext */ public function process($context) { $contents = $context->getContents(); $contents = preg_replace_callback('/<\\?=((?!\\?>).)*\\?>/s', function ($match) use($context) { return $context->getPlaceholderContainer()->addPlaceholder($match[0]); }, $contents); $contents = preg_replace_callback('/<\\?php((?!\\?>).)*(\\?>)?/s', function ($match) use($context) { return $context->getPlaceholderContainer()->addPlaceholder($match[0]); }, $contents); return $context->setContents($contents); }
/** * Replace blade tags with a temporary placeholder. * * @param \ArjanSchouten\HtmlMinifier\MinifyContext $context * * @return \ArjanSchouten\HtmlMinifier\MinifyContext */ public function process($context) { $contents = $this->setEchosPlaceholder($context->getContents(), $context->getPlaceholderContainer()); $contents = $this->setBladeControlStructuresPlaceholder($contents, $context->getPlaceholderContainer()); return $context->setContents($contents); }
/** * Replace critical content with a temp placeholder for integrity. * * @param \ArjanSchouten\HtmlMinifier\MinifyContext $context * * @return \ArjanSchouten\HtmlMinifier\MinifyContext */ public function process($context) { $context->setContents($this->setCDataPlaceholder($context->getContents(), $context->getPlaceholderContainer())); return $context->setContents($this->setConditionalCommentsPlaceholder($context->getContents(), $context->getPlaceholderContainer())); }
/** * Restore placeholders with their original content. * * @param \ArjanSchouten\HtmlMinifier\MinifyContext $context * * @return \ArjanSchouten\HtmlMinifier\MinifyContext */ protected function restore(MinifyContext $context) { $withoutPlaceholders = $context->getPlaceholderContainer()->restorePlaceholders($context->getContents()); return $context->setContents($withoutPlaceholders); }