Skip to content

Commit 85a9473

Browse files
committed
Fixed namespaces
1 parent 7cfaff4 commit 85a9473

File tree

5 files changed

+82
-2
lines changed

5 files changed

+82
-2
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
}
1313
],
1414
"require": {
15-
"tijsverkoyen/css-to-inline-styles": "^2.2"
15+
"tijsverkoyen/css-to-inline-styles": "^2.2",
16+
"twig/twig": "^1.26"
1617
},
1718
"autoload": {
1819
"psr-4": {

src/PageSpecificCss.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace PageSpecificCss;
3+
namespace JanDC\PageSpecificCss;
44

55
use TijsVerkoyen\CssToInlineStyles\Css\Processor;
66
use TijsVerkoyen\CssToInlineStyles\CssToInlineStyles;

src/Twig/Extension.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace JanDC\PageSpecificCss\Twig;
4+
5+
use JanDC\PageSpecificCss\Twig\TokenParsers\FoldTokenParser;
6+
use Twig_Extension;
7+
use Twig_ExtensionInterface;
8+
9+
class Extension extends Twig_Extension implements Twig_ExtensionInterface
10+
{
11+
12+
public function getTokenParsers()
13+
{
14+
return [
15+
new FoldTokenParser(),
16+
];
17+
}
18+
19+
}

src/Twig/TokenParsers/FoldNode.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
namespace JanDC\PageSpecificCss\Twig\TokenParsers;
4+
5+
use Twig_Compiler;
6+
use Twig_Node;
7+
8+
class FoldNode extends Twig_Node
9+
{
10+
11+
public function __construct(array $nodes, array $attributes, $lineno, $tag)
12+
{
13+
parent::__construct($nodes, $attributes, $lineno, $tag);
14+
}
15+
16+
public function compile(Twig_Compiler $compiler)
17+
{
18+
file_put_contents('test', $this->getNode('body'));
19+
}
20+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
namespace JanDC\PageSpecificCss\Twig\TokenParsers;
4+
5+
use Twig_Error_Syntax;
6+
use Twig_NodeInterface;
7+
use Twig_Token;
8+
use Twig_TokenParser;
9+
10+
class FoldTokenParser extends Twig_TokenParser
11+
{
12+
13+
/**
14+
* Parses a token and returns a node.
15+
*
16+
* @param Twig_Token $token A Twig_Token instance
17+
*
18+
* @return Twig_NodeInterface A Twig_NodeInterface instance
19+
*
20+
* @throws Twig_Error_Syntax
21+
*/
22+
public function parse(Twig_Token $token)
23+
{
24+
$lineno = $token->getLine();
25+
$this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
26+
$body = $this->parser->subparse([$this, 'decideJsEnd'], true);
27+
$this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
28+
return new FoldNode($body, [], $lineno, $this->getTag());
29+
}
30+
31+
/**
32+
* Gets the tag name associated with this token parser.
33+
*
34+
* @return string The tag name
35+
*/
36+
public function getTag()
37+
{
38+
return 'fold';
39+
}
40+
}

0 commit comments

Comments
 (0)