Skip to content

Commit 32394a8

Browse files
committed
Upload twig-3.4.3 and add more example to show how you can isset a var or method
1 parent d3cab1c commit 32394a8

File tree

188 files changed

+16954
-63
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

188 files changed

+16954
-63
lines changed

cache/94/9414f9742abc9df8e8f6de6676eecee4.php

Lines changed: 0 additions & 62 deletions
This file was deleted.
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
<?php
2+
3+
use Twig\Environment;
4+
use Twig\Error\LoaderError;
5+
use Twig\Error\RuntimeError;
6+
use Twig\Extension\SandboxExtension;
7+
use Twig\Markup;
8+
use Twig\Sandbox\SecurityError;
9+
use Twig\Sandbox\SecurityNotAllowedTagError;
10+
use Twig\Sandbox\SecurityNotAllowedFilterError;
11+
use Twig\Sandbox\SecurityNotAllowedFunctionError;
12+
use Twig\Source;
13+
use Twig\Template;
14+
15+
/* index.html */
16+
class __TwigTemplate_b3c9ebcd5cf5b4def2481ba23d9c2b8c extends Template
17+
{
18+
private $source;
19+
private $macros = [];
20+
21+
public function __construct(Environment $env)
22+
{
23+
parent::__construct($env);
24+
25+
$this->source = $this->getSourceContext();
26+
27+
$this->parent = false;
28+
29+
$this->blocks = [
30+
];
31+
}
32+
33+
protected function doDisplay(array $context, array $blocks = [])
34+
{
35+
$macros = $this->macros;
36+
// line 1
37+
echo "<h1>Hello ";
38+
echo twig_escape_filter($this->env, ($context["name"] ?? null), "html", null, true);
39+
echo "!</h1>
40+
-----------------------------
41+
";
42+
// line 3
43+
if (array_key_exists("foo", $context)) {
44+
// line 4
45+
echo " ...
46+
";
47+
}
48+
// line 6
49+
echo "
50+
";
51+
// line 7
52+
if (twig_get_attribute($this->env, $this->source, ($context["foo"] ?? null), "bar", [], "any", true, true, false, 7)) {
53+
// line 8
54+
echo " ...
55+
";
56+
}
57+
// line 10
58+
echo "
59+
";
60+
// line 11
61+
if (twig_get_attribute($this->env, $this->source, ($context["foo"] ?? null), "bar", [], "array", true, true, false, 11)) {
62+
// line 12
63+
echo " ...
64+
";
65+
}
66+
// line 14
67+
echo "
68+
";
69+
// line 15
70+
if ((array_key_exists("var", $context) && twig_get_attribute($this->env, $this->source, ($context["foo"] ?? null), "method", [0 => ($context["var"] ?? null)], "method", true, true, false, 15))) {
71+
// line 16
72+
echo " ...
73+
";
74+
}
75+
}
76+
77+
public function getTemplateName()
78+
{
79+
return "index.html";
80+
}
81+
82+
public function isTraitable()
83+
{
84+
return false;
85+
}
86+
87+
public function getDebugInfo()
88+
{
89+
return array ( 72 => 16, 70 => 15, 67 => 14, 63 => 12, 61 => 11, 58 => 10, 54 => 8, 52 => 7, 49 => 6, 45 => 4, 43 => 3, 37 => 1,);
90+
}
91+
92+
public function getSourceContext()
93+
{
94+
return new Source("", "index.html", "C:\\Users\\Max\\TwigPHPNoComposer\\templates\\index.html");
95+
}
96+
}

example.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
spl_autoload_register(function ($classname)
33
{
4-
$dirs = ['./twig-3.4.1/'];
4+
$dirs = ['./twig-3.4.3/'];
55
foreach ($dirs as $dir) {
66
$filename = $dir . str_replace('\\', '/', $classname) .'.php';
77
if (file_exists($filename)) {

templates/index.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,17 @@
11
<h1>Hello {{ name }}!</h1>
2+
-----------------------------
3+
{% if foo is defined %}
4+
...
5+
{% endif %}
6+
7+
{% if foo.bar is defined %}
8+
...
9+
{% endif %}
10+
11+
{% if foo['bar'] is defined %}
12+
...
13+
{% endif %}
14+
15+
{% if var is defined and foo.method(var) is defined %}
16+
...
17+
{% endif %}

twig-3.4.3/.editorconfig

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
; top-most EditorConfig file
2+
root = true
3+
4+
; Unix-style newlines
5+
[*]
6+
end_of_line = LF
7+
8+
[*.php]
9+
indent_style = space
10+
indent_size = 4
11+
12+
[*.test]
13+
indent_style = space
14+
indent_size = 4
15+
16+
[*.rst]
17+
indent_style = space
18+
indent_size = 4

twig-3.4.3/.gitattributes

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/doc/ export-ignore
2+
/extra/ export-ignore
3+
/tests/ export-ignore
4+
/phpunit.xml.dist export-ignore

twig-3.4.3/.github/workflows/ci.yml

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
name: "CI"
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- '3.x'
8+
9+
env:
10+
SYMFONY_PHPUNIT_DISABLE_RESULT_CACHE: 1
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
tests:
17+
name: "PHP ${{ matrix.php-version }}"
18+
19+
runs-on: 'ubuntu-latest'
20+
21+
continue-on-error: ${{ matrix.experimental }}
22+
23+
strategy:
24+
matrix:
25+
php-version:
26+
- '7.2.5'
27+
- '7.3'
28+
- '7.4'
29+
- '8.0'
30+
- '8.1'
31+
experimental: [false]
32+
33+
steps:
34+
- name: "Checkout code"
35+
uses: actions/checkout@v2
36+
37+
- name: "Install PHP with extensions"
38+
uses: shivammathur/setup-php@v2
39+
with:
40+
coverage: "none"
41+
php-version: ${{ matrix.php-version }}
42+
ini-values: memory_limit=-1
43+
44+
- name: "Add PHPUnit matcher"
45+
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
46+
47+
- run: composer install
48+
49+
- name: "Install PHPUnit"
50+
run: vendor/bin/simple-phpunit install
51+
52+
- name: "PHPUnit version"
53+
run: vendor/bin/simple-phpunit --version
54+
55+
- name: "Run tests"
56+
run: vendor/bin/simple-phpunit
57+
58+
extension-tests:
59+
needs:
60+
- 'tests'
61+
62+
name: "${{ matrix.extension }} with PHP ${{ matrix.php-version }}"
63+
64+
runs-on: 'ubuntu-latest'
65+
66+
continue-on-error: true
67+
68+
strategy:
69+
matrix:
70+
php-version:
71+
- '7.2.5'
72+
- '7.3'
73+
- '7.4'
74+
- '8.0'
75+
- '8.1'
76+
extension:
77+
- 'extra/cache-extra'
78+
- 'extra/cssinliner-extra'
79+
- 'extra/html-extra'
80+
- 'extra/inky-extra'
81+
- 'extra/intl-extra'
82+
- 'extra/markdown-extra'
83+
- 'extra/string-extra'
84+
- 'extra/twig-extra-bundle'
85+
experimental: [false]
86+
87+
steps:
88+
- name: "Checkout code"
89+
uses: actions/checkout@v2
90+
91+
- name: "Install PHP with extensions"
92+
uses: shivammathur/setup-php@v2
93+
with:
94+
coverage: "none"
95+
php-version: ${{ matrix.php-version }}
96+
ini-values: memory_limit=-1
97+
98+
- name: "Add PHPUnit matcher"
99+
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
100+
101+
- run: composer install
102+
103+
- name: "Install PHPUnit"
104+
run: vendor/bin/simple-phpunit install
105+
106+
- name: "PHPUnit version"
107+
run: vendor/bin/simple-phpunit --version
108+
109+
- name: "Composer install"
110+
working-directory: ${{ matrix.extension}}
111+
run: composer install
112+
113+
- name: "Run tests"
114+
working-directory: ${{ matrix.extension}}
115+
run: ../../vendor/bin/simple-phpunit
116+
117+
#
118+
# Drupal does not support Twig 3 now!
119+
#
120+
# integration-tests:
121+
# needs:
122+
# - 'tests'
123+
#
124+
# name: "Integration tests with PHP ${{ matrix.php-version }}"
125+
#
126+
# runs-on: 'ubuntu-20.04'
127+
#
128+
# continue-on-error: true
129+
#
130+
# strategy:
131+
# matrix:
132+
# php-version:
133+
# - '7.3'
134+
#
135+
# steps:
136+
# - name: "Checkout code"
137+
# uses: actions/checkout@v2
138+
#
139+
# - name: "Install PHP with extensions"
140+
# uses: shivammathur/setup-php@2
141+
# with:
142+
# coverage: "none"
143+
# extensions: "gd, pdo_sqlite"
144+
# php-version: ${{ matrix.php-version }}
145+
# ini-values: memory_limit=-1
146+
# tools: composer:v2
147+
#
148+
# - run: bash ./tests/drupal_test.sh
149+
# shell: "bash"

0 commit comments

Comments
 (0)