moved the HTML extension to an external Composer package

This commit is contained in:
Fabien Potencier
2019-08-08 16:33:34 +02:00
parent f07a7f388d
commit 59bb9d1033
17 changed files with 158 additions and 11 deletions
+4 -1
View File
@@ -10,8 +10,11 @@ before_install:
install:
- travis_retry composer install
- (cd extra/html-extension && travis_retry composer install)
script: ./vendor/bin/simple-phpunit
script:
- ./vendor/bin/simple-phpunit
- (cd extra/html-extension && ./vendor/bin/simple-phpunit)
jobs:
fast_finish: true
+1 -2
View File
@@ -1,7 +1,6 @@
* 2.12.0 (2019-XX-XX)
* added the "html_classes" function
* added the "data_uri" filter
* added the HtmlExtension: "html_classes" function and "data_uri" filter
* fixed cache when opcache is installed but disabled
* fixed using macros in arrow functions
-1
View File
@@ -31,7 +31,6 @@
"require-dev": {
"symfony/phpunit-bridge": "^4.4@dev|^5.0",
"symfony/debug": "^3.4|^4.2",
"symfony/mime": "^4.3",
"psr/container": "^1.0"
},
"autoload": {
+8 -2
View File
@@ -25,9 +25,15 @@ The ``data_uri`` filter generates a URL using the data scheme as defined in RFC
.. note::
The ``data_uri`` filter is part of the ``HtmlExtension`` which is not
enabled by default; you must add it explicitly on the Twig environment::
installed by default. Install it first:
use Twig\Extension\HtmlExtension;
.. code-block:: bash
$ composer req twig/html-extension
Then, add it on the Twig environment::
use Twig\Html\HtmlExtension;
$twig = new \Twig\Environment(...);
$twig->addExtension(new HtmlExtension());
+8 -2
View File
@@ -18,9 +18,15 @@ names together:
.. note::
The ``html_classes`` function is part of the ``HtmlExtension`` which is not
enabled by default; you must add it explicitly on the Twig environment::
installed by default. Install it first:
use Twig\Extension\HtmlExtension;
.. code-block:: bash
$ composer req twig/html-extension
Then, add it on the Twig environment::
use Twig\Html\HtmlExtension;
$twig = new \Twig\Environment(...);
$twig->addExtension(new HtmlExtension());
+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.
+13
View File
@@ -0,0 +1,13 @@
Twig HTML Extension
===================
This package is a Twig extension that provides the following:
* [`data_uri`][1] filter: generates a URL using the data scheme as defined in
RFC 2397;
* [`html_classes`][2] function: returns a string by conditionally joining class
names together.
[1]: https://twig.symfony.com/doc/2.x/functions/html_classes.html
[2]: https://twig.symfony.com/doc/2.x/filters/data_uri.html
+39
View File
@@ -0,0 +1,39 @@
{
"name": "twig/html-extension",
"type": "library",
"description": "A Twig extension for HTML",
"keywords": ["twig", "html"],
"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",
"twig/twig": "^2.4|^3.0"
},
"require-dev": {
"symfony/mime": "^4.3",
"symfony/phpunit-bridge": "^4.4@dev"
},
"autoload": {
"psr-4" : {
"Twig\\Html\\" : "src/"
}
},
"autoload-dev": {
"psr-4" : {
"Twig\\Html\\Tests\\" : "tests/"
}
},
"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 HTML Extension Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>./</directory>
<exclude>
<directory>./tests</directory>
<directory>./vendor</directory>
</exclude>
</whitelist>
</filter>
</phpunit>
@@ -9,8 +9,9 @@
* file that was distributed with this source code.
*/
namespace Twig\Extension {
namespace Twig\Html {
use Symfony\Component\Mime\MimeTypes;
use Twig\Extension\AbstractExtension;
use Twig\TwigFilter;
use Twig\TwigFunction;
@@ -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\Intl\Tests;
use Twig\Html\HtmlExtension;
use Twig\Test\IntegrationTestCase;
class IntegrationTest extends IntegrationTestCase
{
public function getExtensions()
{
return [
new HtmlExtension(),
];
}
public function getFixturesDir()
{
return __DIR__.'/Fixtures/';
}
}
-2
View File
@@ -13,7 +13,6 @@ namespace Twig\Tests;
use Twig\Extension\AbstractExtension;
use Twig\Extension\DebugExtension;
use Twig\Extension\HtmlExtension;
use Twig\Extension\SandboxExtension;
use Twig\Extension\StringLoaderExtension;
use Twig\Node\Expression\ConstantExpression;
@@ -44,7 +43,6 @@ class IntegrationTest extends IntegrationTestCase
new SandboxExtension($policy, false),
new StringLoaderExtension(),
new TwigTestExtension(),
new HtmlExtension(),
];
}