A Symfony bundle to integrate several custom utilities for HTML manipulation
Contents
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.
Make sure Composer is installed globally, as explained in the installation chapter of the Composer documentation.
Open a command console, enter your project directory and execute:
$ composer require ocubom/html-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
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],
];
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.
See the open issues for a full list of proposed features (and known issues).
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.
- Oscar Cubo Medina — @ocubom — https://ocubom.page
See also the list of contributors who participated in this project.
Distributed under the MIT License. See LICENSE for more information.