Skip to content

Commit

Permalink
feat(engine-twig-php): update @basalt/twig-renderer to v3.0.1 using T…
Browse files Browse the repository at this point in the history
…wig v3.7.1 (#1499)

* feat(engine-twig-php): update @basalt/twig-renderer to v3.0.1 using Twig v3.7.1

Closes: #1496

* feat(edition-twig): alter-twig.php using Twig v3 namespaces

Refs: #1496

* fix(edition-twig): deprecation message "hiding by underscore prefix"
  • Loading branch information
hadl committed Dec 21, 2023
1 parent c5ef833 commit 2e5c9e1
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 15 deletions.
11 changes: 6 additions & 5 deletions packages/edition-twig/alter-twig.php
@@ -1,15 +1,17 @@
<?php
use Twig\Environment;
use Twig\TwigFunction;

/**
* @param Twig_Environment $env - The Twig Environment - https://twig.symfony.com/api/1.x/Twig_Environment.html
* @param $config - Config of `@basalt/twig-renderer`
*/
function addCustomExtension(\Twig_Environment &$env, $config) {
function addCustomExtension(Environment &$env, $config) {

/**
* @example `<h1>Hello {{ customTwigFunctionThatSaysWorld() }}!</h1>` => `<h1>Hello Custom World</h1>`
*/
// $env->addFunction(new \Twig_SimpleFunction('customTwigFunctionThatSaysWorld', function () {
// $env->addFunction(new TwigFunction('customTwigFunctionThatSaysWorld', function () {
// return 'Custom World';
// }));

Expand All @@ -18,7 +20,7 @@ function addCustomExtension(\Twig_Environment &$env, $config) {
* @param string $theString
* @example `<p>{{ reverse('abc') }}</p>` => `<p>cba</p>`
*/
// $env->addFunction(new \Twig_SimpleFunction('reverse', function ($theString) {
// $env->addFunction(new TwigFunction('reverse', function ($theString) {
// return strrev($theString);
// }));

Expand All @@ -29,6 +31,5 @@ function addCustomExtension(\Twig_Environment &$env, $config) {
// $env->addGlobal('foo', 'bar');

// example of enabling the Twig debug mode extension (ex. {{ dump(my_variable) }} to check out the template's available data) -- comment out to disable
// $env->addExtension(new \Twig_Extension_Debug());

// $env->addExtension(new Twig\Extension\DebugExtension());
}
@@ -1,4 +1,4 @@
{% include '@atoms/buttons/_button.twig' with {
{% include '@atoms/buttons/button.twig' with {
text: 'Click Me',
dark: true,
} only %}
@@ -1,3 +1,3 @@
{% include '@atoms/buttons/_button.twig' with {
{% include '@atoms/buttons/button.twig' with {
text: 'Click Me',
} only %}
@@ -0,0 +1,3 @@
---
hidden: true
---
@@ -1,6 +1,6 @@
<h1>Heading Level 1</h1>
<h2>Heading Level 2</h2>
<h3>Heading Level 3</h3>
<h3>Heading Level 3</h3>
<h4>Heading Level 4</h4>
<h5>Heading Level 5</h5>
<h5>Heading Level 5</h5>
<h6>Heading Level 6</h6>
@@ -1,6 +1,6 @@
<div class="card">
<h2>Card Title here</h2>
{% include '@atoms/buttons/_button.twig' with {
{% include '@atoms/buttons/button.twig' with {
text: 'some text from card'
} only %}
</div>
2 changes: 1 addition & 1 deletion packages/engine-twig-php/package.json
Expand Up @@ -4,7 +4,7 @@
"version": "6.0.1",
"main": "lib/engine_twig_php.js",
"dependencies": {
"@basalt/twig-renderer": "^2.0.0",
"@basalt/twig-renderer": "^3.0.1",
"@pattern-lab/core": "^6.0.1",
"chalk": "^4.1.0",
"fs-extra": "10.0.0"
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Expand Up @@ -1121,10 +1121,10 @@
"@babel/helper-validator-identifier" "^7.19.1"
to-fast-properties "^2.0.0"

"@basalt/twig-renderer@^2.0.0":
version "2.1.0"
resolved "https://registry.yarnpkg.com/@basalt/twig-renderer/-/twig-renderer-2.1.0.tgz#951e524fe1c75b37242d28d5b9552c9b1cce807b"
integrity sha512-27+8D3xJa8ht9ngo8FGsN76thAlQGsNiq5VF+rQX/aV93aGOneHGG900Tj0GqeZTKJ+F3s1O8I13JV0jcECByw==
"@basalt/twig-renderer@^3.0.1":
version "3.0.1"
resolved "https://registry.yarnpkg.com/@basalt/twig-renderer/-/twig-renderer-3.0.1.tgz#6c75dca804ed917483b3028f2bfd4130173e5c20"
integrity sha512-pLZeVxdwohW0Y3yXxnEpvJahoGPe5MSbvspeYVKMaVvUZnFD90R4plYmvHcXrMBUCwmcPU4bIOXaV/TNzxS/hg==
dependencies:
"@babel/core" "^7.2.0"
"@babel/preset-env" "^7.2.0"
Expand Down

0 comments on commit 2e5c9e1

Please sign in to comment.