diff options
author | Nicolas LÅ“uillet <nicolas.loeuillet@gmail.com> | 2013-08-03 19:26:54 +0200 |
---|---|---|
committer | Nicolas LÅ“uillet <nicolas.loeuillet@gmail.com> | 2013-08-03 19:26:54 +0200 |
commit | 4f5b44bd3bd490309eb2ba7b44df4769816ba729 (patch) | |
tree | 6cefe170dfe0a5a361cb1e2d1fc4d580a3316d02 /vendor/twig/twig/lib/Twig/TokenParser/Spaceless.php | |
parent | 2b840e0cfb63a453bea67a98541f3df9c273c5f5 (diff) | |
download | wallabag-4f5b44bd3bd490309eb2ba7b44df4769816ba729.tar.gz wallabag-4f5b44bd3bd490309eb2ba7b44df4769816ba729.tar.zst wallabag-4f5b44bd3bd490309eb2ba7b44df4769816ba729.zip |
twig implementation
Diffstat (limited to 'vendor/twig/twig/lib/Twig/TokenParser/Spaceless.php')
-rw-r--r-- | vendor/twig/twig/lib/Twig/TokenParser/Spaceless.php | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/vendor/twig/twig/lib/Twig/TokenParser/Spaceless.php b/vendor/twig/twig/lib/Twig/TokenParser/Spaceless.php new file mode 100644 index 00000000..1e3fa8f3 --- /dev/null +++ b/vendor/twig/twig/lib/Twig/TokenParser/Spaceless.php | |||
@@ -0,0 +1,59 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2010 Fabien Potencier | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | /** | ||
13 | * Remove whitespaces between HTML tags. | ||
14 | * | ||
15 | * <pre> | ||
16 | * {% spaceless %} | ||
17 | * <div> | ||
18 | * <strong>foo</strong> | ||
19 | * </div> | ||
20 | * {% endspaceless %} | ||
21 | * | ||
22 | * {# output will be <div><strong>foo</strong></div> #} | ||
23 | * </pre> | ||
24 | */ | ||
25 | class Twig_TokenParser_Spaceless extends Twig_TokenParser | ||
26 | { | ||
27 | /** | ||
28 | * Parses a token and returns a node. | ||
29 | * | ||
30 | * @param Twig_Token $token A Twig_Token instance | ||
31 | * | ||
32 | * @return Twig_NodeInterface A Twig_NodeInterface instance | ||
33 | */ | ||
34 | public function parse(Twig_Token $token) | ||
35 | { | ||
36 | $lineno = $token->getLine(); | ||
37 | |||
38 | $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); | ||
39 | $body = $this->parser->subparse(array($this, 'decideSpacelessEnd'), true); | ||
40 | $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); | ||
41 | |||
42 | return new Twig_Node_Spaceless($body, $lineno, $this->getTag()); | ||
43 | } | ||
44 | |||
45 | public function decideSpacelessEnd(Twig_Token $token) | ||
46 | { | ||
47 | return $token->test('endspaceless'); | ||
48 | } | ||
49 | |||
50 | /** | ||
51 | * Gets the tag name associated with this token parser. | ||
52 | * | ||
53 | * @return string The tag name | ||
54 | */ | ||
55 | public function getTag() | ||
56 | { | ||
57 | return 'spaceless'; | ||
58 | } | ||
59 | } | ||