/** * test the Pug alias */ public function testPugAlias() { $jade = new Jade(); $pug = new Pug(); $this->assertSame($jade->getOption('stream'), 'jade.stream'); $this->assertSame($pug->getOption('stream'), 'pug.stream'); $this->assertSame($pug->render('p Hello'), '<p>Hello</p>'); $this->assertSame($pug->getExtension(), '.pug'); $this->assertTrue(in_array('.pug', $pug->getExtensions())); $jade = new Jade(array('extension' => '.foo')); $this->assertSame($jade->getExtension(), '.foo'); $this->assertFalse(in_array('.pug', $jade->getExtensions())); $this->assertTrue(in_array('.foo', $jade->getExtensions())); $jade->setOption('extension', array('.jade', '.pug')); $this->assertSame($jade->getExtension(), '.jade'); $this->assertFalse(in_array('.foo', $jade->getExtensions())); $this->assertTrue(in_array('.jade', $jade->getExtensions())); $this->assertTrue(in_array('.pug', $jade->getExtensions())); $jade->setOption('extension', array()); $this->assertSame($jade->getExtension(), ''); $this->assertFalse(in_array('', $jade->getExtensions())); $this->assertFalse(in_array('.foo', $jade->getExtensions())); $this->assertFalse(in_array('.jade', $jade->getExtensions())); $this->assertFalse(in_array('.pug', $jade->getExtensions())); $jade->setOption('extension', '.pug'); $this->assertSame($jade->getExtension(), '.pug'); $this->assertFalse(in_array('', $jade->getExtensions())); $this->assertFalse(in_array('.foo', $jade->getExtensions())); $this->assertFalse(in_array('.jade', $jade->getExtensions())); $this->assertTrue(in_array('.pug', $jade->getExtensions())); }
/** * @dataProvider caseProvider */ public function testJadeGeneration($htmlFile, $jadeFile) { $jade = new Pug(); $actual = str_replace(array("\r", "\n", "\t"), '', preg_replace('`^\\s+`', '', $jade->render($jadeFile))); $expected = str_replace(array("\r", "\n", "\t"), '', preg_replace('`^\\s+`', '', file_get_contents($htmlFile))); $this->assertSame($expected, $actual, $jadeFile . ' should match ' . $htmlFile); }
/** * Compile the view at the given path. * * @param string $path * @return void */ public function compile($path) { if (is_null($this->cachePath)) { return; } $contents = $this->pug->compile($this->files->get($path)); $this->files->put($this->getCompiledPath($path), $contents); }
public function testPostRender() { $pug = new Pug(array('postRender' => function ($phpCode) { return str_replace('?>>', '?> data-dynamic="true">', $phpCode); })); $html = $pug->render('a#foo(title=5*3) Hello'); $expected = '<a id="foo" title="15" data-dynamic="true">Hello</a>'; $this->assertSame($expected, $html); }
public function testSpacesRender() { $pug = new Pug(array('prettyprint' => false)); $html = $pug->render("i a\ni b"); $this->assertSame('<i>a</i><i>b</i>', $html); $html = $pug->render("i a\n=' '\ni b"); $this->assertSame('<i>a</i> <i>b</i>', $html); $html = $pug->render("p\n | #[i a] #[i b]"); $this->assertSame('<p><i>a</i> <i>b</i></p>', $html); }
/** * @dataProvider caseProvider */ public function testPugGeneration($htmlFile, $pugFile) { $pug = new Pug(); $renderedHtml = $pug->render($pugFile, array('color' => 'yellow')); $htmlFileContents = file_get_contents($htmlFile); $actual = static::simplifyHtml($renderedHtml); $expected = static::simplifyHtml($htmlFileContents); $this->assertSame($expected, $actual, $pugFile . ' should match ' . $htmlFile . ' as html'); $actual = static::simplifyText($renderedHtml); $expected = static::simplifyText($htmlFileContents); $this->assertSame($expected, $actual, $pugFile . ' should match ' . $htmlFile . ' as text'); }
/** * @dataProvider caseProvider */ public function testJadeGeneration($htmlFile, $jadeFile) { $jade = new Pug(); $renderedHtml = $jade->render($jadeFile); $htmlFileContents = file_get_contents($htmlFile); $actual = trim(preg_replace('`\\s+`', '', $renderedHtml)); $expected = trim(preg_replace('`\\s+`', '', $htmlFileContents)); $this->assertSame($expected, $actual, $jadeFile . ' should match ' . $htmlFile . ' as html'); $actual = trim(preg_replace('`\\s+`', ' ', strip_tags($renderedHtml))); $expected = trim(preg_replace('`\\s+`', ' ', strip_tags($htmlFileContents))); $this->assertSame($expected, $actual, $jadeFile . ' should match ' . $htmlFile . ' as text'); }
/** * Compile the view at the given path. * * @param string $path * @return void */ public function compile($path) { $this->footer = array(); if (is_null($this->cachePath)) { return; } // First compile the Haml $contents = $this->pug->compile($this->files->get($path)); // Then the Blade syntax $contents = $this->compileString($contents); // Save $this->files->put($this->getCompiledPath($path), $contents); }
public function testIssue90() { $pug = new Pug(array('expressionLanguage' => 'php')); $actual = trim($pug->render('p= \'$test\' p= "$test" p= \'#{$test}\' p= "#{$test}" p #{$test} p( data-a=\'$test\' data-b="$test" data-c=\'#{$test}\' data-d="#{$test}" ) test', array('test' => 'foo'))); $expected = '<p>$test</p><p>foo</p><p>#{$test}</p><p>#foo</p><p>foo</p><p data-a="$test" data-b="$test" data-c="foo" data-d="foo">test</p>'; $this->assertSame($expected, $actual); }
/** * Remove the keywords. * * @return self $this */ public function unsetMinify() { $this->pug->removeKeyword('assets'); $this->pug->removeKeyword('concat'); $this->pug->removeKeyword('concat-to'); $this->pug->removeKeyword('minify'); $this->pug->removeKeyword('minify-to'); $this->minify = null; return $this; }
/** * @group issues */ public function testIssue4() { $this->cleanTempDir(); $outputDirectory = $this->getTempDir(); $pug = new Pug(array('prettyprint' => true, 'assetDirectory' => array(dirname(__DIR__), __DIR__, __DIR__ . '/js'), 'outputDirectory' => $outputDirectory)); $minify = new Minify($pug); $minify->on('post-minify', function ($params) { $params->outputFile = '/' . $params->outputFile; return $params; }); $pug->addKeyword('minify', $minify); $html = static::simpleHtml($pug->render(__DIR__ . '/test-minify.pug')); $expected = static::simpleHtml(file_get_contents(__DIR__ . '/issue4.html')); $this->assertSame($expected, $html); $this->cleanTempDir(); }
/** * @expectedException \InvalidArgumentException * @expectedExceptionCode 19 */ public function testRequirementThatDoesNotExist() { $pug = new Pug(); $pug->requirements('requirementThatDoesNotExist'); }
public function draw($_text, $_parameters = []) { $pug = new Pug\Pug(); $page = $pug->render($_text, $_parameters); return $page; }