示例#1
0
 /**
  * @param Minify $minify
  *
  * @return self   $this
  */
 public function setMinify($minify)
 {
     $this->pug->setKeyword('assets', $minify);
     $this->pug->setKeyword('concat', $minify);
     $this->pug->setKeyword('concat-to', $minify);
     $this->pug->setKeyword('minify', $minify);
     $this->pug->setKeyword('minify-to', $minify);
     $this->minify = $minify;
     return $this;
 }
示例#2
0
 public function testKeyWordArguments()
 {
     $jade = new Jade(array('singleQuote' => false, 'prettyprint' => false));
     $foo = function ($args, $block, $keyWord) {
         return $keyWord;
     };
     $jade->setKeyword('foo', $foo);
     $actual = trim($jade->render("foo\n"));
     $expected = 'foo';
     $this->assertSame($expected, $actual);
     $jade->setKeyword('bar', $foo);
     $actual = trim($jade->render("bar\n"));
     $expected = 'bar';
     $this->assertSame($expected, $actual);
     $jade->setKeyword('minify', function ($args, $block) {
         $names = array();
         foreach ($block->nodes as $index => $tag) {
             if ($tag->name === 'link') {
                 $href = $tag->getAttribute('href');
                 $names[] = substr($href['value'], 1, -5);
                 unset($block->nodes[$index]);
             }
         }
         return '<link href="' . implode('-', $names) . '.min.css">';
     });
     $actual = trim($jade->render("minify\n" . "  link(href='foo.css')\n" . "  link(href='bar.css')\n"));
     $expected = '<link href="foo-bar.min.css">';
     $this->assertSame($expected, $actual);
     $jade->setKeyword('concat-to', function ($args, $block) {
         $names = array();
         foreach ($block->nodes as $index => $tag) {
             if ($tag->name === 'link') {
                 unset($block->nodes[$index]);
             }
         }
         return '<link href="' . $args . '">';
     });
     $actual = trim($jade->render("concat-to app.css\n" . "  link(href='foo.css')\n" . "  link(href='bar.css')\n"));
     $expected = '<link href="app.css">';
     $this->assertSame($expected, $actual);
 }