added the cssinliner and inky extensions

This commit is contained in:
Fabien Potencier
2019-08-11 11:30:22 +02:00
parent 5168c0e2fe
commit 37ed0436dd
29 changed files with 698 additions and 71 deletions
+4
View File
@@ -11,13 +11,17 @@ before_install:
install:
- travis_retry composer install
- (cd extra/cssinliner-extra && travis_retry composer install)
- (cd extra/html-extra && travis_retry composer install)
- (cd extra/inky-extra && travis_retry composer install)
- (cd extra/intl-extra && travis_retry composer install)
- (cd extra/markdown-extra && travis_retry composer install)
script:
- ./vendor/bin/simple-phpunit
- (cd extra/cssinliner-extra && ./vendor/bin/simple-phpunit)
- (cd extra/html-extra && ./vendor/bin/simple-phpunit)
- (cd extra/inky-extra && ./vendor/bin/simple-phpunit)
- (cd extra/intl-extra && ./vendor/bin/simple-phpunit)
- (cd extra/markdown-extra && ./vendor/bin/simple-phpunit)
+2
View File
@@ -27,6 +27,8 @@ Filters
format_number
format_time
html_to_markdown
inline_css
inky
join
json_encode
keys
+40
View File
@@ -0,0 +1,40 @@
``inky``
========
.. versionadded:: 2.12
The ``inky`` filter was added in Twig 2.12.
The ``inky`` filter processes an `inky email template
<https://github.com/zurb/inky>`_:
.. code-block:: twig
{% apply inky %}
<row>
<columns large="6"></columns>
<columns large="6"></columns>
</row>
{% endapply %}
You can also use the filter on an included file:
.. code-block:: twig
{{ include('some_template.inky.twig')|inky }}
.. note::
The ``inky`` filter is part of the ``CssInlinerExtension`` which is not
installed by default. Install it first:
.. code-block:: bash
$ composer req twig/cssinliner-extra
Then, use the ``twig/extra-bundle`` on Symfony projects or add the extension
explictly on the Twig environment::
use Twig\Extra\CssInliner\CssInlinerExtension;
$twig = new \Twig\Environment(...);
$twig->addExtension(new CssInlinerExtension());
+64
View File
@@ -0,0 +1,64 @@
``inline_css``
==============
.. versionadded:: 2.12
The ``inline_css`` filter was added in Twig 2.12.
The ``inline_css`` filter inline CSS styles in HTML documents:
.. code-block:: twig
{% apply inline_css %}
<html>
<head>
<style>
p { color: red; }
</style>
</head>
<body>
<p>Hello CSS!</p>
</body>
</html>
{% endapply %}
You can also add some stylesheets by passing them as arguments to the filter:
.. code-block:: twig
{% apply inline_css(source("some_styles.css"), source("another.css")) %}
<html>
<body>
<p>Hello CSS!</p>
</body>
</html>
{% endapply %}
Styles loaded via the filter override the styles defined in the ``<style>`` tag
of the HTML document.
You can also use the filter on an included file:
.. code-block:: twig
{{ include('some_template.html.twig')|inline_css }}
{{ include('some_template.html.twig')|inline_css(source("some_styles.css")) }}
Note that the CSS inliner works on an entire HTML document, not a fragment.
.. note::
The ``inline_css`` filter is part of the ``CssInlinerExtension`` which is not
installed by default. Install it first:
.. code-block:: bash
$ composer req twig/cssinliner-extra
Then, use the ``twig/extra-bundle`` on Symfony projects or add the extension
explictly on the Twig environment::
use Twig\Extra\CssInliner\CssInlinerExtension;
$twig = new \Twig\Environment(...);
$twig->addExtension(new CssInlinerExtension());
+4
View File
@@ -0,0 +1,4 @@
vendor/
composer.lock
phpunit.xml
.phpunit.result.cache
+19
View File
@@ -0,0 +1,19 @@
Copyright (c) 2019 Fabien Potencier
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
+8
View File
@@ -0,0 +1,8 @@
Twig CssInliner Extension
=========================
This package is a Twig extension that provides the following:
* [`inline_css`][1] filter: inlines CSS styles in HTML documents.
[1]: https://twig.symfony.com/inline_css
+39
View File
@@ -0,0 +1,39 @@
{
"name": "twig/cssinliner-extra",
"type": "library",
"description": "A Twig extension to allow inlining CSS",
"keywords": ["twig", "css", "inlining"],
"homepage": "https://twig.symfony.com",
"license": "MIT",
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com",
"homepage": "http://fabien.potencier.org",
"role": "Lead Developer"
}
],
"require": {
"php": "^7.1.3",
"tijsverkoyen/css-to-inline-styles": "^2.0",
"twig/twig": "^2.4|^3.0"
},
"require-dev": {
"symfony/phpunit-bridge": "^4.4@dev"
},
"autoload": {
"psr-4" : {
"Twig\\Extra\\CssInliner\\" : "src/"
}
},
"autoload-dev": {
"psr-4" : {
"Twig\\Extra\\CssInliner\\Tests\\" : "test/"
}
},
"extra": {
"branch-alias": {
"dev-master": "2.12-dev"
}
}
}
+30
View File
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/5.2/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="vendor/autoload.php"
failOnRisky="true"
failOnWarning="true"
>
<php>
<ini name="error_reporting" value="-1" />
</php>
<testsuites>
<testsuite name="Twig CssInlinder Extension Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>./</directory>
<exclude>
<directory>./tests</directory>
<directory>./vendor</directory>
</exclude>
</whitelist>
</filter>
</phpunit>
@@ -0,0 +1,36 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Twig\Extra\CssInliner;
use TijsVerkoyen\CssToInlineStyles\CssToInlineStyles;
use Twig\Extension\AbstractExtension;
use Twig\TwigFilter;
class CssInlinerExtension extends AbstractExtension
{
public function getFilters()
{
return [
new TwigFilter('inline_css', 'Twig\\Extra\\CssInliner\\twig_inline_css', ['is_safe' => ['all']]),
];
}
}
function twig_inline_css(string $body, string ...$css): string
{
static $inliner;
if (null === $inliner) {
$inliner = new CssToInlineStyles();
}
return $inliner->convert($body, implode("\n", $css));
}
@@ -0,0 +1,53 @@
--TEST--
"inky" filter
--TEMPLATE--
{% apply inline_css|spaceless %}
<html>
<style>p { color: red }</style>
<p>Great!</p>
</html>
{% endapply %}
{% apply inline_css(source('css'))|spaceless %}
<html>
<p>Great!</p>
</html>
{% endapply %}
{% apply inline_css(source('css'), source('more_css'))|spaceless %}
<html>
<p>Great!</p>
</html>
{% endapply %}
{% apply inline_css(source('css') ~ source('more_css'))|spaceless %}
<html>
<p>Great!</p>
</html>
{% endapply %}
{{ include('html')|inline_css(source('css') ~ source('more_css'))|spaceless }}
--TEMPLATE(html)--
<html>
<p>Great!</p>
</html>
--TEMPLATE(css)--
p { color: red }
--TEMPLATE(more_css)--
p { color: blue }
--DATA--
return []
--EXPECT--
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"><html><head><style>p { color: red }</style></head><body><p style="color: red;">Great!</p></body></html>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"><html><body><p style="color: red;">Great!</p></body></html>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"><html><body><p style="color: blue;">Great!</p></body></html>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"><html><body><p style="color: blue;">Great!</p></body></html>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"><html><body><p style="color: blue;">Great!</p></body></html>
@@ -0,0 +1,30 @@
<?php
/*
* This file is part of Twig.
*
* (c) Fabien Potencier
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Twig\Extra\CssInliner\Tests;
use Twig\Extra\CssInliner\CssInlinerExtension;
use Twig\Test\IntegrationTestCase;
class IntegrationTest extends IntegrationTestCase
{
public function getExtensions()
{
return [
new CssInlinerExtension(),
];
}
public function getFixturesDir()
{
return __DIR__.'/Fixtures/';
}
}
+4
View File
@@ -0,0 +1,4 @@
vendor/
composer.lock
phpunit.xml
.phpunit.result.cache
+19
View File
@@ -0,0 +1,19 @@
Copyright (c) 2019 Fabien Potencier
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
+8
View File
@@ -0,0 +1,8 @@
Twig Inky Extension
===================
This package is a Twig extension that provides the following:
* [`inky`][1] filter: processes an [inky email template](https://github.com/zurb/inky).
[1]: https://twig.symfony.com/inky
+39
View File
@@ -0,0 +1,39 @@
{
"name": "twig/inky-extra",
"type": "library",
"description": "A Twig extension for the inky email templating engine",
"keywords": ["twig", "inky", "email", "emails"],
"homepage": "https://twig.symfony.com",
"license": "MIT",
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com",
"homepage": "http://fabien.potencier.org",
"role": "Lead Developer"
}
],
"require": {
"php": "^7.1.3",
"lorenzo/pinky": "^1.0",
"twig/twig": "^2.4|^3.0"
},
"require-dev": {
"symfony/phpunit-bridge": "^4.4@dev"
},
"autoload": {
"psr-4" : {
"Twig\\Extra\\Inky\\" : "src/"
}
},
"autoload-dev": {
"psr-4" : {
"Twig\\Extra\\Inky\\Tests\\" : "test/"
}
},
"extra": {
"branch-alias": {
"dev-master": "2.12-dev"
}
}
}
+30
View File
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/5.2/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="vendor/autoload.php"
failOnRisky="true"
failOnWarning="true"
>
<php>
<ini name="error_reporting" value="-1" />
</php>
<testsuites>
<testsuite name="Twig Inky Extension Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>./</directory>
<exclude>
<directory>./tests</directory>
<directory>./vendor</directory>
</exclude>
</whitelist>
</filter>
</phpunit>
@@ -0,0 +1,29 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Twig\Extra\Inky\Bundle\DependencyInjection;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
/**
* @author Fabien Potencier <fabien@symfony.com>
*/
class TwigInkyExtension extends Extension
{
public function load(array $configs, ContainerBuilder $container)
{
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('inky.xml');
}
}
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<defaults public="false" />
<service id="twig.extension.inky" class="Twig\Inky\InkyExtension">
<tag name="twig.extension" />
</service>
</services>
</container>
@@ -0,0 +1,18 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Twig\Extra\Inky\Bundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;
class TwigInkyBundle extends Bundle
{
}
+31
View File
@@ -0,0 +1,31 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Twig\Extra\Inky;
use Pinky;
use Twig\Extension\AbstractExtension;
use Twig\TwigFilter;
class InkyExtension extends AbstractExtension
{
public function getFilters()
{
return [
new TwigFilter('inky', 'Twig\\Extra\\Inky\\twig_inky', ['is_safe' => ['html']]),
];
}
}
function twig_inky(string $body): string
{
return Pinky\transformString($body)->saveHTML();
}
+16
View File
@@ -0,0 +1,16 @@
--TEST--
"inky" filter
--TEMPLATE--
{% apply inky %}
<container class="extra">{{ var }}</container>
{%- endapply %}
{{ include("inky")|inky }}
--TEMPLATE(inky)--
<container class="extra">{{ var }}</container>
--DATA--
return ['var' => 'value<br />']
--EXPECT--
<html><body><table align="center" class="extra container"><tbody><tr><td>value&lt;br /&gt;</td></tr></tbody></table></body></html>
<html><body><table align="center" class="extra container"><tbody><tr><td>value&lt;br /&gt;</td></tr></tbody></table></body></html>
@@ -0,0 +1,30 @@
<?php
/*
* This file is part of Twig.
*
* (c) Fabien Potencier
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Twig\Extra\Inky\Tests;
use Twig\Extra\Inky\InkyExtension;
use Twig\Test\IntegrationTestCase;
class IntegrationTest extends IntegrationTestCase
{
public function getExtensions()
{
return [
new InkyExtension(),
];
}
public function getFixturesDir()
{
return __DIR__.'/Fixtures/';
}
}
@@ -13,9 +13,7 @@ namespace Twig\Extra\TwigExtraBundle\DependencyInjection;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
use Twig\Extra\Html\HtmlExtension;
use Twig\Extra\Intl\IntlExtension;
use Twig\Extra\Markdown\MarkdownExtension;
use Twig\Extra\TwigExtraBundle\Extensions;
class Configuration implements ConfigurationInterface
{
@@ -24,29 +22,15 @@ class Configuration implements ConfigurationInterface
$treeBuilder = new TreeBuilder('twig_extra');
$rootNode = $treeBuilder->getRootNode();
$rootNode
->children()
->arrayNode('html')
->{class_exists(HtmlExtension::class) ? 'canBeDisabled' : 'canBeEnabled'}()
foreach (Extensions::getClasses() as $extension => $class) {
$rootNode
->children()
->arrayNode($extension)
->{class_exists($class) ? 'canBeDisabled' : 'canBeEnabled'}()
->end()
->end()
->end()
;
$rootNode
->children()
->arrayNode('markdown')
->{class_exists(MarkdownExtension::class) ? 'canBeDisabled' : 'canBeEnabled'}()
->end()
->end()
;
$rootNode
->children()
->arrayNode('intl')
->{class_exists(IntlExtension::class) ? 'canBeDisabled' : 'canBeEnabled'}()
->end()
->end()
;
;
}
return $treeBuilder;
}
@@ -15,6 +15,7 @@ use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Twig\Extra\TwigExtraBundle\Extensions;
/**
* @author Fabien Potencier <fabien@symfony.com>
@@ -31,16 +32,10 @@ class TwigExtraExtension extends Extension
$loader->load('suggestor.xml');
}
if ($this->isConfigEnabled($container, $config['html'])) {
$loader->load('html.xml');
}
if ($this->isConfigEnabled($container, $config['markdown'])) {
$loader->load('markdown.xml');
}
if ($this->isConfigEnabled($container, $config['intl'])) {
$loader->load('intl.xml');
foreach (array_keys(Extensions::getClasses()) as $extension) {
if ($this->isConfigEnabled($container, $config[$extension])) {
$loader->load($extension.'.xml');
}
}
}
}
@@ -0,0 +1,85 @@
<?php
/*
* This file is part of Twig.
*
* (c) Fabien Potencier
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Twig\Extra\TwigExtraBundle;
final class Extensions
{
private const EXTENSIONS = [
'html' => [
'name' => 'html',
'class' => HtmlExtension::class,
'class_name' => 'HtmlExtension',
'package' => 'twig/html-extra',
'filters' => ['data_uri'],
'functions' => ['html_classes'],
],
'markdown' => [
'name' => 'markdown',
'class' => MarkdownExtension::class,
'class_name' => 'MarkdownExtension',
'package' => 'twig/markdown-extra',
'filters' => ['html_to_markdown', 'markdown_to_html'],
],
'intl' => [
'name' => 'intl',
'class' => IntlExtension::class,
'class_name' => 'IntlExtension',
'package' => 'twig/intl-extra',
'filters' => ['country_name', 'currency_name', 'currency_symbol', 'language_name', 'country_timezones',
'format_currency', 'format_number', 'format_decimal_number', 'format_currency_number',
'format_percent_number', 'format_scientific_number', 'format_spellout_number', 'format_ordinal_number',
'format_duration_number', 'format_date', 'format_datetime', 'format_time'
],
],
'cssinliner' => [
'name' => 'cssinliner',
'class' => CssInlinerExtension::class,
'class_name' => 'CssInlinerExtension',
'package' => 'twig/cssinliner-extra',
'filters' => ['inline_css'],
],
'inky' => [
'name' => 'inky',
'class' => InkyExtension::class,
'class_name' => 'InkyExtension',
'package' => 'twig/inky-extra',
'filters' => ['inky'],
],
];
public static function getClasses(): array
{
return array_column(self::EXTENSIONS, 'class', 'name');
}
public static function getFilters(string $name): array
{
foreach (self::EXTENSIONS as $extension) {
if (in_array($name, $extension['filters'])) {
return [$extension['class_name'], $extension['package']];
}
}
return [];
}
public static function getFunctions(string $name): array
{
foreach (self::EXTENSIONS as $extension) {
if (in_array($name, $extension['functions'])) {
return [$extension['class_name'], $extension['package']];
}
}
return [];
}
}
@@ -15,42 +15,10 @@ use Twig\Error\SyntaxError;
final class MissingExtensionSuggestor
{
private const FILTERS = [
// HTML
'data_uri' => ['HtmlExtension', 'twig/html-extra'],
// Markdown
'html_to_markdown' => ['MarkdownExtension', 'twig/markdown-extra'],
'markdown_to_html' => ['MarkdownExtension', 'twig/markdown-extra'],
// Intl
'country_name' => ['IntlExtension', 'twig/intl-extra'],
'currency_name' => ['IntlExtension', 'twig/intl-extra'],
'currency_symbol' => ['IntlExtension', 'twig/intl-extra'],
'language_name' => ['IntlExtension', 'twig/intl-extra'],
'country_timezones' => ['IntlExtension', 'twig/intl-extra'],
'format_currency' => ['IntlExtension', 'twig/intl-extra'],
'format_number' => ['IntlExtension', 'twig/intl-extra'],
'format_decimal_number' => ['IntlExtension', 'twig/intl-extra'],
'format_currency_number' => ['IntlExtension', 'twig/intl-extra'],
'format_percent_number' => ['IntlExtension', 'twig/intl-extra'],
'format_scientific_number' => ['IntlExtension', 'twig/intl-extra'],
'format_spellout_number' => ['IntlExtension', 'twig/intl-extra'],
'format_ordinal_number' => ['IntlExtension', 'twig/intl-extra'],
'format_duration_number' => ['IntlExtension', 'twig/intl-extra'],
'format_date' => ['IntlExtension', 'twig/intl-extra'],
'format_datetime' => ['IntlExtension', 'twig/intl-extra'],
'format_time' => ['IntlExtension', 'twig/intl-extra'],
];
private const FUNCTIONS = [
'html_classes' => ['HtmlExtension', 'twig/html-extra'],
];
public function suggestFilter(string $name): bool
{
if (isset(self::FILTERS[$name])) {
throw new SyntaxError(sprintf('The "%s" filter is part of the %s, which is not installed/enabled; try running "composer require %s twig/extra-bundle".', $name, self::FILTERS[$name][0], self::FILTERS[$name][1]));
if ($filter = Extensions::getFilter($name)) {
throw new SyntaxError(sprintf('The "%s" filter is part of the %s, which is not installed/enabled; try running "composer require %s twig/extra-bundle".', $name, $filter[0], $filter[1]));
}
return false;
@@ -58,8 +26,8 @@ final class MissingExtensionSuggestor
public function suggestFunction(string $name): bool
{
if (isset(self::FUNCTIONS[$name])) {
throw new SyntaxError(sprintf('The "%s" function is part of the %s, which is not installed/enabled; try running "composer require %s twig/extra-bundle".', $name, self::FILTERS[$name][0], self::FILTERS[$name][1]));
if ($function = Extensions::getFunction($name)) {
throw new SyntaxError(sprintf('The "%s" function is part of the %s, which is not installed/enabled; try running "composer require %s twig/extra-bundle".', $name, $function[0], $function[1]));
}
return false;
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<defaults public="false" />
<service id="twig.extension.cssinliner" class="Twig\Extra\CssInliner\CssInlinerExtension">
<tag name="twig.extension" />
</service>
</services>
</container>
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<defaults public="false" />
<service id="twig.extension.inky" class="Twig\Extra\Inky\InkyExtension">
<tag name="twig.extension" />
</service>
</services>
</container>