ocubom / html-bundle
A Symfony bundle to integrate several custom utilities for HTML manipulation
Installs: 9
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=7.4
- ocubom/twig-html-extension: ^1.0
- symfony/config: ^5.4|^6.0
- symfony/dependency-injection: ^5.4|^6.0
- symfony/twig-bundle: ^5.4|^6.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.4|^3.9
- symfony/phpunit-bridge: ^6.1
README
A Symfony bundle to integrate several custom utilities for HTML manipulation
Contents
About HTML Bundle
Ocubom HTML Bundle is a Symfony Bundle that integrates several utilities for HTML manipulation.
This suite started as an internal class based on nochso/html-compress-twig to allow the use of wyrihaximus/html-compress with Twig 3.0. This class used to be embedded into several projects. Over time, each project adapted its version slightly, leading to fragmented development and difficult maintenance. Therefore, the development is unified in this extension which is made public in case it is useful for other projects.
Getting Started
Installation
Make sure Composer is installed globally, as explained in the installation chapter of the Composer documentation.
Applications that use Symfony Flex
Open a command console, enter your project directory and execute:
$ composer require ocubom/html-bundle
Applications that don't use Symfony Flex
Step 1: Download the Bundle
Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:
$ composer require ocubom/html-bundle
Step 2: Enable the Bundle
Then, enable the bundle by adding it to the list of registered bundles
in the config/bundles.php
file of your project:
// config/bundles.php return [ // ... Ocubom\HtmlBundle\OcubomHtmlBundle::class => ['all' => true], ];
Usage
Just create the file config/packages/ocubom_html.yaml
using the configuration reference:
bin/console config:dump-reference ocubom_html
You can use the example configuration provided.
ocubom_html: # Register Ocubom/TwigHtmlExtension to minify the HTML (defaults) compress: force: false level: smallest # Headers extract # The listener is only registered if some header is registered #headers: # # Duplicate robots meta as X-Robots-Tag # # @see https://developers.google.com/search/docs/advanced/robots/robots_meta_tag#xrobotstag # - name: 'X-Robots-Tag' # pattern: '@[\p{Zs}]*<meta\s+(?:name="robots"\s+content="([^"]+)"|content="([^"]+)"\s+name="robots")\s*/?\s*>\p{Zs}*\n?@i' # value: '%2$s' # replace: '%1$s' # formats: # - 'text/html' # # # Disable Metro Interface # # @see https://github.com/h5bp/html5-boilerplate/blob/5.3.0/dist/doc/extend.md#prompt-users-to-switch-to-desktop-mode-in-ie10-metro # - name: 'X-UA-Compatible' # enabled: true # pattern: '@[\p{Zs}]*<meta\s+(?:http-equiv="X-UA-Compatible"\s+content="([^"]+)"|content="([^"]+)"\s+http-equiv="X-UA-Compatible")\s*>\p{Zs}*\n?@i' # value: '%2$s' # replace: '' # Delete the meta tag as is not standard # formats: # - 'text/html'
Note This configuration will be installed if your project uses endroid/installer
For more examples, please refer to the Documentation.
Roadmap
See the open issues for a full list of proposed features (and known issues).
Contributing
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement".
- Fork the Project.
- Create your Feature Branch (
git checkout -b feature/your-feature
). - Commit your Changes (
git commit -m 'Add your-feature'
). - Push to the Branch (
git push origin feature/your-feature
). - Open a Pull Request.
Authorship
- Oscar Cubo Medina — @ocubom — https://ocubom.page
See also the list of contributors who participated in this project.
License
Distributed under the MIT License. See LICENSE for more information.