├── .bowerrc ├── .gitignore ├── 404.php ├── Gulpfile.js ├── README.md ├── archive.php ├── bower.json ├── composer.json ├── dist ├── css │ └── .gitignore ├── fonts │ └── .gitignore ├── js │ └── .gitignore └── tmp │ ├── .gitignore │ ├── bootstrap.css │ ├── bootstrap.js │ └── jquery.js ├── functions.php ├── home.php ├── inc ├── Twig │ ├── Twig │ │ ├── Autoloader.php │ │ ├── Compiler.php │ │ ├── CompilerInterface.php │ │ ├── Environment.php │ │ ├── Error.php │ │ ├── Error │ │ │ ├── Loader.php │ │ │ ├── Runtime.php │ │ │ └── Syntax.php │ │ ├── ExistsLoaderInterface.php │ │ ├── ExpressionParser.php │ │ ├── Extension.php │ │ ├── Extension │ │ │ ├── Core.php │ │ │ ├── Debug.php │ │ │ ├── Escaper.php │ │ │ ├── Optimizer.php │ │ │ ├── Sandbox.php │ │ │ ├── Staging.php │ │ │ └── StringLoader.php │ │ ├── ExtensionInterface.php │ │ ├── Filter.php │ │ ├── Filter │ │ │ ├── Function.php │ │ │ ├── Method.php │ │ │ └── Node.php │ │ ├── FilterCallableInterface.php │ │ ├── FilterInterface.php │ │ ├── Function.php │ │ ├── Function │ │ │ ├── Function.php │ │ │ ├── Method.php │ │ │ └── Node.php │ │ ├── FunctionCallableInterface.php │ │ ├── FunctionInterface.php │ │ ├── Lexer.php │ │ ├── LexerInterface.php │ │ ├── Loader │ │ │ ├── Array.php │ │ │ ├── Chain.php │ │ │ ├── Filesystem.php │ │ │ └── String.php │ │ ├── LoaderInterface.php │ │ ├── Markup.php │ │ ├── Node.php │ │ ├── Node │ │ │ ├── AutoEscape.php │ │ │ ├── Block.php │ │ │ ├── BlockReference.php │ │ │ ├── Body.php │ │ │ ├── Do.php │ │ │ ├── Embed.php │ │ │ ├── Expression.php │ │ │ ├── Expression │ │ │ │ ├── Array.php │ │ │ │ ├── AssignName.php │ │ │ │ ├── Binary.php │ │ │ │ ├── Binary │ │ │ │ │ ├── Add.php │ │ │ │ │ ├── And.php │ │ │ │ │ ├── BitwiseAnd.php │ │ │ │ │ ├── BitwiseOr.php │ │ │ │ │ ├── BitwiseXor.php │ │ │ │ │ ├── Concat.php │ │ │ │ │ ├── Div.php │ │ │ │ │ ├── EndsWith.php │ │ │ │ │ ├── Equal.php │ │ │ │ │ ├── FloorDiv.php │ │ │ │ │ ├── Greater.php │ │ │ │ │ ├── GreaterEqual.php │ │ │ │ │ ├── In.php │ │ │ │ │ ├── Less.php │ │ │ │ │ ├── LessEqual.php │ │ │ │ │ ├── Matches.php │ │ │ │ │ ├── Mod.php │ │ │ │ │ ├── Mul.php │ │ │ │ │ ├── NotEqual.php │ │ │ │ │ ├── NotIn.php │ │ │ │ │ ├── Or.php │ │ │ │ │ ├── Power.php │ │ │ │ │ ├── Range.php │ │ │ │ │ ├── StartsWith.php │ │ │ │ │ └── Sub.php │ │ │ │ ├── BlockReference.php │ │ │ │ ├── Call.php │ │ │ │ ├── Conditional.php │ │ │ │ ├── Constant.php │ │ │ │ ├── ExtensionReference.php │ │ │ │ ├── Filter.php │ │ │ │ ├── Filter │ │ │ │ │ └── Default.php │ │ │ │ ├── Function.php │ │ │ │ ├── GetAttr.php │ │ │ │ ├── MethodCall.php │ │ │ │ ├── Name.php │ │ │ │ ├── Parent.php │ │ │ │ ├── TempName.php │ │ │ │ ├── Test.php │ │ │ │ ├── Test │ │ │ │ │ ├── Constant.php │ │ │ │ │ ├── Defined.php │ │ │ │ │ ├── Divisibleby.php │ │ │ │ │ ├── Even.php │ │ │ │ │ ├── Null.php │ │ │ │ │ ├── Odd.php │ │ │ │ │ └── Sameas.php │ │ │ │ ├── Unary.php │ │ │ │ └── Unary │ │ │ │ │ ├── Neg.php │ │ │ │ │ ├── Not.php │ │ │ │ │ └── Pos.php │ │ │ ├── Flush.php │ │ │ ├── For.php │ │ │ ├── ForLoop.php │ │ │ ├── If.php │ │ │ ├── Import.php │ │ │ ├── Include.php │ │ │ ├── Macro.php │ │ │ ├── Module.php │ │ │ ├── Print.php │ │ │ ├── Sandbox.php │ │ │ ├── SandboxedModule.php │ │ │ ├── SandboxedPrint.php │ │ │ ├── Set.php │ │ │ ├── SetTemp.php │ │ │ ├── Spaceless.php │ │ │ └── Text.php │ │ ├── NodeInterface.php │ │ ├── NodeOutputInterface.php │ │ ├── NodeTraverser.php │ │ ├── NodeVisitor │ │ │ ├── Escaper.php │ │ │ ├── Optimizer.php │ │ │ ├── SafeAnalysis.php │ │ │ └── Sandbox.php │ │ ├── NodeVisitorInterface.php │ │ ├── Parser.php │ │ ├── ParserInterface.php │ │ ├── Sandbox │ │ │ ├── SecurityError.php │ │ │ ├── SecurityNotAllowedFilterError.php │ │ │ ├── SecurityNotAllowedFunctionError.php │ │ │ ├── SecurityNotAllowedTagError.php │ │ │ ├── SecurityPolicy.php │ │ │ └── SecurityPolicyInterface.php │ │ ├── SimpleFilter.php │ │ ├── SimpleFunction.php │ │ ├── SimpleTest.php │ │ ├── Template.php │ │ ├── TemplateInterface.php │ │ ├── Test.php │ │ ├── Test │ │ │ ├── Function.php │ │ │ ├── IntegrationTestCase.php │ │ │ ├── Method.php │ │ │ ├── Node.php │ │ │ └── NodeTestCase.php │ │ ├── TestCallableInterface.php │ │ ├── TestInterface.php │ │ ├── Token.php │ │ ├── TokenParser.php │ │ ├── TokenParser │ │ │ ├── AutoEscape.php │ │ │ ├── Block.php │ │ │ ├── Do.php │ │ │ ├── Embed.php │ │ │ ├── Extends.php │ │ │ ├── Filter.php │ │ │ ├── Flush.php │ │ │ ├── For.php │ │ │ ├── From.php │ │ │ ├── If.php │ │ │ ├── Import.php │ │ │ ├── Include.php │ │ │ ├── Macro.php │ │ │ ├── Sandbox.php │ │ │ ├── Set.php │ │ │ ├── Spaceless.php │ │ │ └── Use.php │ │ ├── TokenParserBroker.php │ │ ├── TokenParserBrokerInterface.php │ │ ├── TokenParserInterface.php │ │ └── TokenStream.php │ ├── class-twig-proxy.php │ └── class-twigpress.php ├── activation.php ├── comments.php ├── config.php ├── extras.php ├── gallery.php ├── init.php ├── scripts.php ├── titles.php ├── twigpress.php ├── utils.php └── wp_bootstrap_navwalker.php ├── index.php ├── package.json ├── page.php ├── screenshot.png ├── search.php ├── sidebar.php ├── single.php ├── src ├── js │ └── main.js └── scss │ ├── base │ ├── _base.scss │ ├── _colors.scss │ ├── _html.scss │ ├── _position.scss │ └── _typography.scss │ ├── components │ ├── _buttons.scss │ ├── _comments.scss │ ├── _components.scss │ ├── _fields.scss │ ├── _lists.scss │ ├── _tables.scss │ └── _wp-fixes.scss │ ├── helpers │ ├── _helpers.scss │ ├── _mixins.scss │ └── _variables.scss │ ├── layout │ ├── _footer.scss │ ├── _header.scss │ ├── _layout.scss │ ├── _navigation.scss │ └── _site.scss │ ├── main.scss │ └── pages │ ├── _home.scss │ └── _pages.scss ├── style.css ├── template-sidebar.php └── twigs ├── 404.twig ├── archive.twig ├── content ├── content-404.twig ├── content-excerpt.twig ├── content-none.twig ├── content-page.twig ├── content-single.twig └── content.twig ├── home.twig ├── includes ├── comments.twig ├── entry-meta.twig ├── footer.twig ├── head.twig ├── header.twig ├── paging.twig └── sidebar.twig ├── index.twig ├── layouts ├── base.twig └── sidebar.twig ├── page.twig ├── search.twig ├── single.twig └── template-sidebar.twig /.bowerrc: -------------------------------------------------------------------------------- 1 | { 2 | "directory": "vendor" 3 | } 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/* 2 | .sass-cache/* 3 | vendor/* 4 | inc/Twig/twig_cache/* 5 | .DS_Store 6 | .idea -------------------------------------------------------------------------------- /404.php: -------------------------------------------------------------------------------- 1 | " 7 | ], 8 | "private": true, 9 | "ignore": [ 10 | "**/.*", 11 | "node_modules", 12 | "assets/vendor" 13 | ], 14 | "dependencies": { 15 | "jquery": "1.11.1", 16 | "bootstrap": "3.3.1" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "require": { 3 | "twig/twig": "~1.0" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /dist/css/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore -------------------------------------------------------------------------------- /dist/fonts/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore -------------------------------------------------------------------------------- /dist/js/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore -------------------------------------------------------------------------------- /dist/tmp/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore -------------------------------------------------------------------------------- /functions.php: -------------------------------------------------------------------------------- 1 | 16 | */ 17 | class Twig_Autoloader 18 | { 19 | /** 20 | * Registers Twig_Autoloader as an SPL autoloader. 21 | * 22 | * @param bool $prepend Whether to prepend the autoloader or not. 23 | */ 24 | public static function register($prepend = false) 25 | { 26 | if (version_compare(phpversion(), '5.3.0', '>=')) { 27 | spl_autoload_register(array(__CLASS__, 'autoload'), true, $prepend); 28 | } else { 29 | spl_autoload_register(array(__CLASS__, 'autoload')); 30 | } 31 | } 32 | 33 | /** 34 | * Handles autoloading of classes. 35 | * 36 | * @param string $class A class name. 37 | */ 38 | public static function autoload($class) 39 | { 40 | if (0 !== strpos($class, 'Twig')) { 41 | return; 42 | } 43 | 44 | if (is_file($file = dirname(__FILE__).'/../'.str_replace(array('_', "\0"), array('/', ''), $class).'.php')) { 45 | require $file; 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /inc/Twig/Twig/CompilerInterface.php: -------------------------------------------------------------------------------- 1 | 16 | * 17 | * @deprecated since 1.12 (to be removed in 3.0) 18 | */ 19 | interface Twig_CompilerInterface 20 | { 21 | /** 22 | * Compiles a node. 23 | * 24 | * @param Twig_NodeInterface $node The node to compile 25 | * 26 | * @return Twig_CompilerInterface The current compiler instance 27 | */ 28 | public function compile(Twig_NodeInterface $node); 29 | 30 | /** 31 | * Gets the current PHP code after compilation. 32 | * 33 | * @return string The PHP code 34 | */ 35 | public function getSource(); 36 | } 37 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Error/Loader.php: -------------------------------------------------------------------------------- 1 | 24 | */ 25 | class Twig_Error_Loader extends Twig_Error 26 | { 27 | public function __construct($message, $lineno = -1, $filename = null, Exception $previous = null) 28 | { 29 | parent::__construct($message, false, false, $previous); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Error/Runtime.php: -------------------------------------------------------------------------------- 1 | 17 | */ 18 | class Twig_Error_Runtime extends Twig_Error 19 | { 20 | } 21 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Error/Syntax.php: -------------------------------------------------------------------------------- 1 | 17 | */ 18 | class Twig_Error_Syntax extends Twig_Error 19 | { 20 | } 21 | -------------------------------------------------------------------------------- /inc/Twig/Twig/ExistsLoaderInterface.php: -------------------------------------------------------------------------------- 1 | 16 | * 17 | * @deprecated since 1.12 (to be removed in 3.0) 18 | */ 19 | interface Twig_ExistsLoaderInterface 20 | { 21 | /** 22 | * Check if we have the source code of a template, given its name. 23 | * 24 | * @param string $name The name of the template to check if we can load 25 | * 26 | * @return bool If the template source code is handled by this loader or not 27 | */ 28 | public function exists($name); 29 | } 30 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Extension.php: -------------------------------------------------------------------------------- 1 | $isDumpOutputHtmlSafe ? array('html') : array(), 'needs_context' => true, 'needs_environment' => true)), 32 | ); 33 | } 34 | 35 | /** 36 | * Returns the name of the extension. 37 | * 38 | * @return string The extension name 39 | */ 40 | public function getName() 41 | { 42 | return 'debug'; 43 | } 44 | } 45 | 46 | function twig_var_dump(Twig_Environment $env, $context) 47 | { 48 | if (!$env->isDebug()) { 49 | return; 50 | } 51 | 52 | ob_start(); 53 | 54 | $count = func_num_args(); 55 | if (2 === $count) { 56 | $vars = array(); 57 | foreach ($context as $key => $value) { 58 | if (!$value instanceof Twig_Template) { 59 | $vars[$key] = $value; 60 | } 61 | } 62 | 63 | var_dump($vars); 64 | } else { 65 | for ($i = 2; $i < $count; $i++) { 66 | var_dump(func_get_arg($i)); 67 | } 68 | } 69 | 70 | return ob_get_clean(); 71 | } 72 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Extension/Optimizer.php: -------------------------------------------------------------------------------- 1 | optimizers = $optimizers; 18 | } 19 | 20 | /** 21 | * {@inheritdoc} 22 | */ 23 | public function getNodeVisitors() 24 | { 25 | return array(new Twig_NodeVisitor_Optimizer($this->optimizers)); 26 | } 27 | 28 | /** 29 | * {@inheritdoc} 30 | */ 31 | public function getName() 32 | { 33 | return 'optimizer'; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Extension/Staging.php: -------------------------------------------------------------------------------- 1 | 18 | */ 19 | class Twig_Extension_Staging extends Twig_Extension 20 | { 21 | protected $functions = array(); 22 | protected $filters = array(); 23 | protected $visitors = array(); 24 | protected $tokenParsers = array(); 25 | protected $globals = array(); 26 | protected $tests = array(); 27 | 28 | public function addFunction($name, $function) 29 | { 30 | $this->functions[$name] = $function; 31 | } 32 | 33 | /** 34 | * {@inheritdoc} 35 | */ 36 | public function getFunctions() 37 | { 38 | return $this->functions; 39 | } 40 | 41 | public function addFilter($name, $filter) 42 | { 43 | $this->filters[$name] = $filter; 44 | } 45 | 46 | /** 47 | * {@inheritdoc} 48 | */ 49 | public function getFilters() 50 | { 51 | return $this->filters; 52 | } 53 | 54 | public function addNodeVisitor(Twig_NodeVisitorInterface $visitor) 55 | { 56 | $this->visitors[] = $visitor; 57 | } 58 | 59 | /** 60 | * {@inheritdoc} 61 | */ 62 | public function getNodeVisitors() 63 | { 64 | return $this->visitors; 65 | } 66 | 67 | public function addTokenParser(Twig_TokenParserInterface $parser) 68 | { 69 | $this->tokenParsers[] = $parser; 70 | } 71 | 72 | /** 73 | * {@inheritdoc} 74 | */ 75 | public function getTokenParsers() 76 | { 77 | return $this->tokenParsers; 78 | } 79 | 80 | public function addGlobal($name, $value) 81 | { 82 | $this->globals[$name] = $value; 83 | } 84 | 85 | /** 86 | * {@inheritdoc} 87 | */ 88 | public function getGlobals() 89 | { 90 | return $this->globals; 91 | } 92 | 93 | public function addTest($name, $test) 94 | { 95 | $this->tests[$name] = $test; 96 | } 97 | 98 | /** 99 | * {@inheritdoc} 100 | */ 101 | public function getTests() 102 | { 103 | return $this->tests; 104 | } 105 | 106 | /** 107 | * {@inheritdoc} 108 | */ 109 | public function getName() 110 | { 111 | return 'staging'; 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Extension/StringLoader.php: -------------------------------------------------------------------------------- 1 | true)), 20 | ); 21 | } 22 | 23 | /** 24 | * {@inheritdoc} 25 | */ 26 | public function getName() 27 | { 28 | return 'string_loader'; 29 | } 30 | } 31 | 32 | /** 33 | * Loads a template from a string. 34 | * 35 | *
36 |  * {{ include(template_from_string("Hello {{ name }}")) }}
37 |  * 
38 | * 39 | * @param Twig_Environment $env A Twig_Environment instance 40 | * @param string $template A template as a string 41 | * 42 | * @return Twig_Template A Twig_Template instance 43 | */ 44 | function twig_template_from_string(Twig_Environment $env, $template) 45 | { 46 | $name = sprintf('__string_template__%s', hash('sha256', uniqid(mt_rand(), true), false)); 47 | 48 | $loader = new Twig_Loader_Chain(array( 49 | new Twig_Loader_Array(array($name => $template)), 50 | $current = $env->getLoader(), 51 | )); 52 | 53 | $env->setLoader($loader); 54 | try { 55 | $template = $env->loadTemplate($name); 56 | } catch (Exception $e) { 57 | $env->setLoader($current); 58 | 59 | throw $e; 60 | } 61 | $env->setLoader($current); 62 | 63 | return $template; 64 | } 65 | -------------------------------------------------------------------------------- /inc/Twig/Twig/ExtensionInterface.php: -------------------------------------------------------------------------------- 1 | 16 | */ 17 | interface Twig_ExtensionInterface 18 | { 19 | /** 20 | * Initializes the runtime environment. 21 | * 22 | * This is where you can load some file that contains filter functions for instance. 23 | * 24 | * @param Twig_Environment $environment The current Twig_Environment instance 25 | */ 26 | public function initRuntime(Twig_Environment $environment); 27 | 28 | /** 29 | * Returns the token parser instances to add to the existing list. 30 | * 31 | * @return array An array of Twig_TokenParserInterface or Twig_TokenParserBrokerInterface instances 32 | */ 33 | public function getTokenParsers(); 34 | 35 | /** 36 | * Returns the node visitor instances to add to the existing list. 37 | * 38 | * @return Twig_NodeVisitorInterface[] An array of Twig_NodeVisitorInterface instances 39 | */ 40 | public function getNodeVisitors(); 41 | 42 | /** 43 | * Returns a list of filters to add to the existing list. 44 | * 45 | * @return array An array of filters 46 | */ 47 | public function getFilters(); 48 | 49 | /** 50 | * Returns a list of tests to add to the existing list. 51 | * 52 | * @return array An array of tests 53 | */ 54 | public function getTests(); 55 | 56 | /** 57 | * Returns a list of functions to add to the existing list. 58 | * 59 | * @return array An array of functions 60 | */ 61 | public function getFunctions(); 62 | 63 | /** 64 | * Returns a list of operators to add to the existing list. 65 | * 66 | * @return array An array of operators 67 | */ 68 | public function getOperators(); 69 | 70 | /** 71 | * Returns a list of global variables to add to the existing list. 72 | * 73 | * @return array An array of global variables 74 | */ 75 | public function getGlobals(); 76 | 77 | /** 78 | * Returns the name of the extension. 79 | * 80 | * @return string The extension name 81 | */ 82 | public function getName(); 83 | } 84 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Filter.php: -------------------------------------------------------------------------------- 1 | 18 | * @deprecated since 1.12 (to be removed in 2.0) 19 | */ 20 | abstract class Twig_Filter implements Twig_FilterInterface, Twig_FilterCallableInterface 21 | { 22 | protected $options; 23 | protected $arguments = array(); 24 | 25 | public function __construct(array $options = array()) 26 | { 27 | $this->options = array_merge(array( 28 | 'needs_environment' => false, 29 | 'needs_context' => false, 30 | 'pre_escape' => null, 31 | 'preserves_safety' => null, 32 | 'callable' => null, 33 | ), $options); 34 | } 35 | 36 | public function setArguments($arguments) 37 | { 38 | $this->arguments = $arguments; 39 | } 40 | 41 | public function getArguments() 42 | { 43 | return $this->arguments; 44 | } 45 | 46 | public function needsEnvironment() 47 | { 48 | return $this->options['needs_environment']; 49 | } 50 | 51 | public function needsContext() 52 | { 53 | return $this->options['needs_context']; 54 | } 55 | 56 | public function getSafe(Twig_Node $filterArgs) 57 | { 58 | if (isset($this->options['is_safe'])) { 59 | return $this->options['is_safe']; 60 | } 61 | 62 | if (isset($this->options['is_safe_callback'])) { 63 | return call_user_func($this->options['is_safe_callback'], $filterArgs); 64 | } 65 | } 66 | 67 | public function getPreservesSafety() 68 | { 69 | return $this->options['preserves_safety']; 70 | } 71 | 72 | public function getPreEscape() 73 | { 74 | return $this->options['pre_escape']; 75 | } 76 | 77 | public function getCallable() 78 | { 79 | return $this->options['callable']; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Filter/Function.php: -------------------------------------------------------------------------------- 1 | 18 | * @deprecated since 1.12 (to be removed in 2.0) 19 | */ 20 | class Twig_Filter_Function extends Twig_Filter 21 | { 22 | protected $function; 23 | 24 | public function __construct($function, array $options = array()) 25 | { 26 | $options['callable'] = $function; 27 | 28 | parent::__construct($options); 29 | 30 | $this->function = $function; 31 | } 32 | 33 | public function compile() 34 | { 35 | return $this->function; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Filter/Method.php: -------------------------------------------------------------------------------- 1 | 18 | * @deprecated since 1.12 (to be removed in 2.0) 19 | */ 20 | class Twig_Filter_Method extends Twig_Filter 21 | { 22 | protected $extension; 23 | protected $method; 24 | 25 | public function __construct(Twig_ExtensionInterface $extension, $method, array $options = array()) 26 | { 27 | $options['callable'] = array($extension, $method); 28 | 29 | parent::__construct($options); 30 | 31 | $this->extension = $extension; 32 | $this->method = $method; 33 | } 34 | 35 | public function compile() 36 | { 37 | return sprintf('$this->env->getExtension(\'%s\')->%s', $this->extension->getName(), $this->method); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Filter/Node.php: -------------------------------------------------------------------------------- 1 | 18 | * @deprecated since 1.12 (to be removed in 2.0) 19 | */ 20 | class Twig_Filter_Node extends Twig_Filter 21 | { 22 | protected $class; 23 | 24 | public function __construct($class, array $options = array()) 25 | { 26 | parent::__construct($options); 27 | 28 | $this->class = $class; 29 | } 30 | 31 | public function getClass() 32 | { 33 | return $this->class; 34 | } 35 | 36 | public function compile() 37 | { 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /inc/Twig/Twig/FilterCallableInterface.php: -------------------------------------------------------------------------------- 1 | 18 | * @deprecated since 1.12 (to be removed in 2.0) 19 | */ 20 | interface Twig_FilterCallableInterface 21 | { 22 | public function getCallable(); 23 | } 24 | -------------------------------------------------------------------------------- /inc/Twig/Twig/FilterInterface.php: -------------------------------------------------------------------------------- 1 | 18 | * @deprecated since 1.12 (to be removed in 2.0) 19 | */ 20 | interface Twig_FilterInterface 21 | { 22 | /** 23 | * Compiles a filter. 24 | * 25 | * @return string The PHP code for the filter 26 | */ 27 | public function compile(); 28 | 29 | public function needsEnvironment(); 30 | 31 | public function needsContext(); 32 | 33 | public function getSafe(Twig_Node $filterArgs); 34 | 35 | public function getPreservesSafety(); 36 | 37 | public function getPreEscape(); 38 | 39 | public function setArguments($arguments); 40 | 41 | public function getArguments(); 42 | } 43 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Function.php: -------------------------------------------------------------------------------- 1 | 18 | * @deprecated since 1.12 (to be removed in 2.0) 19 | */ 20 | abstract class Twig_Function implements Twig_FunctionInterface, Twig_FunctionCallableInterface 21 | { 22 | protected $options; 23 | protected $arguments = array(); 24 | 25 | public function __construct(array $options = array()) 26 | { 27 | $this->options = array_merge(array( 28 | 'needs_environment' => false, 29 | 'needs_context' => false, 30 | 'callable' => null, 31 | ), $options); 32 | } 33 | 34 | public function setArguments($arguments) 35 | { 36 | $this->arguments = $arguments; 37 | } 38 | 39 | public function getArguments() 40 | { 41 | return $this->arguments; 42 | } 43 | 44 | public function needsEnvironment() 45 | { 46 | return $this->options['needs_environment']; 47 | } 48 | 49 | public function needsContext() 50 | { 51 | return $this->options['needs_context']; 52 | } 53 | 54 | public function getSafe(Twig_Node $functionArgs) 55 | { 56 | if (isset($this->options['is_safe'])) { 57 | return $this->options['is_safe']; 58 | } 59 | 60 | if (isset($this->options['is_safe_callback'])) { 61 | return call_user_func($this->options['is_safe_callback'], $functionArgs); 62 | } 63 | 64 | return array(); 65 | } 66 | 67 | public function getCallable() 68 | { 69 | return $this->options['callable']; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Function/Function.php: -------------------------------------------------------------------------------- 1 | 19 | * @deprecated since 1.12 (to be removed in 2.0) 20 | */ 21 | class Twig_Function_Function extends Twig_Function 22 | { 23 | protected $function; 24 | 25 | public function __construct($function, array $options = array()) 26 | { 27 | $options['callable'] = $function; 28 | 29 | parent::__construct($options); 30 | 31 | $this->function = $function; 32 | } 33 | 34 | public function compile() 35 | { 36 | return $this->function; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Function/Method.php: -------------------------------------------------------------------------------- 1 | 19 | * @deprecated since 1.12 (to be removed in 2.0) 20 | */ 21 | class Twig_Function_Method extends Twig_Function 22 | { 23 | protected $extension; 24 | protected $method; 25 | 26 | public function __construct(Twig_ExtensionInterface $extension, $method, array $options = array()) 27 | { 28 | $options['callable'] = array($extension, $method); 29 | 30 | parent::__construct($options); 31 | 32 | $this->extension = $extension; 33 | $this->method = $method; 34 | } 35 | 36 | public function compile() 37 | { 38 | return sprintf('$this->env->getExtension(\'%s\')->%s', $this->extension->getName(), $this->method); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Function/Node.php: -------------------------------------------------------------------------------- 1 | 18 | * @deprecated since 1.12 (to be removed in 2.0) 19 | */ 20 | class Twig_Function_Node extends Twig_Function 21 | { 22 | protected $class; 23 | 24 | public function __construct($class, array $options = array()) 25 | { 26 | parent::__construct($options); 27 | 28 | $this->class = $class; 29 | } 30 | 31 | public function getClass() 32 | { 33 | return $this->class; 34 | } 35 | 36 | public function compile() 37 | { 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /inc/Twig/Twig/FunctionCallableInterface.php: -------------------------------------------------------------------------------- 1 | 18 | * @deprecated since 1.12 (to be removed in 2.0) 19 | */ 20 | interface Twig_FunctionCallableInterface 21 | { 22 | public function getCallable(); 23 | } 24 | -------------------------------------------------------------------------------- /inc/Twig/Twig/FunctionInterface.php: -------------------------------------------------------------------------------- 1 | 19 | * @deprecated since 1.12 (to be removed in 2.0) 20 | */ 21 | interface Twig_FunctionInterface 22 | { 23 | /** 24 | * Compiles a function. 25 | * 26 | * @return string The PHP code for the function 27 | */ 28 | public function compile(); 29 | 30 | public function needsEnvironment(); 31 | 32 | public function needsContext(); 33 | 34 | public function getSafe(Twig_Node $filterArgs); 35 | 36 | public function setArguments($arguments); 37 | 38 | public function getArguments(); 39 | } 40 | -------------------------------------------------------------------------------- /inc/Twig/Twig/LexerInterface.php: -------------------------------------------------------------------------------- 1 | 16 | * 17 | * @deprecated since 1.12 (to be removed in 3.0) 18 | */ 19 | interface Twig_LexerInterface 20 | { 21 | /** 22 | * Tokenizes a source code. 23 | * 24 | * @param string $code The source code 25 | * @param string $filename A unique identifier for the source code 26 | * 27 | * @return Twig_TokenStream A token stream instance 28 | * 29 | * @throws Twig_Error_Syntax When the code is syntactically wrong 30 | */ 31 | public function tokenize($code, $filename = null); 32 | } 33 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Loader/Array.php: -------------------------------------------------------------------------------- 1 | 23 | */ 24 | class Twig_Loader_Array implements Twig_LoaderInterface, Twig_ExistsLoaderInterface 25 | { 26 | protected $templates = array(); 27 | 28 | /** 29 | * Constructor. 30 | * 31 | * @param array $templates An array of templates (keys are the names, and values are the source code) 32 | * 33 | * @see Twig_Loader 34 | */ 35 | public function __construct(array $templates) 36 | { 37 | $this->templates = $templates; 38 | } 39 | 40 | /** 41 | * Adds or overrides a template. 42 | * 43 | * @param string $name The template name 44 | * @param string $template The template source 45 | */ 46 | public function setTemplate($name, $template) 47 | { 48 | $this->templates[(string) $name] = $template; 49 | } 50 | 51 | /** 52 | * {@inheritdoc} 53 | */ 54 | public function getSource($name) 55 | { 56 | $name = (string) $name; 57 | if (!isset($this->templates[$name])) { 58 | throw new Twig_Error_Loader(sprintf('Template "%s" is not defined.', $name)); 59 | } 60 | 61 | return $this->templates[$name]; 62 | } 63 | 64 | /** 65 | * {@inheritdoc} 66 | */ 67 | public function exists($name) 68 | { 69 | return isset($this->templates[(string) $name]); 70 | } 71 | 72 | /** 73 | * {@inheritdoc} 74 | */ 75 | public function getCacheKey($name) 76 | { 77 | $name = (string) $name; 78 | if (!isset($this->templates[$name])) { 79 | throw new Twig_Error_Loader(sprintf('Template "%s" is not defined.', $name)); 80 | } 81 | 82 | return $this->templates[$name]; 83 | } 84 | 85 | /** 86 | * {@inheritdoc} 87 | */ 88 | public function isFresh($name, $time) 89 | { 90 | $name = (string) $name; 91 | if (!isset($this->templates[$name])) { 92 | throw new Twig_Error_Loader(sprintf('Template "%s" is not defined.', $name)); 93 | } 94 | 95 | return true; 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Loader/String.php: -------------------------------------------------------------------------------- 1 | 23 | */ 24 | class Twig_Loader_String implements Twig_LoaderInterface, Twig_ExistsLoaderInterface 25 | { 26 | /** 27 | * {@inheritdoc} 28 | */ 29 | public function getSource($name) 30 | { 31 | return $name; 32 | } 33 | 34 | /** 35 | * {@inheritdoc} 36 | */ 37 | public function exists($name) 38 | { 39 | return true; 40 | } 41 | 42 | /** 43 | * {@inheritdoc} 44 | */ 45 | public function getCacheKey($name) 46 | { 47 | return $name; 48 | } 49 | 50 | /** 51 | * {@inheritdoc} 52 | */ 53 | public function isFresh($name, $time) 54 | { 55 | return true; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /inc/Twig/Twig/LoaderInterface.php: -------------------------------------------------------------------------------- 1 | 16 | */ 17 | interface Twig_LoaderInterface 18 | { 19 | /** 20 | * Gets the source code of a template, given its name. 21 | * 22 | * @param string $name The name of the template to load 23 | * 24 | * @return string The template source code 25 | * 26 | * @throws Twig_Error_Loader When $name is not found 27 | */ 28 | public function getSource($name); 29 | 30 | /** 31 | * Gets the cache key to use for the cache for a given template name. 32 | * 33 | * @param string $name The name of the template to load 34 | * 35 | * @return string The cache key 36 | * 37 | * @throws Twig_Error_Loader When $name is not found 38 | */ 39 | public function getCacheKey($name); 40 | 41 | /** 42 | * Returns true if the template is still fresh. 43 | * 44 | * @param string $name The template name 45 | * @param timestamp $time The last modification time of the cached template 46 | * 47 | * @return bool true if the template is fresh, false otherwise 48 | * 49 | * @throws Twig_Error_Loader When $name is not found 50 | */ 51 | public function isFresh($name, $time); 52 | } 53 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Markup.php: -------------------------------------------------------------------------------- 1 | 16 | */ 17 | class Twig_Markup implements Countable 18 | { 19 | protected $content; 20 | protected $charset; 21 | 22 | public function __construct($content, $charset) 23 | { 24 | $this->content = (string) $content; 25 | $this->charset = $charset; 26 | } 27 | 28 | public function __toString() 29 | { 30 | return $this->content; 31 | } 32 | 33 | public function count() 34 | { 35 | return function_exists('mb_get_info') ? mb_strlen($this->content, $this->charset) : strlen($this->content); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Node/AutoEscape.php: -------------------------------------------------------------------------------- 1 | 22 | */ 23 | class Twig_Node_AutoEscape extends Twig_Node 24 | { 25 | public function __construct($value, Twig_NodeInterface $body, $lineno, $tag = 'autoescape') 26 | { 27 | parent::__construct(array('body' => $body), array('value' => $value), $lineno, $tag); 28 | } 29 | 30 | /** 31 | * Compiles the node to PHP. 32 | * 33 | * @param Twig_Compiler $compiler A Twig_Compiler instance 34 | */ 35 | public function compile(Twig_Compiler $compiler) 36 | { 37 | $compiler->subcompile($this->getNode('body')); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Node/Block.php: -------------------------------------------------------------------------------- 1 | 17 | */ 18 | class Twig_Node_Block extends Twig_Node 19 | { 20 | public function __construct($name, Twig_NodeInterface $body, $lineno, $tag = null) 21 | { 22 | parent::__construct(array('body' => $body), array('name' => $name), $lineno, $tag); 23 | } 24 | 25 | /** 26 | * Compiles the node to PHP. 27 | * 28 | * @param Twig_Compiler $compiler A Twig_Compiler instance 29 | */ 30 | public function compile(Twig_Compiler $compiler) 31 | { 32 | $compiler 33 | ->addDebugInfo($this) 34 | ->write(sprintf("public function block_%s(\$context, array \$blocks = array())\n", $this->getAttribute('name')), "{\n") 35 | ->indent() 36 | ; 37 | 38 | $compiler 39 | ->subcompile($this->getNode('body')) 40 | ->outdent() 41 | ->write("}\n\n") 42 | ; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Node/BlockReference.php: -------------------------------------------------------------------------------- 1 | 17 | */ 18 | class Twig_Node_BlockReference extends Twig_Node implements Twig_NodeOutputInterface 19 | { 20 | public function __construct($name, $lineno, $tag = null) 21 | { 22 | parent::__construct(array(), array('name' => $name), $lineno, $tag); 23 | } 24 | 25 | /** 26 | * Compiles the node to PHP. 27 | * 28 | * @param Twig_Compiler $compiler A Twig_Compiler instance 29 | */ 30 | public function compile(Twig_Compiler $compiler) 31 | { 32 | $compiler 33 | ->addDebugInfo($this) 34 | ->write(sprintf("\$this->displayBlock('%s', \$context, \$blocks);\n", $this->getAttribute('name'))) 35 | ; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Node/Body.php: -------------------------------------------------------------------------------- 1 | 16 | */ 17 | class Twig_Node_Body extends Twig_Node 18 | { 19 | } 20 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Node/Do.php: -------------------------------------------------------------------------------- 1 | 16 | */ 17 | class Twig_Node_Do extends Twig_Node 18 | { 19 | public function __construct(Twig_Node_Expression $expr, $lineno, $tag = null) 20 | { 21 | parent::__construct(array('expr' => $expr), array(), $lineno, $tag); 22 | } 23 | 24 | /** 25 | * Compiles the node to PHP. 26 | * 27 | * @param Twig_Compiler $compiler A Twig_Compiler instance 28 | */ 29 | public function compile(Twig_Compiler $compiler) 30 | { 31 | $compiler 32 | ->addDebugInfo($this) 33 | ->write('') 34 | ->subcompile($this->getNode('expr')) 35 | ->raw(";\n") 36 | ; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Node/Embed.php: -------------------------------------------------------------------------------- 1 | 16 | */ 17 | class Twig_Node_Embed extends Twig_Node_Include 18 | { 19 | // we don't inject the module to avoid node visitors to traverse it twice (as it will be already visited in the main module) 20 | public function __construct($filename, $index, Twig_Node_Expression $variables = null, $only = false, $ignoreMissing = false, $lineno, $tag = null) 21 | { 22 | parent::__construct(new Twig_Node_Expression_Constant('not_used', $lineno), $variables, $only, $ignoreMissing, $lineno, $tag); 23 | 24 | $this->setAttribute('filename', $filename); 25 | $this->setAttribute('index', $index); 26 | } 27 | 28 | protected function addGetTemplate(Twig_Compiler $compiler) 29 | { 30 | $compiler 31 | ->write("\$this->env->loadTemplate(") 32 | ->string($this->getAttribute('filename')) 33 | ->raw(', ') 34 | ->string($this->getAttribute('index')) 35 | ->raw(")") 36 | ; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Node/Expression.php: -------------------------------------------------------------------------------- 1 | 17 | */ 18 | abstract class Twig_Node_Expression extends Twig_Node 19 | { 20 | } 21 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Node/Expression/Array.php: -------------------------------------------------------------------------------- 1 | index = -1; 20 | foreach ($this->getKeyValuePairs() as $pair) { 21 | if ($pair['key'] instanceof Twig_Node_Expression_Constant && ctype_digit((string) $pair['key']->getAttribute('value')) && $pair['key']->getAttribute('value') > $this->index) { 22 | $this->index = $pair['key']->getAttribute('value'); 23 | } 24 | } 25 | } 26 | 27 | public function getKeyValuePairs() 28 | { 29 | $pairs = array(); 30 | 31 | foreach (array_chunk($this->nodes, 2) as $pair) { 32 | $pairs[] = array( 33 | 'key' => $pair[0], 34 | 'value' => $pair[1], 35 | ); 36 | } 37 | 38 | return $pairs; 39 | } 40 | 41 | public function hasElement(Twig_Node_Expression $key) 42 | { 43 | foreach ($this->getKeyValuePairs() as $pair) { 44 | // we compare the string representation of the keys 45 | // to avoid comparing the line numbers which are not relevant here. 46 | if ((string) $key == (string) $pair['key']) { 47 | return true; 48 | } 49 | } 50 | 51 | return false; 52 | } 53 | 54 | public function addElement(Twig_Node_Expression $value, Twig_Node_Expression $key = null) 55 | { 56 | if (null === $key) { 57 | $key = new Twig_Node_Expression_Constant(++$this->index, $value->getLine()); 58 | } 59 | 60 | array_push($this->nodes, $key, $value); 61 | } 62 | 63 | /** 64 | * Compiles the node to PHP. 65 | * 66 | * @param Twig_Compiler $compiler A Twig_Compiler instance 67 | */ 68 | public function compile(Twig_Compiler $compiler) 69 | { 70 | $compiler->raw('array('); 71 | $first = true; 72 | foreach ($this->getKeyValuePairs() as $pair) { 73 | if (!$first) { 74 | $compiler->raw(', '); 75 | } 76 | $first = false; 77 | 78 | $compiler 79 | ->subcompile($pair['key']) 80 | ->raw(' => ') 81 | ->subcompile($pair['value']) 82 | ; 83 | } 84 | $compiler->raw(')'); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Node/Expression/AssignName.php: -------------------------------------------------------------------------------- 1 | raw('$context[') 24 | ->string($this->getAttribute('name')) 25 | ->raw(']') 26 | ; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Node/Expression/Binary.php: -------------------------------------------------------------------------------- 1 | $left, 'right' => $right), array(), $lineno); 17 | } 18 | 19 | /** 20 | * Compiles the node to PHP. 21 | * 22 | * @param Twig_Compiler $compiler A Twig_Compiler instance 23 | */ 24 | public function compile(Twig_Compiler $compiler) 25 | { 26 | $compiler 27 | ->raw('(') 28 | ->subcompile($this->getNode('left')) 29 | ->raw(' ') 30 | ; 31 | $this->operator($compiler); 32 | $compiler 33 | ->raw(' ') 34 | ->subcompile($this->getNode('right')) 35 | ->raw(')') 36 | ; 37 | } 38 | 39 | abstract public function operator(Twig_Compiler $compiler); 40 | } 41 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Node/Expression/Binary/Add.php: -------------------------------------------------------------------------------- 1 | raw('+'); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Node/Expression/Binary/And.php: -------------------------------------------------------------------------------- 1 | raw('&&'); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Node/Expression/Binary/BitwiseAnd.php: -------------------------------------------------------------------------------- 1 | raw('&'); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Node/Expression/Binary/BitwiseOr.php: -------------------------------------------------------------------------------- 1 | raw('|'); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Node/Expression/Binary/BitwiseXor.php: -------------------------------------------------------------------------------- 1 | raw('^'); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Node/Expression/Binary/Concat.php: -------------------------------------------------------------------------------- 1 | raw('.'); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Node/Expression/Binary/Div.php: -------------------------------------------------------------------------------- 1 | raw('/'); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Node/Expression/Binary/EndsWith.php: -------------------------------------------------------------------------------- 1 | getVarName(); 16 | $right = $compiler->getVarName(); 17 | $compiler 18 | ->raw(sprintf('(is_string($%s = ', $left)) 19 | ->subcompile($this->getNode('left')) 20 | ->raw(sprintf(') && is_string($%s = ', $right)) 21 | ->subcompile($this->getNode('right')) 22 | ->raw(sprintf(') && (\'\' === $%2$s || $%2$s === substr($%1$s, -strlen($%2$s))))', $left, $right)) 23 | ; 24 | } 25 | 26 | public function operator(Twig_Compiler $compiler) 27 | { 28 | return $compiler->raw(''); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Node/Expression/Binary/Equal.php: -------------------------------------------------------------------------------- 1 | raw('=='); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Node/Expression/Binary/FloorDiv.php: -------------------------------------------------------------------------------- 1 | raw('intval(floor('); 21 | parent::compile($compiler); 22 | $compiler->raw('))'); 23 | } 24 | 25 | public function operator(Twig_Compiler $compiler) 26 | { 27 | return $compiler->raw('/'); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Node/Expression/Binary/Greater.php: -------------------------------------------------------------------------------- 1 | raw('>'); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Node/Expression/Binary/GreaterEqual.php: -------------------------------------------------------------------------------- 1 | raw('>='); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Node/Expression/Binary/In.php: -------------------------------------------------------------------------------- 1 | raw('twig_in_filter(') 22 | ->subcompile($this->getNode('left')) 23 | ->raw(', ') 24 | ->subcompile($this->getNode('right')) 25 | ->raw(')') 26 | ; 27 | } 28 | 29 | public function operator(Twig_Compiler $compiler) 30 | { 31 | return $compiler->raw('in'); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Node/Expression/Binary/Less.php: -------------------------------------------------------------------------------- 1 | raw('<'); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Node/Expression/Binary/LessEqual.php: -------------------------------------------------------------------------------- 1 | raw('<='); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Node/Expression/Binary/Matches.php: -------------------------------------------------------------------------------- 1 | raw('preg_match(') 17 | ->subcompile($this->getNode('right')) 18 | ->raw(', ') 19 | ->subcompile($this->getNode('left')) 20 | ->raw(')') 21 | ; 22 | } 23 | 24 | public function operator(Twig_Compiler $compiler) 25 | { 26 | return $compiler->raw(''); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Node/Expression/Binary/Mod.php: -------------------------------------------------------------------------------- 1 | raw('%'); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Node/Expression/Binary/Mul.php: -------------------------------------------------------------------------------- 1 | raw('*'); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Node/Expression/Binary/NotEqual.php: -------------------------------------------------------------------------------- 1 | raw('!='); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Node/Expression/Binary/NotIn.php: -------------------------------------------------------------------------------- 1 | raw('!twig_in_filter(') 22 | ->subcompile($this->getNode('left')) 23 | ->raw(', ') 24 | ->subcompile($this->getNode('right')) 25 | ->raw(')') 26 | ; 27 | } 28 | 29 | public function operator(Twig_Compiler $compiler) 30 | { 31 | return $compiler->raw('not in'); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Node/Expression/Binary/Or.php: -------------------------------------------------------------------------------- 1 | raw('||'); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Node/Expression/Binary/Power.php: -------------------------------------------------------------------------------- 1 | raw('pow(') 22 | ->subcompile($this->getNode('left')) 23 | ->raw(', ') 24 | ->subcompile($this->getNode('right')) 25 | ->raw(')') 26 | ; 27 | } 28 | 29 | public function operator(Twig_Compiler $compiler) 30 | { 31 | return $compiler->raw('**'); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Node/Expression/Binary/Range.php: -------------------------------------------------------------------------------- 1 | raw('range(') 22 | ->subcompile($this->getNode('left')) 23 | ->raw(', ') 24 | ->subcompile($this->getNode('right')) 25 | ->raw(')') 26 | ; 27 | } 28 | 29 | public function operator(Twig_Compiler $compiler) 30 | { 31 | return $compiler->raw('..'); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Node/Expression/Binary/StartsWith.php: -------------------------------------------------------------------------------- 1 | getVarName(); 16 | $right = $compiler->getVarName(); 17 | $compiler 18 | ->raw(sprintf('(is_string($%s = ', $left)) 19 | ->subcompile($this->getNode('left')) 20 | ->raw(sprintf(') && is_string($%s = ', $right)) 21 | ->subcompile($this->getNode('right')) 22 | ->raw(sprintf(') && (\'\' === $%2$s || 0 === strpos($%1$s, $%2$s)))', $left, $right)) 23 | ; 24 | } 25 | 26 | public function operator(Twig_Compiler $compiler) 27 | { 28 | return $compiler->raw(''); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Node/Expression/Binary/Sub.php: -------------------------------------------------------------------------------- 1 | raw('-'); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Node/Expression/BlockReference.php: -------------------------------------------------------------------------------- 1 | 17 | */ 18 | class Twig_Node_Expression_BlockReference extends Twig_Node_Expression 19 | { 20 | public function __construct(Twig_NodeInterface $name, $asString = false, $lineno, $tag = null) 21 | { 22 | parent::__construct(array('name' => $name), array('as_string' => $asString, 'output' => false), $lineno, $tag); 23 | } 24 | 25 | /** 26 | * Compiles the node to PHP. 27 | * 28 | * @param Twig_Compiler $compiler A Twig_Compiler instance 29 | */ 30 | public function compile(Twig_Compiler $compiler) 31 | { 32 | if ($this->getAttribute('as_string')) { 33 | $compiler->raw('(string) '); 34 | } 35 | 36 | if ($this->getAttribute('output')) { 37 | $compiler 38 | ->addDebugInfo($this) 39 | ->write("\$this->displayBlock(") 40 | ->subcompile($this->getNode('name')) 41 | ->raw(", \$context, \$blocks);\n") 42 | ; 43 | } else { 44 | $compiler 45 | ->raw("\$this->renderBlock(") 46 | ->subcompile($this->getNode('name')) 47 | ->raw(", \$context, \$blocks)") 48 | ; 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Node/Expression/Conditional.php: -------------------------------------------------------------------------------- 1 | $expr1, 'expr2' => $expr2, 'expr3' => $expr3), array(), $lineno); 17 | } 18 | 19 | public function compile(Twig_Compiler $compiler) 20 | { 21 | $compiler 22 | ->raw('((') 23 | ->subcompile($this->getNode('expr1')) 24 | ->raw(') ? (') 25 | ->subcompile($this->getNode('expr2')) 26 | ->raw(') : (') 27 | ->subcompile($this->getNode('expr3')) 28 | ->raw('))') 29 | ; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Node/Expression/Constant.php: -------------------------------------------------------------------------------- 1 | $value), $lineno); 17 | } 18 | 19 | public function compile(Twig_Compiler $compiler) 20 | { 21 | $compiler->repr($this->getAttribute('value')); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Node/Expression/ExtensionReference.php: -------------------------------------------------------------------------------- 1 | 16 | */ 17 | class Twig_Node_Expression_ExtensionReference extends Twig_Node_Expression 18 | { 19 | public function __construct($name, $lineno, $tag = null) 20 | { 21 | parent::__construct(array(), array('name' => $name), $lineno, $tag); 22 | } 23 | 24 | /** 25 | * Compiles the node to PHP. 26 | * 27 | * @param Twig_Compiler $compiler A Twig_Compiler instance 28 | */ 29 | public function compile(Twig_Compiler $compiler) 30 | { 31 | $compiler->raw(sprintf("\$this->env->getExtension('%s')", $this->getAttribute('name'))); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Node/Expression/Filter.php: -------------------------------------------------------------------------------- 1 | $node, 'filter' => $filterName, 'arguments' => $arguments), array(), $lineno, $tag); 17 | } 18 | 19 | public function compile(Twig_Compiler $compiler) 20 | { 21 | $name = $this->getNode('filter')->getAttribute('value'); 22 | $filter = $compiler->getEnvironment()->getFilter($name); 23 | 24 | $this->setAttribute('name', $name); 25 | $this->setAttribute('type', 'filter'); 26 | $this->setAttribute('thing', $filter); 27 | $this->setAttribute('needs_environment', $filter->needsEnvironment()); 28 | $this->setAttribute('needs_context', $filter->needsContext()); 29 | $this->setAttribute('arguments', $filter->getArguments()); 30 | if ($filter instanceof Twig_FilterCallableInterface || $filter instanceof Twig_SimpleFilter) { 31 | $this->setAttribute('callable', $filter->getCallable()); 32 | } 33 | 34 | $this->compileCallable($compiler); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Node/Expression/Filter/Default.php: -------------------------------------------------------------------------------- 1 | 16 | * {{ var.foo|default('foo item on var is not defined') }} 17 | * 18 | * 19 | * @author Fabien Potencier 20 | */ 21 | class Twig_Node_Expression_Filter_Default extends Twig_Node_Expression_Filter 22 | { 23 | public function __construct(Twig_NodeInterface $node, Twig_Node_Expression_Constant $filterName, Twig_NodeInterface $arguments, $lineno, $tag = null) 24 | { 25 | $default = new Twig_Node_Expression_Filter($node, new Twig_Node_Expression_Constant('default', $node->getLine()), $arguments, $node->getLine()); 26 | 27 | if ('default' === $filterName->getAttribute('value') && ($node instanceof Twig_Node_Expression_Name || $node instanceof Twig_Node_Expression_GetAttr)) { 28 | $test = new Twig_Node_Expression_Test_Defined(clone $node, 'defined', new Twig_Node(), $node->getLine()); 29 | $false = count($arguments) ? $arguments->getNode(0) : new Twig_Node_Expression_Constant('', $node->getLine()); 30 | 31 | $node = new Twig_Node_Expression_Conditional($test, $default, $false, $node->getLine()); 32 | } else { 33 | $node = $default; 34 | } 35 | 36 | parent::__construct($node, $filterName, $arguments, $lineno, $tag); 37 | } 38 | 39 | public function compile(Twig_Compiler $compiler) 40 | { 41 | $compiler->subcompile($this->getNode('node')); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Node/Expression/Function.php: -------------------------------------------------------------------------------- 1 | $arguments), array('name' => $name), $lineno); 16 | } 17 | 18 | public function compile(Twig_Compiler $compiler) 19 | { 20 | $name = $this->getAttribute('name'); 21 | $function = $compiler->getEnvironment()->getFunction($name); 22 | 23 | $this->setAttribute('name', $name); 24 | $this->setAttribute('type', 'function'); 25 | $this->setAttribute('thing', $function); 26 | $this->setAttribute('needs_environment', $function->needsEnvironment()); 27 | $this->setAttribute('needs_context', $function->needsContext()); 28 | $this->setAttribute('arguments', $function->getArguments()); 29 | if ($function instanceof Twig_FunctionCallableInterface || $function instanceof Twig_SimpleFunction) { 30 | $this->setAttribute('callable', $function->getCallable()); 31 | } 32 | 33 | $this->compileCallable($compiler); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Node/Expression/GetAttr.php: -------------------------------------------------------------------------------- 1 | $node, 'attribute' => $attribute, 'arguments' => $arguments), array('type' => $type, 'is_defined_test' => false, 'ignore_strict_check' => false, 'disable_c_ext' => false), $lineno); 17 | } 18 | 19 | public function compile(Twig_Compiler $compiler) 20 | { 21 | if (function_exists('twig_template_get_attributes') && !$this->getAttribute('disable_c_ext')) { 22 | $compiler->raw('twig_template_get_attributes($this, '); 23 | } else { 24 | $compiler->raw('$this->getAttribute('); 25 | } 26 | 27 | if ($this->getAttribute('ignore_strict_check')) { 28 | $this->getNode('node')->setAttribute('ignore_strict_check', true); 29 | } 30 | 31 | $compiler->subcompile($this->getNode('node')); 32 | 33 | $compiler->raw(', ')->subcompile($this->getNode('attribute')); 34 | 35 | // only generate optional arguments when needed (to make generated code more readable) 36 | $needFourth = $this->getAttribute('ignore_strict_check'); 37 | $needThird = $needFourth || $this->getAttribute('is_defined_test'); 38 | $needSecond = $needThird || Twig_Template::ANY_CALL !== $this->getAttribute('type'); 39 | $needFirst = $needSecond || null !== $this->getNode('arguments'); 40 | 41 | if ($needFirst) { 42 | if (null !== $this->getNode('arguments')) { 43 | $compiler->raw(', ')->subcompile($this->getNode('arguments')); 44 | } else { 45 | $compiler->raw(', array()'); 46 | } 47 | } 48 | 49 | if ($needSecond) { 50 | $compiler->raw(', ')->repr($this->getAttribute('type')); 51 | } 52 | 53 | if ($needThird) { 54 | $compiler->raw(', ')->repr($this->getAttribute('is_defined_test')); 55 | } 56 | 57 | if ($needFourth) { 58 | $compiler->raw(', ')->repr($this->getAttribute('ignore_strict_check')); 59 | } 60 | 61 | $compiler->raw(')'); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Node/Expression/MethodCall.php: -------------------------------------------------------------------------------- 1 | $node, 'arguments' => $arguments), array('method' => $method, 'safe' => false), $lineno); 16 | 17 | if ($node instanceof Twig_Node_Expression_Name) { 18 | $node->setAttribute('always_defined', true); 19 | } 20 | } 21 | 22 | public function compile(Twig_Compiler $compiler) 23 | { 24 | $compiler 25 | ->subcompile($this->getNode('node')) 26 | ->raw('->') 27 | ->raw($this->getAttribute('method')) 28 | ->raw('(') 29 | ; 30 | $first = true; 31 | foreach ($this->getNode('arguments')->getKeyValuePairs() as $pair) { 32 | if (!$first) { 33 | $compiler->raw(', '); 34 | } 35 | $first = false; 36 | 37 | $compiler->subcompile($pair['value']); 38 | } 39 | $compiler->raw(')'); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Node/Expression/Parent.php: -------------------------------------------------------------------------------- 1 | 17 | */ 18 | class Twig_Node_Expression_Parent extends Twig_Node_Expression 19 | { 20 | public function __construct($name, $lineno, $tag = null) 21 | { 22 | parent::__construct(array(), array('output' => false, 'name' => $name), $lineno, $tag); 23 | } 24 | 25 | /** 26 | * Compiles the node to PHP. 27 | * 28 | * @param Twig_Compiler $compiler A Twig_Compiler instance 29 | */ 30 | public function compile(Twig_Compiler $compiler) 31 | { 32 | if ($this->getAttribute('output')) { 33 | $compiler 34 | ->addDebugInfo($this) 35 | ->write("\$this->displayParentBlock(") 36 | ->string($this->getAttribute('name')) 37 | ->raw(", \$context, \$blocks);\n") 38 | ; 39 | } else { 40 | $compiler 41 | ->raw("\$this->renderParentBlock(") 42 | ->string($this->getAttribute('name')) 43 | ->raw(", \$context, \$blocks)") 44 | ; 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Node/Expression/TempName.php: -------------------------------------------------------------------------------- 1 | $name), $lineno); 16 | } 17 | 18 | public function compile(Twig_Compiler $compiler) 19 | { 20 | $compiler 21 | ->raw('$_') 22 | ->raw($this->getAttribute('name')) 23 | ->raw('_') 24 | ; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Node/Expression/Test.php: -------------------------------------------------------------------------------- 1 | $node, 'arguments' => $arguments), array('name' => $name), $lineno); 16 | } 17 | 18 | public function compile(Twig_Compiler $compiler) 19 | { 20 | $name = $this->getAttribute('name'); 21 | $test = $compiler->getEnvironment()->getTest($name); 22 | 23 | $this->setAttribute('name', $name); 24 | $this->setAttribute('type', 'test'); 25 | $this->setAttribute('thing', $test); 26 | if ($test instanceof Twig_TestCallableInterface || $test instanceof Twig_SimpleTest) { 27 | $this->setAttribute('callable', $test->getCallable()); 28 | } 29 | 30 | $this->compileCallable($compiler); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Node/Expression/Test/Constant.php: -------------------------------------------------------------------------------- 1 | 16 | * {% if post.status is constant('Post::PUBLISHED') %} 17 | * the status attribute is exactly the same as Post::PUBLISHED 18 | * {% endif %} 19 | * 20 | * 21 | * @author Fabien Potencier 22 | */ 23 | class Twig_Node_Expression_Test_Constant extends Twig_Node_Expression_Test 24 | { 25 | public function compile(Twig_Compiler $compiler) 26 | { 27 | $compiler 28 | ->raw('(') 29 | ->subcompile($this->getNode('node')) 30 | ->raw(' === constant(') 31 | ; 32 | 33 | if ($this->getNode('arguments')->hasNode(1)) { 34 | $compiler 35 | ->raw('get_class(') 36 | ->subcompile($this->getNode('arguments')->getNode(1)) 37 | ->raw(')."::".') 38 | ; 39 | } 40 | 41 | $compiler 42 | ->subcompile($this->getNode('arguments')->getNode(0)) 43 | ->raw('))') 44 | ; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Node/Expression/Test/Defined.php: -------------------------------------------------------------------------------- 1 | 16 | * {# defined works with variable names and variable attributes #} 17 | * {% if foo is defined %} 18 | * {# ... #} 19 | * {% endif %} 20 | * 21 | * 22 | * @author Fabien Potencier 23 | */ 24 | class Twig_Node_Expression_Test_Defined extends Twig_Node_Expression_Test 25 | { 26 | public function __construct(Twig_NodeInterface $node, $name, Twig_NodeInterface $arguments = null, $lineno) 27 | { 28 | parent::__construct($node, $name, $arguments, $lineno); 29 | 30 | if ($node instanceof Twig_Node_Expression_Name) { 31 | $node->setAttribute('is_defined_test', true); 32 | } elseif ($node instanceof Twig_Node_Expression_GetAttr) { 33 | $node->setAttribute('is_defined_test', true); 34 | 35 | $this->changeIgnoreStrictCheck($node); 36 | } else { 37 | throw new Twig_Error_Syntax('The "defined" test only works with simple variables', $this->getLine()); 38 | } 39 | } 40 | 41 | protected function changeIgnoreStrictCheck(Twig_Node_Expression_GetAttr $node) 42 | { 43 | $node->setAttribute('ignore_strict_check', true); 44 | 45 | if ($node->getNode('node') instanceof Twig_Node_Expression_GetAttr) { 46 | $this->changeIgnoreStrictCheck($node->getNode('node')); 47 | } 48 | } 49 | 50 | public function compile(Twig_Compiler $compiler) 51 | { 52 | $compiler->subcompile($this->getNode('node')); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Node/Expression/Test/Divisibleby.php: -------------------------------------------------------------------------------- 1 | 16 | * {% if loop.index is divisible by(3) %} 17 | * 18 | * 19 | * @author Fabien Potencier 20 | */ 21 | class Twig_Node_Expression_Test_Divisibleby extends Twig_Node_Expression_Test 22 | { 23 | public function compile(Twig_Compiler $compiler) 24 | { 25 | $compiler 26 | ->raw('(0 == ') 27 | ->subcompile($this->getNode('node')) 28 | ->raw(' % ') 29 | ->subcompile($this->getNode('arguments')->getNode(0)) 30 | ->raw(')') 31 | ; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Node/Expression/Test/Even.php: -------------------------------------------------------------------------------- 1 | 16 | * {{ var is even }} 17 | * 18 | * 19 | * @author Fabien Potencier 20 | */ 21 | class Twig_Node_Expression_Test_Even extends Twig_Node_Expression_Test 22 | { 23 | public function compile(Twig_Compiler $compiler) 24 | { 25 | $compiler 26 | ->raw('(') 27 | ->subcompile($this->getNode('node')) 28 | ->raw(' % 2 == 0') 29 | ->raw(')') 30 | ; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Node/Expression/Test/Null.php: -------------------------------------------------------------------------------- 1 | 16 | * {{ var is none }} 17 | * 18 | * 19 | * @author Fabien Potencier 20 | */ 21 | class Twig_Node_Expression_Test_Null extends Twig_Node_Expression_Test 22 | { 23 | public function compile(Twig_Compiler $compiler) 24 | { 25 | $compiler 26 | ->raw('(null === ') 27 | ->subcompile($this->getNode('node')) 28 | ->raw(')') 29 | ; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Node/Expression/Test/Odd.php: -------------------------------------------------------------------------------- 1 | 16 | * {{ var is odd }} 17 | * 18 | * 19 | * @author Fabien Potencier 20 | */ 21 | class Twig_Node_Expression_Test_Odd extends Twig_Node_Expression_Test 22 | { 23 | public function compile(Twig_Compiler $compiler) 24 | { 25 | $compiler 26 | ->raw('(') 27 | ->subcompile($this->getNode('node')) 28 | ->raw(' % 2 == 1') 29 | ->raw(')') 30 | ; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Node/Expression/Test/Sameas.php: -------------------------------------------------------------------------------- 1 | 16 | */ 17 | class Twig_Node_Expression_Test_Sameas extends Twig_Node_Expression_Test 18 | { 19 | public function compile(Twig_Compiler $compiler) 20 | { 21 | $compiler 22 | ->raw('(') 23 | ->subcompile($this->getNode('node')) 24 | ->raw(' === ') 25 | ->subcompile($this->getNode('arguments')->getNode(0)) 26 | ->raw(')') 27 | ; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Node/Expression/Unary.php: -------------------------------------------------------------------------------- 1 | $node), array(), $lineno); 17 | } 18 | 19 | public function compile(Twig_Compiler $compiler) 20 | { 21 | $compiler->raw('('); 22 | $this->operator($compiler); 23 | $compiler 24 | ->subcompile($this->getNode('node')) 25 | ->raw(')') 26 | ; 27 | } 28 | 29 | abstract public function operator(Twig_Compiler $compiler); 30 | } 31 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Node/Expression/Unary/Neg.php: -------------------------------------------------------------------------------- 1 | raw('-'); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Node/Expression/Unary/Not.php: -------------------------------------------------------------------------------- 1 | raw('!'); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Node/Expression/Unary/Pos.php: -------------------------------------------------------------------------------- 1 | raw('+'); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Node/Flush.php: -------------------------------------------------------------------------------- 1 | 16 | */ 17 | class Twig_Node_Flush extends Twig_Node 18 | { 19 | public function __construct($lineno, $tag) 20 | { 21 | parent::__construct(array(), array(), $lineno, $tag); 22 | } 23 | 24 | /** 25 | * Compiles the node to PHP. 26 | * 27 | * @param Twig_Compiler $compiler A Twig_Compiler instance 28 | */ 29 | public function compile(Twig_Compiler $compiler) 30 | { 31 | $compiler 32 | ->addDebugInfo($this) 33 | ->write("flush();\n") 34 | ; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Node/ForLoop.php: -------------------------------------------------------------------------------- 1 | 16 | */ 17 | class Twig_Node_ForLoop extends Twig_Node 18 | { 19 | public function __construct($lineno, $tag = null) 20 | { 21 | parent::__construct(array(), array('with_loop' => false, 'ifexpr' => false, 'else' => false), $lineno, $tag); 22 | } 23 | 24 | /** 25 | * Compiles the node to PHP. 26 | * 27 | * @param Twig_Compiler $compiler A Twig_Compiler instance 28 | */ 29 | public function compile(Twig_Compiler $compiler) 30 | { 31 | if ($this->getAttribute('else')) { 32 | $compiler->write("\$context['_iterated'] = true;\n"); 33 | } 34 | 35 | if ($this->getAttribute('with_loop')) { 36 | $compiler 37 | ->write("++\$context['loop']['index0'];\n") 38 | ->write("++\$context['loop']['index'];\n") 39 | ->write("\$context['loop']['first'] = false;\n") 40 | ; 41 | 42 | if (!$this->getAttribute('ifexpr')) { 43 | $compiler 44 | ->write("if (isset(\$context['loop']['length'])) {\n") 45 | ->indent() 46 | ->write("--\$context['loop']['revindex0'];\n") 47 | ->write("--\$context['loop']['revindex'];\n") 48 | ->write("\$context['loop']['last'] = 0 === \$context['loop']['revindex0'];\n") 49 | ->outdent() 50 | ->write("}\n") 51 | ; 52 | } 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Node/If.php: -------------------------------------------------------------------------------- 1 | 17 | */ 18 | class Twig_Node_If extends Twig_Node 19 | { 20 | public function __construct(Twig_NodeInterface $tests, Twig_NodeInterface $else = null, $lineno, $tag = null) 21 | { 22 | parent::__construct(array('tests' => $tests, 'else' => $else), array(), $lineno, $tag); 23 | } 24 | 25 | /** 26 | * Compiles the node to PHP. 27 | * 28 | * @param Twig_Compiler $compiler A Twig_Compiler instance 29 | */ 30 | public function compile(Twig_Compiler $compiler) 31 | { 32 | $compiler->addDebugInfo($this); 33 | for ($i = 0, $count = count($this->getNode('tests')); $i < $count; $i += 2) { 34 | if ($i > 0) { 35 | $compiler 36 | ->outdent() 37 | ->write("} elseif (") 38 | ; 39 | } else { 40 | $compiler 41 | ->write('if (') 42 | ; 43 | } 44 | 45 | $compiler 46 | ->subcompile($this->getNode('tests')->getNode($i)) 47 | ->raw(") {\n") 48 | ->indent() 49 | ->subcompile($this->getNode('tests')->getNode($i + 1)) 50 | ; 51 | } 52 | 53 | if ($this->hasNode('else') && null !== $this->getNode('else')) { 54 | $compiler 55 | ->outdent() 56 | ->write("} else {\n") 57 | ->indent() 58 | ->subcompile($this->getNode('else')) 59 | ; 60 | } 61 | 62 | $compiler 63 | ->outdent() 64 | ->write("}\n"); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Node/Import.php: -------------------------------------------------------------------------------- 1 | 16 | */ 17 | class Twig_Node_Import extends Twig_Node 18 | { 19 | public function __construct(Twig_Node_Expression $expr, Twig_Node_Expression $var, $lineno, $tag = null) 20 | { 21 | parent::__construct(array('expr' => $expr, 'var' => $var), array(), $lineno, $tag); 22 | } 23 | 24 | /** 25 | * Compiles the node to PHP. 26 | * 27 | * @param Twig_Compiler $compiler A Twig_Compiler instance 28 | */ 29 | public function compile(Twig_Compiler $compiler) 30 | { 31 | $compiler 32 | ->addDebugInfo($this) 33 | ->write('') 34 | ->subcompile($this->getNode('var')) 35 | ->raw(' = ') 36 | ; 37 | 38 | if ($this->getNode('expr') instanceof Twig_Node_Expression_Name && '_self' === $this->getNode('expr')->getAttribute('name')) { 39 | $compiler->raw("\$this"); 40 | } else { 41 | $compiler 42 | ->raw('$this->env->loadTemplate(') 43 | ->subcompile($this->getNode('expr')) 44 | ->raw(")") 45 | ; 46 | } 47 | 48 | $compiler->raw(";\n"); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Node/Include.php: -------------------------------------------------------------------------------- 1 | 17 | */ 18 | class Twig_Node_Include extends Twig_Node implements Twig_NodeOutputInterface 19 | { 20 | public function __construct(Twig_Node_Expression $expr, Twig_Node_Expression $variables = null, $only = false, $ignoreMissing = false, $lineno, $tag = null) 21 | { 22 | parent::__construct(array('expr' => $expr, 'variables' => $variables), array('only' => (bool) $only, 'ignore_missing' => (bool) $ignoreMissing), $lineno, $tag); 23 | } 24 | 25 | /** 26 | * Compiles the node to PHP. 27 | * 28 | * @param Twig_Compiler $compiler A Twig_Compiler instance 29 | */ 30 | public function compile(Twig_Compiler $compiler) 31 | { 32 | $compiler->addDebugInfo($this); 33 | 34 | if ($this->getAttribute('ignore_missing')) { 35 | $compiler 36 | ->write("try {\n") 37 | ->indent() 38 | ; 39 | } 40 | 41 | $this->addGetTemplate($compiler); 42 | 43 | $compiler->raw('->display('); 44 | 45 | $this->addTemplateArguments($compiler); 46 | 47 | $compiler->raw(");\n"); 48 | 49 | if ($this->getAttribute('ignore_missing')) { 50 | $compiler 51 | ->outdent() 52 | ->write("} catch (Twig_Error_Loader \$e) {\n") 53 | ->indent() 54 | ->write("// ignore missing template\n") 55 | ->outdent() 56 | ->write("}\n\n") 57 | ; 58 | } 59 | } 60 | 61 | protected function addGetTemplate(Twig_Compiler $compiler) 62 | { 63 | $method = $this->getNode('expr') instanceof Twig_Node_Expression_Constant ? 'loadTemplate' : 'resolveTemplate'; 64 | $compiler 65 | ->write(sprintf('$this->env->%s(', $method)) 66 | ->subcompile($this->getNode('expr')) 67 | ->raw(')') 68 | ; 69 | } 70 | 71 | protected function addTemplateArguments(Twig_Compiler $compiler) 72 | { 73 | if (null === $this->getNode('variables')) { 74 | $compiler->raw(false === $this->getAttribute('only') ? '$context' : 'array()'); 75 | } elseif (false === $this->getAttribute('only')) { 76 | $compiler 77 | ->raw('array_merge($context, ') 78 | ->subcompile($this->getNode('variables')) 79 | ->raw(')') 80 | ; 81 | } else { 82 | $compiler->subcompile($this->getNode('variables')); 83 | } 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Node/Print.php: -------------------------------------------------------------------------------- 1 | 17 | */ 18 | class Twig_Node_Print extends Twig_Node implements Twig_NodeOutputInterface 19 | { 20 | public function __construct(Twig_Node_Expression $expr, $lineno, $tag = null) 21 | { 22 | parent::__construct(array('expr' => $expr), array(), $lineno, $tag); 23 | } 24 | 25 | /** 26 | * Compiles the node to PHP. 27 | * 28 | * @param Twig_Compiler $compiler A Twig_Compiler instance 29 | */ 30 | public function compile(Twig_Compiler $compiler) 31 | { 32 | $compiler 33 | ->addDebugInfo($this) 34 | ->write('echo ') 35 | ->subcompile($this->getNode('expr')) 36 | ->raw(";\n") 37 | ; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Node/Sandbox.php: -------------------------------------------------------------------------------- 1 | 16 | */ 17 | class Twig_Node_Sandbox extends Twig_Node 18 | { 19 | public function __construct(Twig_NodeInterface $body, $lineno, $tag = null) 20 | { 21 | parent::__construct(array('body' => $body), array(), $lineno, $tag); 22 | } 23 | 24 | /** 25 | * Compiles the node to PHP. 26 | * 27 | * @param Twig_Compiler $compiler A Twig_Compiler instance 28 | */ 29 | public function compile(Twig_Compiler $compiler) 30 | { 31 | $compiler 32 | ->addDebugInfo($this) 33 | ->write("\$sandbox = \$this->env->getExtension('sandbox');\n") 34 | ->write("if (!\$alreadySandboxed = \$sandbox->isSandboxed()) {\n") 35 | ->indent() 36 | ->write("\$sandbox->enableSandbox();\n") 37 | ->outdent() 38 | ->write("}\n") 39 | ->subcompile($this->getNode('body')) 40 | ->write("if (!\$alreadySandboxed) {\n") 41 | ->indent() 42 | ->write("\$sandbox->disableSandbox();\n") 43 | ->outdent() 44 | ->write("}\n") 45 | ; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Node/SandboxedPrint.php: -------------------------------------------------------------------------------- 1 | 21 | */ 22 | class Twig_Node_SandboxedPrint extends Twig_Node_Print 23 | { 24 | public function __construct(Twig_Node_Expression $expr, $lineno, $tag = null) 25 | { 26 | parent::__construct($expr, $lineno, $tag); 27 | } 28 | 29 | /** 30 | * Compiles the node to PHP. 31 | * 32 | * @param Twig_Compiler $compiler A Twig_Compiler instance 33 | */ 34 | public function compile(Twig_Compiler $compiler) 35 | { 36 | $compiler 37 | ->addDebugInfo($this) 38 | ->write('echo $this->env->getExtension(\'sandbox\')->ensureToStringAllowed(') 39 | ->subcompile($this->getNode('expr')) 40 | ->raw(");\n") 41 | ; 42 | } 43 | 44 | /** 45 | * Removes node filters. 46 | * 47 | * This is mostly needed when another visitor adds filters (like the escaper one). 48 | * 49 | * @param Twig_Node $node A Node 50 | */ 51 | protected function removeNodeFilter($node) 52 | { 53 | if ($node instanceof Twig_Node_Expression_Filter) { 54 | return $this->removeNodeFilter($node->getNode('node')); 55 | } 56 | 57 | return $node; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Node/SetTemp.php: -------------------------------------------------------------------------------- 1 | $name), $lineno); 17 | } 18 | 19 | public function compile(Twig_Compiler $compiler) 20 | { 21 | $name = $this->getAttribute('name'); 22 | $compiler 23 | ->addDebugInfo($this) 24 | ->write('if (isset($context[') 25 | ->string($name) 26 | ->raw('])) { $_') 27 | ->raw($name) 28 | ->raw('_ = $context[') 29 | ->repr($name) 30 | ->raw(']; } else { $_') 31 | ->raw($name) 32 | ->raw("_ = null; }\n") 33 | ; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Node/Spaceless.php: -------------------------------------------------------------------------------- 1 | 18 | */ 19 | class Twig_Node_Spaceless extends Twig_Node 20 | { 21 | public function __construct(Twig_NodeInterface $body, $lineno, $tag = 'spaceless') 22 | { 23 | parent::__construct(array('body' => $body), array(), $lineno, $tag); 24 | } 25 | 26 | /** 27 | * Compiles the node to PHP. 28 | * 29 | * @param Twig_Compiler $compiler A Twig_Compiler instance 30 | */ 31 | public function compile(Twig_Compiler $compiler) 32 | { 33 | $compiler 34 | ->addDebugInfo($this) 35 | ->write("ob_start();\n") 36 | ->subcompile($this->getNode('body')) 37 | ->write("echo trim(preg_replace('/>\s+<', ob_get_clean()));\n") 38 | ; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Node/Text.php: -------------------------------------------------------------------------------- 1 | 17 | */ 18 | class Twig_Node_Text extends Twig_Node implements Twig_NodeOutputInterface 19 | { 20 | public function __construct($data, $lineno) 21 | { 22 | parent::__construct(array(), array('data' => $data), $lineno); 23 | } 24 | 25 | /** 26 | * Compiles the node to PHP. 27 | * 28 | * @param Twig_Compiler $compiler A Twig_Compiler instance 29 | */ 30 | public function compile(Twig_Compiler $compiler) 31 | { 32 | $compiler 33 | ->addDebugInfo($this) 34 | ->write('echo ') 35 | ->string($this->getAttribute('data')) 36 | ->raw(";\n") 37 | ; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /inc/Twig/Twig/NodeInterface.php: -------------------------------------------------------------------------------- 1 | 16 | * 17 | * @deprecated since 1.12 (to be removed in 3.0) 18 | */ 19 | interface Twig_NodeInterface extends Countable, IteratorAggregate 20 | { 21 | /** 22 | * Compiles the node to PHP. 23 | * 24 | * @param Twig_Compiler $compiler A Twig_Compiler instance 25 | */ 26 | public function compile(Twig_Compiler $compiler); 27 | 28 | public function getLine(); 29 | 30 | public function getNodeTag(); 31 | } 32 | -------------------------------------------------------------------------------- /inc/Twig/Twig/NodeOutputInterface.php: -------------------------------------------------------------------------------- 1 | 16 | */ 17 | interface Twig_NodeOutputInterface 18 | { 19 | } 20 | -------------------------------------------------------------------------------- /inc/Twig/Twig/NodeTraverser.php: -------------------------------------------------------------------------------- 1 | 18 | */ 19 | class Twig_NodeTraverser 20 | { 21 | protected $env; 22 | protected $visitors; 23 | 24 | /** 25 | * Constructor. 26 | * 27 | * @param Twig_Environment $env A Twig_Environment instance 28 | * @param Twig_NodeVisitorInterface[] $visitors An array of Twig_NodeVisitorInterface instances 29 | */ 30 | public function __construct(Twig_Environment $env, array $visitors = array()) 31 | { 32 | $this->env = $env; 33 | $this->visitors = array(); 34 | foreach ($visitors as $visitor) { 35 | $this->addVisitor($visitor); 36 | } 37 | } 38 | 39 | /** 40 | * Adds a visitor. 41 | * 42 | * @param Twig_NodeVisitorInterface $visitor A Twig_NodeVisitorInterface instance 43 | */ 44 | public function addVisitor(Twig_NodeVisitorInterface $visitor) 45 | { 46 | if (!isset($this->visitors[$visitor->getPriority()])) { 47 | $this->visitors[$visitor->getPriority()] = array(); 48 | } 49 | 50 | $this->visitors[$visitor->getPriority()][] = $visitor; 51 | } 52 | 53 | /** 54 | * Traverses a node and calls the registered visitors. 55 | * 56 | * @param Twig_NodeInterface $node A Twig_NodeInterface instance 57 | */ 58 | public function traverse(Twig_NodeInterface $node) 59 | { 60 | ksort($this->visitors); 61 | foreach ($this->visitors as $visitors) { 62 | foreach ($visitors as $visitor) { 63 | $node = $this->traverseForVisitor($visitor, $node); 64 | } 65 | } 66 | 67 | return $node; 68 | } 69 | 70 | protected function traverseForVisitor(Twig_NodeVisitorInterface $visitor, Twig_NodeInterface $node = null) 71 | { 72 | if (null === $node) { 73 | return; 74 | } 75 | 76 | $node = $visitor->enterNode($node, $this->env); 77 | 78 | foreach ($node as $k => $n) { 79 | if (false !== $n = $this->traverseForVisitor($visitor, $n)) { 80 | $node->setNode($k, $n); 81 | } else { 82 | $node->removeNode($k); 83 | } 84 | } 85 | 86 | return $visitor->leaveNode($node, $this->env); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /inc/Twig/Twig/NodeVisitorInterface.php: -------------------------------------------------------------------------------- 1 | 16 | */ 17 | interface Twig_NodeVisitorInterface 18 | { 19 | /** 20 | * Called before child nodes are visited. 21 | * 22 | * @param Twig_NodeInterface $node The node to visit 23 | * @param Twig_Environment $env The Twig environment instance 24 | * 25 | * @return Twig_NodeInterface The modified node 26 | */ 27 | public function enterNode(Twig_NodeInterface $node, Twig_Environment $env); 28 | 29 | /** 30 | * Called after child nodes are visited. 31 | * 32 | * @param Twig_NodeInterface $node The node to visit 33 | * @param Twig_Environment $env The Twig environment instance 34 | * 35 | * @return Twig_NodeInterface|false The modified node or false if the node must be removed 36 | */ 37 | public function leaveNode(Twig_NodeInterface $node, Twig_Environment $env); 38 | 39 | /** 40 | * Returns the priority for this visitor. 41 | * 42 | * Priority should be between -10 and 10 (0 is the default). 43 | * 44 | * @return int The priority level 45 | */ 46 | public function getPriority(); 47 | } 48 | -------------------------------------------------------------------------------- /inc/Twig/Twig/ParserInterface.php: -------------------------------------------------------------------------------- 1 | 16 | * 17 | * @deprecated since 1.12 (to be removed in 3.0) 18 | */ 19 | interface Twig_ParserInterface 20 | { 21 | /** 22 | * Converts a token stream to a node tree. 23 | * 24 | * @param Twig_TokenStream $stream A token stream instance 25 | * 26 | * @return Twig_Node_Module A node tree 27 | * 28 | * @throws Twig_Error_Syntax When the token stream is syntactically or semantically wrong 29 | */ 30 | public function parse(Twig_TokenStream $stream); 31 | } 32 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Sandbox/SecurityError.php: -------------------------------------------------------------------------------- 1 | 16 | */ 17 | class Twig_Sandbox_SecurityError extends Twig_Error 18 | { 19 | } 20 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Sandbox/SecurityNotAllowedFilterError.php: -------------------------------------------------------------------------------- 1 | 16 | */ 17 | class Twig_Sandbox_SecurityNotAllowedFilterError extends Twig_Sandbox_SecurityError 18 | { 19 | private $filterName; 20 | 21 | public function __construct($message, $functionName, $lineno = -1, $filename = null, Exception $previous = null) 22 | { 23 | parent::__construct($message, $lineno, $filename, $previous); 24 | $this->filterName = $functionName; 25 | } 26 | 27 | public function getFilterName() 28 | { 29 | return $this->filterName; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Sandbox/SecurityNotAllowedFunctionError.php: -------------------------------------------------------------------------------- 1 | 16 | */ 17 | class Twig_Sandbox_SecurityNotAllowedFunctionError extends Twig_Sandbox_SecurityError 18 | { 19 | private $functionName; 20 | 21 | public function __construct($message, $functionName, $lineno = -1, $filename = null, Exception $previous = null) 22 | { 23 | parent::__construct($message, $lineno, $filename, $previous); 24 | $this->functionName = $functionName; 25 | } 26 | 27 | public function getFunctionName() 28 | { 29 | return $this->functionName; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Sandbox/SecurityNotAllowedTagError.php: -------------------------------------------------------------------------------- 1 | 16 | */ 17 | class Twig_Sandbox_SecurityNotAllowedTagError extends Twig_Sandbox_SecurityError 18 | { 19 | private $tagName; 20 | 21 | public function __construct($message, $tagName, $lineno = -1, $filename = null, Exception $previous = null) 22 | { 23 | parent::__construct($message, $lineno, $filename, $previous); 24 | $this->tagName = $tagName; 25 | } 26 | 27 | public function getTagName() 28 | { 29 | return $this->tagName; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Sandbox/SecurityPolicyInterface.php: -------------------------------------------------------------------------------- 1 | 16 | */ 17 | interface Twig_Sandbox_SecurityPolicyInterface 18 | { 19 | public function checkSecurity($tags, $filters, $functions); 20 | 21 | public function checkMethodAllowed($obj, $method); 22 | 23 | public function checkPropertyAllowed($obj, $method); 24 | } 25 | -------------------------------------------------------------------------------- /inc/Twig/Twig/SimpleFilter.php: -------------------------------------------------------------------------------- 1 | 16 | */ 17 | class Twig_SimpleFilter 18 | { 19 | protected $name; 20 | protected $callable; 21 | protected $options; 22 | protected $arguments = array(); 23 | 24 | public function __construct($name, $callable, array $options = array()) 25 | { 26 | $this->name = $name; 27 | $this->callable = $callable; 28 | $this->options = array_merge(array( 29 | 'needs_environment' => false, 30 | 'needs_context' => false, 31 | 'is_safe' => null, 32 | 'is_safe_callback' => null, 33 | 'pre_escape' => null, 34 | 'preserves_safety' => null, 35 | 'node_class' => 'Twig_Node_Expression_Filter', 36 | ), $options); 37 | } 38 | 39 | public function getName() 40 | { 41 | return $this->name; 42 | } 43 | 44 | public function getCallable() 45 | { 46 | return $this->callable; 47 | } 48 | 49 | public function getNodeClass() 50 | { 51 | return $this->options['node_class']; 52 | } 53 | 54 | public function setArguments($arguments) 55 | { 56 | $this->arguments = $arguments; 57 | } 58 | 59 | public function getArguments() 60 | { 61 | return $this->arguments; 62 | } 63 | 64 | public function needsEnvironment() 65 | { 66 | return $this->options['needs_environment']; 67 | } 68 | 69 | public function needsContext() 70 | { 71 | return $this->options['needs_context']; 72 | } 73 | 74 | public function getSafe(Twig_Node $filterArgs) 75 | { 76 | if (null !== $this->options['is_safe']) { 77 | return $this->options['is_safe']; 78 | } 79 | 80 | if (null !== $this->options['is_safe_callback']) { 81 | return call_user_func($this->options['is_safe_callback'], $filterArgs); 82 | } 83 | } 84 | 85 | public function getPreservesSafety() 86 | { 87 | return $this->options['preserves_safety']; 88 | } 89 | 90 | public function getPreEscape() 91 | { 92 | return $this->options['pre_escape']; 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /inc/Twig/Twig/SimpleFunction.php: -------------------------------------------------------------------------------- 1 | 16 | */ 17 | class Twig_SimpleFunction 18 | { 19 | protected $name; 20 | protected $callable; 21 | protected $options; 22 | protected $arguments = array(); 23 | 24 | public function __construct($name, $callable, array $options = array()) 25 | { 26 | $this->name = $name; 27 | $this->callable = $callable; 28 | $this->options = array_merge(array( 29 | 'needs_environment' => false, 30 | 'needs_context' => false, 31 | 'is_safe' => null, 32 | 'is_safe_callback' => null, 33 | 'node_class' => 'Twig_Node_Expression_Function', 34 | ), $options); 35 | } 36 | 37 | public function getName() 38 | { 39 | return $this->name; 40 | } 41 | 42 | public function getCallable() 43 | { 44 | return $this->callable; 45 | } 46 | 47 | public function getNodeClass() 48 | { 49 | return $this->options['node_class']; 50 | } 51 | 52 | public function setArguments($arguments) 53 | { 54 | $this->arguments = $arguments; 55 | } 56 | 57 | public function getArguments() 58 | { 59 | return $this->arguments; 60 | } 61 | 62 | public function needsEnvironment() 63 | { 64 | return $this->options['needs_environment']; 65 | } 66 | 67 | public function needsContext() 68 | { 69 | return $this->options['needs_context']; 70 | } 71 | 72 | public function getSafe(Twig_Node $functionArgs) 73 | { 74 | if (null !== $this->options['is_safe']) { 75 | return $this->options['is_safe']; 76 | } 77 | 78 | if (null !== $this->options['is_safe_callback']) { 79 | return call_user_func($this->options['is_safe_callback'], $functionArgs); 80 | } 81 | 82 | return array(); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /inc/Twig/Twig/SimpleTest.php: -------------------------------------------------------------------------------- 1 | 16 | */ 17 | class Twig_SimpleTest 18 | { 19 | protected $name; 20 | protected $callable; 21 | protected $options; 22 | 23 | public function __construct($name, $callable, array $options = array()) 24 | { 25 | $this->name = $name; 26 | $this->callable = $callable; 27 | $this->options = array_merge(array( 28 | 'node_class' => 'Twig_Node_Expression_Test', 29 | ), $options); 30 | } 31 | 32 | public function getName() 33 | { 34 | return $this->name; 35 | } 36 | 37 | public function getCallable() 38 | { 39 | return $this->callable; 40 | } 41 | 42 | public function getNodeClass() 43 | { 44 | return $this->options['node_class']; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /inc/Twig/Twig/TemplateInterface.php: -------------------------------------------------------------------------------- 1 | 16 | * 17 | * @deprecated since 1.12 (to be removed in 3.0) 18 | */ 19 | interface Twig_TemplateInterface 20 | { 21 | const ANY_CALL = 'any'; 22 | const ARRAY_CALL = 'array'; 23 | const METHOD_CALL = 'method'; 24 | 25 | /** 26 | * Renders the template with the given context and returns it as string. 27 | * 28 | * @param array $context An array of parameters to pass to the template 29 | * 30 | * @return string The rendered template 31 | */ 32 | public function render(array $context); 33 | 34 | /** 35 | * Displays the template with the given context. 36 | * 37 | * @param array $context An array of parameters to pass to the template 38 | * @param array $blocks An array of blocks to pass to the template 39 | */ 40 | public function display(array $context, array $blocks = array()); 41 | 42 | /** 43 | * Returns the bound environment for this template. 44 | * 45 | * @return Twig_Environment The current environment 46 | */ 47 | public function getEnvironment(); 48 | } 49 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Test.php: -------------------------------------------------------------------------------- 1 | 16 | * @deprecated since 1.12 (to be removed in 2.0) 17 | */ 18 | abstract class Twig_Test implements Twig_TestInterface, Twig_TestCallableInterface 19 | { 20 | protected $options; 21 | protected $arguments = array(); 22 | 23 | public function __construct(array $options = array()) 24 | { 25 | $this->options = array_merge(array( 26 | 'callable' => null, 27 | ), $options); 28 | } 29 | 30 | public function getCallable() 31 | { 32 | return $this->options['callable']; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Test/Function.php: -------------------------------------------------------------------------------- 1 | 16 | * @deprecated since 1.12 (to be removed in 2.0) 17 | */ 18 | class Twig_Test_Function extends Twig_Test 19 | { 20 | protected $function; 21 | 22 | public function __construct($function, array $options = array()) 23 | { 24 | $options['callable'] = $function; 25 | 26 | parent::__construct($options); 27 | 28 | $this->function = $function; 29 | } 30 | 31 | public function compile() 32 | { 33 | return $this->function; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Test/Method.php: -------------------------------------------------------------------------------- 1 | 16 | * @deprecated since 1.12 (to be removed in 2.0) 17 | */ 18 | class Twig_Test_Method extends Twig_Test 19 | { 20 | protected $extension; 21 | protected $method; 22 | 23 | public function __construct(Twig_ExtensionInterface $extension, $method, array $options = array()) 24 | { 25 | $options['callable'] = array($extension, $method); 26 | 27 | parent::__construct($options); 28 | 29 | $this->extension = $extension; 30 | $this->method = $method; 31 | } 32 | 33 | public function compile() 34 | { 35 | return sprintf('$this->env->getExtension(\'%s\')->%s', $this->extension->getName(), $this->method); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Test/Node.php: -------------------------------------------------------------------------------- 1 | 16 | * @deprecated since 1.12 (to be removed in 2.0) 17 | */ 18 | class Twig_Test_Node extends Twig_Test 19 | { 20 | protected $class; 21 | 22 | public function __construct($class, array $options = array()) 23 | { 24 | parent::__construct($options); 25 | 26 | $this->class = $class; 27 | } 28 | 29 | public function getClass() 30 | { 31 | return $this->class; 32 | } 33 | 34 | public function compile() 35 | { 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /inc/Twig/Twig/Test/NodeTestCase.php: -------------------------------------------------------------------------------- 1 | assertNodeCompilation($source, $node, $environment); 21 | } 22 | 23 | public function assertNodeCompilation($source, Twig_Node $node, Twig_Environment $environment = null) 24 | { 25 | $compiler = $this->getCompiler($environment); 26 | $compiler->compile($node); 27 | 28 | $this->assertEquals($source, trim($compiler->getSource())); 29 | } 30 | 31 | protected function getCompiler(Twig_Environment $environment = null) 32 | { 33 | return new Twig_Compiler(null === $environment ? $this->getEnvironment() : $environment); 34 | } 35 | 36 | protected function getEnvironment() 37 | { 38 | return new Twig_Environment(); 39 | } 40 | 41 | protected function getVariableGetter($name) 42 | { 43 | if (version_compare(phpversion(), '5.4.0RC1', '>=')) { 44 | return sprintf('(isset($context["%s"]) ? $context["%s"] : null)', $name, $name); 45 | } 46 | 47 | return sprintf('$this->getContext($context, "%s")', $name); 48 | } 49 | 50 | protected function getAttributeGetter() 51 | { 52 | if (function_exists('twig_template_get_attributes')) { 53 | return 'twig_template_get_attributes($this, '; 54 | } 55 | 56 | return '$this->getAttribute('; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /inc/Twig/Twig/TestCallableInterface.php: -------------------------------------------------------------------------------- 1 | 16 | * @deprecated since 1.12 (to be removed in 2.0) 17 | */ 18 | interface Twig_TestCallableInterface 19 | { 20 | public function getCallable(); 21 | } 22 | -------------------------------------------------------------------------------- /inc/Twig/Twig/TestInterface.php: -------------------------------------------------------------------------------- 1 | 16 | * @deprecated since 1.12 (to be removed in 2.0) 17 | */ 18 | interface Twig_TestInterface 19 | { 20 | /** 21 | * Compiles a test. 22 | * 23 | * @return string The PHP code for the test 24 | */ 25 | public function compile(); 26 | } 27 | -------------------------------------------------------------------------------- /inc/Twig/Twig/TokenParser.php: -------------------------------------------------------------------------------- 1 | 16 | */ 17 | abstract class Twig_TokenParser implements Twig_TokenParserInterface 18 | { 19 | /** 20 | * @var Twig_Parser 21 | */ 22 | protected $parser; 23 | 24 | /** 25 | * Sets the parser associated with this token parser 26 | * 27 | * @param $parser A Twig_Parser instance 28 | */ 29 | public function setParser(Twig_Parser $parser) 30 | { 31 | $this->parser = $parser; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /inc/Twig/Twig/TokenParser/AutoEscape.php: -------------------------------------------------------------------------------- 1 | 16 | * {% autoescape true %} 17 | * Everything will be automatically escaped in this block 18 | * {% endautoescape %} 19 | * 20 | * {% autoescape false %} 21 | * Everything will be outputed as is in this block 22 | * {% endautoescape %} 23 | * 24 | * {% autoescape true js %} 25 | * Everything will be automatically escaped in this block 26 | * using the js escaping strategy 27 | * {% endautoescape %} 28 | * 29 | */ 30 | class Twig_TokenParser_AutoEscape extends Twig_TokenParser 31 | { 32 | /** 33 | * Parses a token and returns a node. 34 | * 35 | * @param Twig_Token $token A Twig_Token instance 36 | * 37 | * @return Twig_NodeInterface A Twig_NodeInterface instance 38 | */ 39 | public function parse(Twig_Token $token) 40 | { 41 | $lineno = $token->getLine(); 42 | $stream = $this->parser->getStream(); 43 | 44 | if ($stream->test(Twig_Token::BLOCK_END_TYPE)) { 45 | $value = 'html'; 46 | } else { 47 | $expr = $this->parser->getExpressionParser()->parseExpression(); 48 | if (!$expr instanceof Twig_Node_Expression_Constant) { 49 | throw new Twig_Error_Syntax('An escaping strategy must be a string or a Boolean.', $stream->getCurrent()->getLine(), $stream->getFilename()); 50 | } 51 | $value = $expr->getAttribute('value'); 52 | 53 | $compat = true === $value || false === $value; 54 | 55 | if (true === $value) { 56 | $value = 'html'; 57 | } 58 | 59 | if ($compat && $stream->test(Twig_Token::NAME_TYPE)) { 60 | if (false === $value) { 61 | throw new Twig_Error_Syntax('Unexpected escaping strategy as you set autoescaping to false.', $stream->getCurrent()->getLine(), $stream->getFilename()); 62 | } 63 | 64 | $value = $stream->next()->getValue(); 65 | } 66 | } 67 | 68 | $stream->expect(Twig_Token::BLOCK_END_TYPE); 69 | $body = $this->parser->subparse(array($this, 'decideBlockEnd'), true); 70 | $stream->expect(Twig_Token::BLOCK_END_TYPE); 71 | 72 | return new Twig_Node_AutoEscape($value, $body, $lineno, $this->getTag()); 73 | } 74 | 75 | public function decideBlockEnd(Twig_Token $token) 76 | { 77 | return $token->test('endautoescape'); 78 | } 79 | 80 | /** 81 | * Gets the tag name associated with this token parser. 82 | * 83 | * @return string The tag name 84 | */ 85 | public function getTag() 86 | { 87 | return 'autoescape'; 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /inc/Twig/Twig/TokenParser/Block.php: -------------------------------------------------------------------------------- 1 | 17 | * {% block head %} 18 | * 19 | * {% block title %}{% endblock %} - My Webpage 20 | * {% endblock %} 21 | * 22 | */ 23 | class Twig_TokenParser_Block extends Twig_TokenParser 24 | { 25 | /** 26 | * Parses a token and returns a node. 27 | * 28 | * @param Twig_Token $token A Twig_Token instance 29 | * 30 | * @return Twig_NodeInterface A Twig_NodeInterface instance 31 | */ 32 | public function parse(Twig_Token $token) 33 | { 34 | $lineno = $token->getLine(); 35 | $stream = $this->parser->getStream(); 36 | $name = $stream->expect(Twig_Token::NAME_TYPE)->getValue(); 37 | if ($this->parser->hasBlock($name)) { 38 | throw new Twig_Error_Syntax(sprintf("The block '$name' has already been defined line %d", $this->parser->getBlock($name)->getLine()), $stream->getCurrent()->getLine(), $stream->getFilename()); 39 | } 40 | $this->parser->setBlock($name, $block = new Twig_Node_Block($name, new Twig_Node(array()), $lineno)); 41 | $this->parser->pushLocalScope(); 42 | $this->parser->pushBlockStack($name); 43 | 44 | if ($stream->nextIf(Twig_Token::BLOCK_END_TYPE)) { 45 | $body = $this->parser->subparse(array($this, 'decideBlockEnd'), true); 46 | if ($token = $stream->nextIf(Twig_Token::NAME_TYPE)) { 47 | $value = $token->getValue(); 48 | 49 | if ($value != $name) { 50 | throw new Twig_Error_Syntax(sprintf("Expected endblock for block '$name' (but %s given)", $value), $stream->getCurrent()->getLine(), $stream->getFilename()); 51 | } 52 | } 53 | } else { 54 | $body = new Twig_Node(array( 55 | new Twig_Node_Print($this->parser->getExpressionParser()->parseExpression(), $lineno), 56 | )); 57 | } 58 | $stream->expect(Twig_Token::BLOCK_END_TYPE); 59 | 60 | $block->setNode('body', $body); 61 | $this->parser->popBlockStack(); 62 | $this->parser->popLocalScope(); 63 | 64 | return new Twig_Node_BlockReference($name, $lineno, $this->getTag()); 65 | } 66 | 67 | public function decideBlockEnd(Twig_Token $token) 68 | { 69 | return $token->test('endblock'); 70 | } 71 | 72 | /** 73 | * Gets the tag name associated with this token parser. 74 | * 75 | * @return string The tag name 76 | */ 77 | public function getTag() 78 | { 79 | return 'block'; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /inc/Twig/Twig/TokenParser/Do.php: -------------------------------------------------------------------------------- 1 | parser->getExpressionParser()->parseExpression(); 27 | 28 | $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); 29 | 30 | return new Twig_Node_Do($expr, $token->getLine(), $this->getTag()); 31 | } 32 | 33 | /** 34 | * Gets the tag name associated with this token parser. 35 | * 36 | * @return string The tag name 37 | */ 38 | public function getTag() 39 | { 40 | return 'do'; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /inc/Twig/Twig/TokenParser/Embed.php: -------------------------------------------------------------------------------- 1 | parser->getStream(); 27 | 28 | $parent = $this->parser->getExpressionParser()->parseExpression(); 29 | 30 | list($variables, $only, $ignoreMissing) = $this->parseArguments(); 31 | 32 | // inject a fake parent to make the parent() function work 33 | $stream->injectTokens(array( 34 | new Twig_Token(Twig_Token::BLOCK_START_TYPE, '', $token->getLine()), 35 | new Twig_Token(Twig_Token::NAME_TYPE, 'extends', $token->getLine()), 36 | new Twig_Token(Twig_Token::STRING_TYPE, '__parent__', $token->getLine()), 37 | new Twig_Token(Twig_Token::BLOCK_END_TYPE, '', $token->getLine()), 38 | )); 39 | 40 | $module = $this->parser->parse($stream, array($this, 'decideBlockEnd'), true); 41 | 42 | // override the parent with the correct one 43 | $module->setNode('parent', $parent); 44 | 45 | $this->parser->embedTemplate($module); 46 | 47 | $stream->expect(Twig_Token::BLOCK_END_TYPE); 48 | 49 | return new Twig_Node_Embed($module->getAttribute('filename'), $module->getAttribute('index'), $variables, $only, $ignoreMissing, $token->getLine(), $this->getTag()); 50 | } 51 | 52 | public function decideBlockEnd(Twig_Token $token) 53 | { 54 | return $token->test('endembed'); 55 | } 56 | 57 | /** 58 | * Gets the tag name associated with this token parser. 59 | * 60 | * @return string The tag name 61 | */ 62 | public function getTag() 63 | { 64 | return 'embed'; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /inc/Twig/Twig/TokenParser/Extends.php: -------------------------------------------------------------------------------- 1 | 17 | * {% extends "base.html" %} 18 | * 19 | */ 20 | class Twig_TokenParser_Extends extends Twig_TokenParser 21 | { 22 | /** 23 | * Parses a token and returns a node. 24 | * 25 | * @param Twig_Token $token A Twig_Token instance 26 | * 27 | * @return Twig_NodeInterface A Twig_NodeInterface instance 28 | */ 29 | public function parse(Twig_Token $token) 30 | { 31 | if (!$this->parser->isMainScope()) { 32 | throw new Twig_Error_Syntax('Cannot extend from a block', $token->getLine(), $this->parser->getFilename()); 33 | } 34 | 35 | if (null !== $this->parser->getParent()) { 36 | throw new Twig_Error_Syntax('Multiple extends tags are forbidden', $token->getLine(), $this->parser->getFilename()); 37 | } 38 | $this->parser->setParent($this->parser->getExpressionParser()->parseExpression()); 39 | 40 | $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); 41 | } 42 | 43 | /** 44 | * Gets the tag name associated with this token parser. 45 | * 46 | * @return string The tag name 47 | */ 48 | public function getTag() 49 | { 50 | return 'extends'; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /inc/Twig/Twig/TokenParser/Filter.php: -------------------------------------------------------------------------------- 1 | 16 | * {% filter upper %} 17 | * This text becomes uppercase 18 | * {% endfilter %} 19 | * 20 | */ 21 | class Twig_TokenParser_Filter extends Twig_TokenParser 22 | { 23 | /** 24 | * Parses a token and returns a node. 25 | * 26 | * @param Twig_Token $token A Twig_Token instance 27 | * 28 | * @return Twig_NodeInterface A Twig_NodeInterface instance 29 | */ 30 | public function parse(Twig_Token $token) 31 | { 32 | $name = $this->parser->getVarName(); 33 | $ref = new Twig_Node_Expression_BlockReference(new Twig_Node_Expression_Constant($name, $token->getLine()), true, $token->getLine(), $this->getTag()); 34 | 35 | $filter = $this->parser->getExpressionParser()->parseFilterExpressionRaw($ref, $this->getTag()); 36 | $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); 37 | 38 | $body = $this->parser->subparse(array($this, 'decideBlockEnd'), true); 39 | $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); 40 | 41 | $block = new Twig_Node_Block($name, $body, $token->getLine()); 42 | $this->parser->setBlock($name, $block); 43 | 44 | return new Twig_Node_Print($filter, $token->getLine(), $this->getTag()); 45 | } 46 | 47 | public function decideBlockEnd(Twig_Token $token) 48 | { 49 | return $token->test('endfilter'); 50 | } 51 | 52 | /** 53 | * Gets the tag name associated with this token parser. 54 | * 55 | * @return string The tag name 56 | */ 57 | public function getTag() 58 | { 59 | return 'filter'; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /inc/Twig/Twig/TokenParser/Flush.php: -------------------------------------------------------------------------------- 1 | parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); 29 | 30 | return new Twig_Node_Flush($token->getLine(), $this->getTag()); 31 | } 32 | 33 | /** 34 | * Gets the tag name associated with this token parser. 35 | * 36 | * @return string The tag name 37 | */ 38 | public function getTag() 39 | { 40 | return 'flush'; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /inc/Twig/Twig/TokenParser/From.php: -------------------------------------------------------------------------------- 1 | 16 | * {% from 'forms.html' import forms %} 17 | * 18 | */ 19 | class Twig_TokenParser_From extends Twig_TokenParser 20 | { 21 | /** 22 | * Parses a token and returns a node. 23 | * 24 | * @param Twig_Token $token A Twig_Token instance 25 | * 26 | * @return Twig_NodeInterface A Twig_NodeInterface instance 27 | */ 28 | public function parse(Twig_Token $token) 29 | { 30 | $macro = $this->parser->getExpressionParser()->parseExpression(); 31 | $stream = $this->parser->getStream(); 32 | $stream->expect('import'); 33 | 34 | $targets = array(); 35 | do { 36 | $name = $stream->expect(Twig_Token::NAME_TYPE)->getValue(); 37 | 38 | $alias = $name; 39 | if ($stream->nextIf('as')) { 40 | $alias = $stream->expect(Twig_Token::NAME_TYPE)->getValue(); 41 | } 42 | 43 | $targets[$name] = $alias; 44 | 45 | if (!$stream->nextIf(Twig_Token::PUNCTUATION_TYPE, ',')) { 46 | break; 47 | } 48 | } while (true); 49 | 50 | $stream->expect(Twig_Token::BLOCK_END_TYPE); 51 | 52 | $node = new Twig_Node_Import($macro, new Twig_Node_Expression_AssignName($this->parser->getVarName(), $token->getLine()), $token->getLine(), $this->getTag()); 53 | 54 | foreach ($targets as $name => $alias) { 55 | $this->parser->addImportedSymbol('function', $alias, 'get'.$name, $node->getNode('var')); 56 | } 57 | 58 | return $node; 59 | } 60 | 61 | /** 62 | * Gets the tag name associated with this token parser. 63 | * 64 | * @return string The tag name 65 | */ 66 | public function getTag() 67 | { 68 | return 'from'; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /inc/Twig/Twig/TokenParser/Import.php: -------------------------------------------------------------------------------- 1 | 16 | * {% import 'forms.html' as forms %} 17 | * 18 | */ 19 | class Twig_TokenParser_Import extends Twig_TokenParser 20 | { 21 | /** 22 | * Parses a token and returns a node. 23 | * 24 | * @param Twig_Token $token A Twig_Token instance 25 | * 26 | * @return Twig_NodeInterface A Twig_NodeInterface instance 27 | */ 28 | public function parse(Twig_Token $token) 29 | { 30 | $macro = $this->parser->getExpressionParser()->parseExpression(); 31 | $this->parser->getStream()->expect('as'); 32 | $var = new Twig_Node_Expression_AssignName($this->parser->getStream()->expect(Twig_Token::NAME_TYPE)->getValue(), $token->getLine()); 33 | $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); 34 | 35 | $this->parser->addImportedSymbol('template', $var->getAttribute('name')); 36 | 37 | return new Twig_Node_Import($macro, $var, $token->getLine(), $this->getTag()); 38 | } 39 | 40 | /** 41 | * Gets the tag name associated with this token parser. 42 | * 43 | * @return string The tag name 44 | */ 45 | public function getTag() 46 | { 47 | return 'import'; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /inc/Twig/Twig/TokenParser/Include.php: -------------------------------------------------------------------------------- 1 | 17 | * {% include 'header.html' %} 18 | * Body 19 | * {% include 'footer.html' %} 20 | * 21 | */ 22 | class Twig_TokenParser_Include extends Twig_TokenParser 23 | { 24 | /** 25 | * Parses a token and returns a node. 26 | * 27 | * @param Twig_Token $token A Twig_Token instance 28 | * 29 | * @return Twig_NodeInterface A Twig_NodeInterface instance 30 | */ 31 | public function parse(Twig_Token $token) 32 | { 33 | $expr = $this->parser->getExpressionParser()->parseExpression(); 34 | 35 | list($variables, $only, $ignoreMissing) = $this->parseArguments(); 36 | 37 | return new Twig_Node_Include($expr, $variables, $only, $ignoreMissing, $token->getLine(), $this->getTag()); 38 | } 39 | 40 | protected function parseArguments() 41 | { 42 | $stream = $this->parser->getStream(); 43 | 44 | $ignoreMissing = false; 45 | if ($stream->nextIf(Twig_Token::NAME_TYPE, 'ignore')) { 46 | $stream->expect(Twig_Token::NAME_TYPE, 'missing'); 47 | 48 | $ignoreMissing = true; 49 | } 50 | 51 | $variables = null; 52 | if ($stream->nextIf(Twig_Token::NAME_TYPE, 'with')) { 53 | $variables = $this->parser->getExpressionParser()->parseExpression(); 54 | } 55 | 56 | $only = false; 57 | if ($stream->nextIf(Twig_Token::NAME_TYPE, 'only')) { 58 | $only = true; 59 | } 60 | 61 | $stream->expect(Twig_Token::BLOCK_END_TYPE); 62 | 63 | return array($variables, $only, $ignoreMissing); 64 | } 65 | 66 | /** 67 | * Gets the tag name associated with this token parser. 68 | * 69 | * @return string The tag name 70 | */ 71 | public function getTag() 72 | { 73 | return 'include'; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /inc/Twig/Twig/TokenParser/Macro.php: -------------------------------------------------------------------------------- 1 | 16 | * {% macro input(name, value, type, size) %} 17 | * 18 | * {% endmacro %} 19 | * 20 | */ 21 | class Twig_TokenParser_Macro extends Twig_TokenParser 22 | { 23 | /** 24 | * Parses a token and returns a node. 25 | * 26 | * @param Twig_Token $token A Twig_Token instance 27 | * 28 | * @return Twig_NodeInterface A Twig_NodeInterface instance 29 | */ 30 | public function parse(Twig_Token $token) 31 | { 32 | $lineno = $token->getLine(); 33 | $stream = $this->parser->getStream(); 34 | $name = $stream->expect(Twig_Token::NAME_TYPE)->getValue(); 35 | 36 | $arguments = $this->parser->getExpressionParser()->parseArguments(true, true); 37 | 38 | $stream->expect(Twig_Token::BLOCK_END_TYPE); 39 | $this->parser->pushLocalScope(); 40 | $body = $this->parser->subparse(array($this, 'decideBlockEnd'), true); 41 | if ($token = $stream->nextIf(Twig_Token::NAME_TYPE)) { 42 | $value = $token->getValue(); 43 | 44 | if ($value != $name) { 45 | throw new Twig_Error_Syntax(sprintf("Expected endmacro for macro '$name' (but %s given)", $value), $stream->getCurrent()->getLine(), $stream->getFilename()); 46 | } 47 | } 48 | $this->parser->popLocalScope(); 49 | $stream->expect(Twig_Token::BLOCK_END_TYPE); 50 | 51 | $this->parser->setMacro($name, new Twig_Node_Macro($name, new Twig_Node_Body(array($body)), $arguments, $lineno, $this->getTag())); 52 | } 53 | 54 | public function decideBlockEnd(Twig_Token $token) 55 | { 56 | return $token->test('endmacro'); 57 | } 58 | 59 | /** 60 | * Gets the tag name associated with this token parser. 61 | * 62 | * @return string The tag name 63 | */ 64 | public function getTag() 65 | { 66 | return 'macro'; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /inc/Twig/Twig/TokenParser/Sandbox.php: -------------------------------------------------------------------------------- 1 | 16 | * {% sandbox %} 17 | * {% include 'user.html' %} 18 | * {% endsandbox %} 19 | * 20 | * 21 | * @see http://www.twig-project.org/doc/api.html#sandbox-extension for details 22 | */ 23 | class Twig_TokenParser_Sandbox extends Twig_TokenParser 24 | { 25 | /** 26 | * Parses a token and returns a node. 27 | * 28 | * @param Twig_Token $token A Twig_Token instance 29 | * 30 | * @return Twig_NodeInterface A Twig_NodeInterface instance 31 | */ 32 | public function parse(Twig_Token $token) 33 | { 34 | $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); 35 | $body = $this->parser->subparse(array($this, 'decideBlockEnd'), true); 36 | $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); 37 | 38 | // in a sandbox tag, only include tags are allowed 39 | if (!$body instanceof Twig_Node_Include) { 40 | foreach ($body as $node) { 41 | if ($node instanceof Twig_Node_Text && ctype_space($node->getAttribute('data'))) { 42 | continue; 43 | } 44 | 45 | if (!$node instanceof Twig_Node_Include) { 46 | throw new Twig_Error_Syntax('Only "include" tags are allowed within a "sandbox" section', $node->getLine(), $this->parser->getFilename()); 47 | } 48 | } 49 | } 50 | 51 | return new Twig_Node_Sandbox($body, $token->getLine(), $this->getTag()); 52 | } 53 | 54 | public function decideBlockEnd(Twig_Token $token) 55 | { 56 | return $token->test('endsandbox'); 57 | } 58 | 59 | /** 60 | * Gets the tag name associated with this token parser. 61 | * 62 | * @return string The tag name 63 | */ 64 | public function getTag() 65 | { 66 | return 'sandbox'; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /inc/Twig/Twig/TokenParser/Set.php: -------------------------------------------------------------------------------- 1 | 16 | * {% set foo = 'foo' %} 17 | * 18 | * {% set foo = [1, 2] %} 19 | * 20 | * {% set foo = {'foo': 'bar'} %} 21 | * 22 | * {% set foo = 'foo' ~ 'bar' %} 23 | * 24 | * {% set foo, bar = 'foo', 'bar' %} 25 | * 26 | * {% set foo %}Some content{% endset %} 27 | * 28 | */ 29 | class Twig_TokenParser_Set extends Twig_TokenParser 30 | { 31 | /** 32 | * Parses a token and returns a node. 33 | * 34 | * @param Twig_Token $token A Twig_Token instance 35 | * 36 | * @return Twig_NodeInterface A Twig_NodeInterface instance 37 | */ 38 | public function parse(Twig_Token $token) 39 | { 40 | $lineno = $token->getLine(); 41 | $stream = $this->parser->getStream(); 42 | $names = $this->parser->getExpressionParser()->parseAssignmentExpression(); 43 | 44 | $capture = false; 45 | if ($stream->nextIf(Twig_Token::OPERATOR_TYPE, '=')) { 46 | $values = $this->parser->getExpressionParser()->parseMultitargetExpression(); 47 | 48 | $stream->expect(Twig_Token::BLOCK_END_TYPE); 49 | 50 | if (count($names) !== count($values)) { 51 | throw new Twig_Error_Syntax("When using set, you must have the same number of variables and assignments.", $stream->getCurrent()->getLine(), $stream->getFilename()); 52 | } 53 | } else { 54 | $capture = true; 55 | 56 | if (count($names) > 1) { 57 | throw new Twig_Error_Syntax("When using set with a block, you cannot have a multi-target.", $stream->getCurrent()->getLine(), $stream->getFilename()); 58 | } 59 | 60 | $stream->expect(Twig_Token::BLOCK_END_TYPE); 61 | 62 | $values = $this->parser->subparse(array($this, 'decideBlockEnd'), true); 63 | $stream->expect(Twig_Token::BLOCK_END_TYPE); 64 | } 65 | 66 | return new Twig_Node_Set($capture, $names, $values, $lineno, $this->getTag()); 67 | } 68 | 69 | public function decideBlockEnd(Twig_Token $token) 70 | { 71 | return $token->test('endset'); 72 | } 73 | 74 | /** 75 | * Gets the tag name associated with this token parser. 76 | * 77 | * @return string The tag name 78 | */ 79 | public function getTag() 80 | { 81 | return 'set'; 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /inc/Twig/Twig/TokenParser/Spaceless.php: -------------------------------------------------------------------------------- 1 | 16 | * {% spaceless %} 17 | *
18 | * foo 19 | *
20 | * {% endspaceless %} 21 | * 22 | * {# output will be
foo
#} 23 | * 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 | } 60 | -------------------------------------------------------------------------------- /inc/Twig/Twig/TokenParser/Use.php: -------------------------------------------------------------------------------- 1 | 16 | * {% extends "base.html" %} 17 | * 18 | * {% use "blocks.html" %} 19 | * 20 | * {% block title %}{% endblock %} 21 | * {% block content %}{% endblock %} 22 | * 23 | * 24 | * @see http://www.twig-project.org/doc/templates.html#horizontal-reuse for details. 25 | */ 26 | class Twig_TokenParser_Use extends Twig_TokenParser 27 | { 28 | /** 29 | * Parses a token and returns a node. 30 | * 31 | * @param Twig_Token $token A Twig_Token instance 32 | * 33 | * @return Twig_NodeInterface A Twig_NodeInterface instance 34 | */ 35 | public function parse(Twig_Token $token) 36 | { 37 | $template = $this->parser->getExpressionParser()->parseExpression(); 38 | $stream = $this->parser->getStream(); 39 | 40 | if (!$template instanceof Twig_Node_Expression_Constant) { 41 | throw new Twig_Error_Syntax('The template references in a "use" statement must be a string.', $stream->getCurrent()->getLine(), $stream->getFilename()); 42 | } 43 | 44 | $targets = array(); 45 | if ($stream->nextIf('with')) { 46 | do { 47 | $name = $stream->expect(Twig_Token::NAME_TYPE)->getValue(); 48 | 49 | $alias = $name; 50 | if ($stream->nextIf('as')) { 51 | $alias = $stream->expect(Twig_Token::NAME_TYPE)->getValue(); 52 | } 53 | 54 | $targets[$name] = new Twig_Node_Expression_Constant($alias, -1); 55 | 56 | if (!$stream->nextIf(Twig_Token::PUNCTUATION_TYPE, ',')) { 57 | break; 58 | } 59 | } while (true); 60 | } 61 | 62 | $stream->expect(Twig_Token::BLOCK_END_TYPE); 63 | 64 | $this->parser->addTrait(new Twig_Node(array('template' => $template, 'targets' => new Twig_Node($targets)))); 65 | } 66 | 67 | /** 68 | * Gets the tag name associated with this token parser. 69 | * 70 | * @return string The tag name 71 | */ 72 | public function getTag() 73 | { 74 | return 'use'; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /inc/Twig/Twig/TokenParserBrokerInterface.php: -------------------------------------------------------------------------------- 1 | 19 | * @deprecated since 1.12 (to be removed in 2.0) 20 | */ 21 | interface Twig_TokenParserBrokerInterface 22 | { 23 | /** 24 | * Gets a TokenParser suitable for a tag. 25 | * 26 | * @param string $tag A tag name 27 | * 28 | * @return null|Twig_TokenParserInterface A Twig_TokenParserInterface or null if no suitable TokenParser was found 29 | */ 30 | public function getTokenParser($tag); 31 | 32 | /** 33 | * Calls Twig_TokenParserInterface::setParser on all parsers the implementation knows of. 34 | * 35 | * @param Twig_ParserInterface $parser A Twig_ParserInterface interface 36 | */ 37 | public function setParser(Twig_ParserInterface $parser); 38 | 39 | /** 40 | * Gets the Twig_ParserInterface. 41 | * 42 | * @return null|Twig_ParserInterface A Twig_ParserInterface instance or null 43 | */ 44 | public function getParser(); 45 | } 46 | -------------------------------------------------------------------------------- /inc/Twig/Twig/TokenParserInterface.php: -------------------------------------------------------------------------------- 1 | 16 | */ 17 | interface Twig_TokenParserInterface 18 | { 19 | /** 20 | * Sets the parser associated with this token parser 21 | * 22 | * @param $parser A Twig_Parser instance 23 | */ 24 | public function setParser(Twig_Parser $parser); 25 | 26 | /** 27 | * Parses a token and returns a node. 28 | * 29 | * @param Twig_Token $token A Twig_Token instance 30 | * 31 | * @return Twig_NodeInterface A Twig_NodeInterface instance 32 | * 33 | * @throws Twig_Error_Syntax 34 | */ 35 | public function parse(Twig_Token $token); 36 | 37 | /** 38 | * Gets the tag name associated with this token parser. 39 | * 40 | * @return string The tag name 41 | */ 42 | public function getTag(); 43 | } 44 | -------------------------------------------------------------------------------- /inc/Twig/class-twig-proxy.php: -------------------------------------------------------------------------------- 1 | 10 |
    > 11 | '; 17 | } 18 | 19 | function start_el(&$output, $comment, $depth = 0, $args = array(), $id = 0) { 20 | $depth++; 21 | $GLOBALS['comment_depth'] = $depth; 22 | $GLOBALS['comment'] = $comment; 23 | 24 | if (!empty($args['callback'])) { 25 | call_user_func($args['callback'], $comment, $args, $depth); 26 | return; 27 | } 28 | 29 | extract($args, EXTR_SKIP); ?> 30 | 31 |
  • > 32 |
    33 | 34 |
    35 |
    36 |

    37 | 38 | at 39 | 40 |

    41 | 42 | 43 | 44 | comment_approved == '0') : ?> 45 |
    46 | 47 |
    48 | 49 | 50 | 51 | $depth, 'max_depth' => $args['max_depth']))); ?> 52 | 53 | located in templates/comment.php, and then the comment's
  • 62 | echo "
  • \n"; 63 | } 64 | } 65 | 66 | function sprig_get_avatar($avatar, $type) { 67 | if (!is_object($type)) { return $avatar; } 68 | 69 | $avatar = str_replace("class='avatar", "class='avatar pull-left media-object", $avatar); 70 | return $avatar; 71 | } 72 | add_filter('get_avatar', 'sprig_get_avatar', 10, 2); 73 | -------------------------------------------------------------------------------- /inc/config.php: -------------------------------------------------------------------------------- 1 | ' . __('Continued', 'sprig') . ''; 8 | } 9 | add_filter('excerpt_more', 'sprig_excerpt_more'); 10 | 11 | /** 12 | * Manage output of wp_title() 13 | */ 14 | function sprig_wp_title($title) { 15 | if (is_feed()) { 16 | return $title; 17 | } 18 | 19 | $title .= get_bloginfo('name'); 20 | 21 | return $title; 22 | } 23 | add_filter('wp_title', 'sprig_wp_title', 10); 24 | 25 | 26 | -------------------------------------------------------------------------------- /inc/init.php: -------------------------------------------------------------------------------- 1 | __('Primary Navigation', 'sprig') 11 | )); 12 | 13 | // Add post thumbnails 14 | // http://codex.wordpress.org/Post_Thumbnails 15 | // http://codex.wordpress.org/Function_Reference/set_post_thumbnail_size 16 | // http://codex.wordpress.org/Function_Reference/add_image_size 17 | add_theme_support('post-thumbnails'); 18 | 19 | // Add HTML5 markup for captions 20 | // http://codex.wordpress.org/Function_Reference/add_theme_support#HTML5 21 | add_theme_support('html5', array('caption')); 22 | } 23 | add_action('after_setup_theme', 'sprig_setup'); 24 | 25 | /** 26 | * Register sidebars 27 | */ 28 | function sprig_widgets_init() { 29 | register_sidebar(array( 30 | 'name' => __('Primary', 'sprig'), 31 | 'id' => 'sidebar-primary', 32 | 'before_widget' => '
    ', 33 | 'after_widget' => '
    ', 34 | 'before_title' => '

    ', 35 | 'after_title' => '

    ', 36 | )); 37 | } 38 | add_action('widgets_init', 'sprig_widgets_init'); 39 | -------------------------------------------------------------------------------- /inc/scripts.php: -------------------------------------------------------------------------------- 1 | '/dist/css/vendor.css', 12 | 'css' => '/dist/css/main.css', 13 | 'vendor-js' => '/dist/js/vendor.js', 14 | 'js' => '/dist/js/main.js' 15 | ); 16 | 17 | wp_enqueue_style('sprig_vendor_css', get_template_directory_uri() . $assets['vendor-css'], false, null); 18 | wp_enqueue_style('sprig_css', get_template_directory_uri() . $assets['css'], false, null); 19 | wp_enqueue_script('sprig_vendor_js', get_template_directory_uri() . $assets['vendor-js'], array(), null, true); 20 | wp_enqueue_script('sprig_js', get_template_directory_uri() . $assets['js'], array(), null, true); 21 | 22 | if (is_single() && comments_open() && get_option('thread_comments')) { 23 | wp_enqueue_script('comment-reply'); 24 | } 25 | 26 | } 27 | add_action('wp_enqueue_scripts', 'sprig_scripts', 100); -------------------------------------------------------------------------------- /inc/titles.php: -------------------------------------------------------------------------------- 1 | ' . get_the_author() . '' ); 14 | } elseif ( is_year() ) { 15 | $title = sprintf( __( 'Year: %s', '_s' ), get_the_date( _x( 'Y', 'yearly archives date format', '_s' ) ) ); 16 | } elseif ( is_month() ) { 17 | $title = sprintf( __( 'Month: %s', '_s' ), get_the_date( _x( 'F Y', 'monthly archives date format', '_s' ) ) ); 18 | } elseif ( is_day() ) { 19 | $title = sprintf( __( 'Day: %s', '_s' ), get_the_date( _x( 'F j, Y', 'daily archives date format', '_s' ) ) ); 20 | } elseif ( is_tax( 'post_format', 'post-format-aside' ) ) { 21 | $title = _x( 'Asides', 'post format archive title', '_s' ); 22 | } elseif ( is_tax( 'post_format', 'post-format-gallery' ) ) { 23 | $title = _x( 'Galleries', 'post format archive title', '_s' ); 24 | } elseif ( is_tax( 'post_format', 'post-format-image' ) ) { 25 | $title = _x( 'Images', 'post format archive title', '_s' ); 26 | } elseif ( is_tax( 'post_format', 'post-format-video' ) ) { 27 | $title = _x( 'Videos', 'post format archive title', '_s' ); 28 | } elseif ( is_tax( 'post_format', 'post-format-quote' ) ) { 29 | $title = _x( 'Quotes', 'post format archive title', '_s' ); 30 | } elseif ( is_tax( 'post_format', 'post-format-link' ) ) { 31 | $title = _x( 'Links', 'post format archive title', '_s' ); 32 | } elseif ( is_tax( 'post_format', 'post-format-status' ) ) { 33 | $title = _x( 'Statuses', 'post format archive title', '_s' ); 34 | } elseif ( is_tax( 'post_format', 'post-format-audio' ) ) { 35 | $title = _x( 'Audio', 'post format archive title', '_s' ); 36 | } elseif ( is_tax( 'post_format', 'post-format-chat' ) ) { 37 | $title = _x( 'Chats', 'post format archive title', '_s' ); 38 | } elseif ( is_post_type_archive() ) { 39 | $title = sprintf( __( 'Archives: %s', '_s' ), post_type_archive_title( '', false ) ); 40 | } elseif ( is_tax() ) { 41 | $tax = get_taxonomy( get_queried_object()->taxonomy ); 42 | /* translators: 1: Taxonomy singular name, 2: Current taxonomy term */ 43 | $title = sprintf( __( '%1$s: %2$s', '_s' ), $tax->labels->singular_name, single_term_title( '', false ) ); 44 | } else { 45 | $title = __( 'Archives', '_s' ); 46 | } 47 | /** 48 | * Filter the archive title. 49 | * 50 | * @param string $title Archive title to be displayed. 51 | */ 52 | $title = apply_filters( 'get_the_archive_title', $title ); 53 | if ( ! empty( $title ) ) { 54 | echo $before . $title . $after; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /inc/utils.php: -------------------------------------------------------------------------------- 1 | ", 4 | "homepage": "http://zach-adams.com", 5 | "version": "1.0.0", 6 | "licenses": [ 7 | { 8 | "type": "MIT", 9 | "url": "http://opensource.org/licenses/MIT" 10 | } 11 | ], 12 | "engines": { 13 | "node": ">= 0.10.0" 14 | }, 15 | "devDependencies": { 16 | "gulp": "~3.8.8", 17 | "gulp-ruby-sass": "~0.7.1", 18 | "gulp-autoprefixer": "~1.0.1", 19 | "gulp-cssmin": "~0.1.6", 20 | "gulp-rename": "~1.2.0", 21 | "gulp-livereload": "~2.1.1", 22 | "gulp-concat": "~2.4.1", 23 | "gulp-uglify": "~1.0.1", 24 | "gulp-imagemin": "~1.0.1", 25 | "imagemin-pngcrush": "~1.0.0", 26 | "gulp-plumber": "~0.6.6", 27 | "main-bower-files": "~2.1.0", 28 | "gulp-filter": "~1.0.2", 29 | "gulp-clean": "~0.3.1" 30 | } 31 | } -------------------------------------------------------------------------------- /page.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /single.php: -------------------------------------------------------------------------------- 1 | ul, 11 | li > ol { 12 | margin-bottom: 0; 13 | margin-left: 1.5em; 14 | } 15 | dt { 16 | font-weight: bold; 17 | } 18 | dd { 19 | margin: 0 1.5em 1.5em; 20 | } -------------------------------------------------------------------------------- /src/scss/components/_tables.scss: -------------------------------------------------------------------------------- 1 | table { 2 | margin: 0 0 1.5em; 3 | width: 100%; 4 | } 5 | th { 6 | font-weight: bold; 7 | } -------------------------------------------------------------------------------- /src/scss/helpers/_helpers.scss: -------------------------------------------------------------------------------- 1 | @import "mixins"; 2 | @import "variables"; -------------------------------------------------------------------------------- /src/scss/helpers/_mixins.scss: -------------------------------------------------------------------------------- 1 | // Rem output with px fallback 2 | @mixin font-size($sizeValue: 1.6) { 3 | font-size: ($sizeValue * 10) + px; 4 | font-size: $sizeValue + rem; 5 | } 6 | 7 | // Box model 8 | @mixin box-sizing($box-model) { 9 | -webkit-box-sizing: $box-model; // Safari <= 7 10 | -moz-box-sizing: $box-model; // Firefox <= 19 11 | box-sizing: $box-model; 12 | } 13 | 14 | // Border radius 15 | @mixin border-radius($radius) { 16 | background-clip: padding-box; /* stops bg color from leaking outside the border: */ 17 | -webkit-border-radius: $radius; 18 | border-radius: $radius; 19 | } 20 | 21 | // Center block 22 | @mixin center-block { 23 | display: block; 24 | margin: 0 auto; 25 | } 26 | 27 | // Clearfix 28 | @mixin clearfix() { 29 | content: ""; 30 | display: table; 31 | } 32 | 33 | // Clear after (not all clearfix need this also) 34 | @mixin clearfix-after() { 35 | clear: both; 36 | } 37 | 38 | //Vertical Align anything 39 | @mixin vertical-align($position) { 40 | position: $position; 41 | top: 50%; 42 | transform: translateY(-50%); 43 | } 44 | 45 | @mixin vertical-align-table() { 46 | display: table-cell; 47 | vertical-align: middle; 48 | } -------------------------------------------------------------------------------- /src/scss/helpers/_variables.scss: -------------------------------------------------------------------------------- 1 | $font_site-default: "Courier 10 Pitch", Courier, monospace; 2 | 3 | $color_site-default:#000; 4 | $color_white: #fff; 5 | 6 | $size_site-main: 100%; 7 | $size_site-sidebar: 25%; 8 | 9 | $assetPath : ".."; -------------------------------------------------------------------------------- /src/scss/layout/_footer.scss: -------------------------------------------------------------------------------- 1 | //Footer specific stylings 2 | .entry-footer { 3 | clear:both; 4 | } -------------------------------------------------------------------------------- /src/scss/layout/_header.scss: -------------------------------------------------------------------------------- 1 | //Header specific stylings -------------------------------------------------------------------------------- /src/scss/layout/_layout.scss: -------------------------------------------------------------------------------- 1 | /* Layout Stylings */ 2 | @import "navigation"; 3 | @import "header"; 4 | @import "footer"; 5 | @import "site"; -------------------------------------------------------------------------------- /src/scss/layout/_navigation.scss: -------------------------------------------------------------------------------- 1 | //Navigation specific stylings -------------------------------------------------------------------------------- /src/scss/layout/_site.scss: -------------------------------------------------------------------------------- 1 | // Site specific styles 2 | -------------------------------------------------------------------------------- /src/scss/main.scss: -------------------------------------------------------------------------------- 1 | @import "helpers/helpers"; 2 | @import "base/base"; 3 | @import "components/components"; 4 | @import "layout/layout"; 5 | @import "pages/pages"; -------------------------------------------------------------------------------- /src/scss/pages/_home.scss: -------------------------------------------------------------------------------- 1 | //Home page specific stylings -------------------------------------------------------------------------------- /src/scss/pages/_pages.scss: -------------------------------------------------------------------------------- 1 | /* Page specific stylings */ 2 | @import "home"; -------------------------------------------------------------------------------- /style.css: -------------------------------------------------------------------------------- 1 | /* 2 | Theme Name: Sprig Wordpress Starter Theme 3 | Theme URI: http://sprigtheme.com 4 | Description: Sprig is a Wordpress Starter Theme that includes the incredible power of the Twig PHP Templating Engine 5 | Version: 1 6 | Author: Zach Adams 7 | Author URI: http://zach-adams.com/ 8 | 9 | License: MIT License 10 | License URI: http://opensource.org/licenses/MIT 11 | */ 12 | -------------------------------------------------------------------------------- /template-sidebar.php: -------------------------------------------------------------------------------- 1 | 5 |
    6 | {% include 'content/content-404.twig' %} 7 |
    8 | 9 | {% endblock %} -------------------------------------------------------------------------------- /twigs/archive.twig: -------------------------------------------------------------------------------- 1 | {% extends 'layouts/sidebar.twig' %} 2 | 3 | {% block content %} 4 | 7 | {% for post in posts() %} {{ the_post(post) }} 8 | {% include 'content/content-excerpt.twig' %} 9 |
    10 | {% endfor %} 11 | {% if posts is empty %} 12 | {% include 'content/content-none.twig' %} 13 | {% endif %} 14 | {% include 'includes/paging.twig' %} 15 | {% endblock %} 16 | 17 | {% block sidebar %} 18 | {% set sidebar = wp.dynamic_sidebar('primary') %} 19 | {% endblock %} -------------------------------------------------------------------------------- /twigs/content/content-404.twig: -------------------------------------------------------------------------------- 1 |

    404 Not Found Sorry :(

    2 |

    Maybe try searching for it?

    3 | {{ wp.get_search_form }} -------------------------------------------------------------------------------- /twigs/content/content-excerpt.twig: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /twigs/content/content-none.twig: -------------------------------------------------------------------------------- 1 |
    2 |
    3 |

    Nothing found

    4 |
    5 |
    6 |

    Maybe try searching it?

    7 | {{ wp.get_search_form }} 8 |
    9 |
    -------------------------------------------------------------------------------- /twigs/content/content-page.twig: -------------------------------------------------------------------------------- 1 |
    2 | 5 |
    6 | {{ wp.the_content }} 7 | {{ wp.wp_link_pages({'echo':'0'}) }} 8 |
    9 | 10 |
    11 | {{ wp.edit_post_link('Edit','','') }} 12 |
    13 |
    14 |
    15 | {{ include('includes/comments.twig') }} -------------------------------------------------------------------------------- /twigs/content/content-single.twig: -------------------------------------------------------------------------------- 1 | 28 |
    29 | {{ include('includes/comments.twig') }} -------------------------------------------------------------------------------- /twigs/content/content.twig: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /twigs/home.twig: -------------------------------------------------------------------------------- 1 | {% extends 'layouts/sidebar.twig' %} 2 | 3 | {% block content %} 4 | {% for post in posts() %} {{ the_post(post) }} 5 | {% include 'content/content-excerpt.twig' %} 6 |
    7 | {% endfor %} 8 | {% if posts() is empty %} 9 | {% include 'content/content-none.twig' %} 10 | {% endif %} 11 | {% include 'includes/paging.twig' %} 12 | {% endblock %} 13 | 14 | {% block sidebar %} 15 | {% set sidebar = wp.dynamic_sidebar('primary') %} 16 | {% endblock %} -------------------------------------------------------------------------------- /twigs/includes/entry-meta.twig: -------------------------------------------------------------------------------- 1 |
    2 |

    3 | Posted on {{ wp.get_the_date() }} 4 |

    5 |
    -------------------------------------------------------------------------------- /twigs/includes/footer.twig: -------------------------------------------------------------------------------- 1 |
    2 |
    3 | {{ wp.dynamic_sidebar('sidebar-footer') }} 4 |
    5 |
    6 | -------------------------------------------------------------------------------- /twigs/includes/head.twig: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | {{ wp.wp_title('|', true, 'right') }} 9 | 10 | 11 | {{ wp.wp_head }} 12 | 13 | 27 | 28 | -------------------------------------------------------------------------------- /twigs/includes/header.twig: -------------------------------------------------------------------------------- 1 | 35 | -------------------------------------------------------------------------------- /twigs/includes/paging.twig: -------------------------------------------------------------------------------- 1 | {% if wp_query.max_num_pages > 1 %} 2 | 8 | {% endif %} -------------------------------------------------------------------------------- /twigs/includes/sidebar.twig: -------------------------------------------------------------------------------- 1 | {% set sidebar = wp.dynamic_sidebar('sidebar-primary') %} -------------------------------------------------------------------------------- /twigs/index.twig: -------------------------------------------------------------------------------- 1 | {% extends 'layouts/base.twig' %} 2 | 3 | {% block content %} 4 | {% for post in posts() %} {{ the_post(post) }} 5 | {% include wp.get_post_format ? 'content/content-' ~ wp.get_post_format ~ '.twig' : 'content/content.twig' %} 6 | {% endfor %} 7 | {% include 'includes/paging.twig' %} 8 | {% endblock %} -------------------------------------------------------------------------------- /twigs/layouts/base.twig: -------------------------------------------------------------------------------- 1 | {% include('includes/head.twig') %} 2 | 3 | 4 | 5 | {% include('includes/header.twig') %} 6 | 7 |
    8 |
    9 | {% block content %}{% endblock %} 10 |
    11 |
    12 | 13 | {% include('includes/footer.twig') %} 14 | 15 | {{ wp.wp_footer }} 16 | 17 | 18 | -------------------------------------------------------------------------------- /twigs/layouts/sidebar.twig: -------------------------------------------------------------------------------- 1 | {% include('includes/head.twig') %} 2 | 3 | 4 | 5 | {% include('includes/header.twig') %} 6 | 7 |
    8 |
    9 |
    10 |
    11 | {% block content %}{% endblock %} 12 |
    13 |
    14 |
    15 | {% block sidebar %}{% endblock %} 16 |
    17 |
    18 |
    19 | 20 | {% include('includes/footer.twig') %} 21 | 22 | {{ wp.wp_footer }} 23 | 24 | 25 | -------------------------------------------------------------------------------- /twigs/page.twig: -------------------------------------------------------------------------------- 1 | {% extends 'layouts/base.twig' %} 2 | 3 | {% block content %} 4 |
    5 |
    6 | {% for post in posts() %}{{ the_post(post) }} 7 | {% include 'content/content-page.twig' %} 8 | {% endfor %} 9 |
    10 |
    11 | {% endblock %} -------------------------------------------------------------------------------- /twigs/search.twig: -------------------------------------------------------------------------------- 1 | {% extends 'layouts/base.twig' %} 2 | 3 | {% block content %} 4 | 7 | {% for post in posts() %} {{ the_post(post) }} 8 | {% include 'content/content-excerpt.twig' %} 9 |
    10 | {% endfor %} 11 | {% if posts() is empty %} 12 | {% include 'content/content-none.twig' %} 13 | {% endif %} 14 | {% include 'includes/paging.twig' %} 15 | {% endblock %} -------------------------------------------------------------------------------- /twigs/single.twig: -------------------------------------------------------------------------------- 1 | {% extends 'layouts/sidebar.twig' %} 2 | 3 | {% block content %} 4 |
    5 |
    6 | {% for post in posts() %}{{ the_post(post) }} 7 | {% include 'content/content-single.twig' %} 8 | {% endfor %} 9 |
    10 |
    11 | {% endblock %} 12 | {% block sidebar %} 13 | {% set sidebar = wp.dynamic_sidebar('primary') %} 14 | {% endblock %} -------------------------------------------------------------------------------- /twigs/template-sidebar.twig: -------------------------------------------------------------------------------- 1 | {% extends 'layouts/sidebar.twig' %} 2 | 3 | {% block content %} 4 |
    5 |
    6 | {% for post in posts() %}{{ the_post(post) }} 7 | {% include 'content/content-page.twig' %} 8 | {% endfor %} 9 |
    10 |
    11 | {% endblock %} 12 | 13 | {% block sidebar %} 14 | {% include 'includes/sidebar.twig' %} 15 | {% endblock %} --------------------------------------------------------------------------------