/** * Wrap content in quotes, and escape all quotes used. * * Note: This helper is only compatible with the standard {{ }} delimeters. * * @param string $text The text to parse for arguments. * @param Mustache_LambdaHelper $helper Used to render nested mustache variables. * @return string */ public function quote($text, \Mustache_LambdaHelper $helper) { // Split the text into an array of variables. $content = trim($text); $content = $helper->render($content); // Escape the {{ and the ". $content = str_replace('"', '\\"', $content); $content = preg_replace('([{}]{2,3})', '{{=<% %>=}}${0}<%={{ }}=%>', $content); return '"' . $content . '"'; }
/** * Enqueue (concatenate) inline CSS content. * * Must include `<style>` surrounding element. * * @param string $css The CSS string to add. * @param LambdaHelper $helper For rendering strings in the current context. * @return void */ public function addCss($css, LambdaHelper $helper = null) { if ($helper !== null) { $css = $helper->render($css); } self::$css .= $css; }
/** * Add the block of text to the page requires so it is appended in the footer. The * content of the block can contain further mustache tags which will be resolved. * * @param string $text The script content of the section. * @param \Mustache_LambdaHelper $helper Used to render the content of this block. */ public function help($text, \Mustache_LambdaHelper $helper) { $this->requires->js_amd_inline($helper->render($text)); }