ocubom/html-bundle

This package is abandoned and no longer maintained. The author suggests using the ocubom/twig-extra-bundle package instead.

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

v1.0.2 2022-12-17 10:29 UTC

This package is auto-updated.

Last update: 2022-12-31 12:55:32 UTC


README

A Symfony bundle to integrate several custom utilities for HTML manipulation

Contributors Forks Stargazers Issues License

Version CI Code Quality Coverage

Explore the docs »

Report Bug · Request Feature

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".

  1. Fork the Project.
  2. Create your Feature Branch (git checkout -b feature/your-feature).
  3. Commit your Changes (git commit -m 'Add your-feature').
  4. Push to the Branch (git push origin feature/your-feature).
  5. Open a Pull Request.

Authorship

See also the list of contributors who participated in this project.

License

Distributed under the MIT License. See LICENSE for more information.