diff --git a/README.md b/README.md index 4c9760b..77940d1 100644 --- a/README.md +++ b/README.md @@ -11,11 +11,19 @@ Before installing this extension. You need to install [gajus/dindent](https://gi composer require gajus/dindent ``` + ## Configuration Edit `app/config/extension/htmlindenter.xiaohutai.yml` for options: -- indentation_character`: Characters used for indentation. Defaults to 4 spaces. +- `enabled`: Whether to do anything at all or not. Defaults to `true`. +- `indentation_character`: Characters used for indentation. Defaults to 4 spaces. - `blocks`: List of HTML elements that will be output as blocks, such as `div`. - `inline`: List of HTML elements that will be output as inline, such as `span`. - `minify`: Overrides everything and minify HTML. Defaults to `false`. + + +## References + +- Based on [gajus/dindent](https://github.com/gajus/dindent). +- Based on [dactivo/Bolt.cm-HTML-minifier](https://github.com/dactivo/Bolt.cm-HTML-minifier). diff --git a/config/config.yml.dist b/config/config.yml.dist index ca5cf45..3ca9036 100644 --- a/config/config.yml.dist +++ b/config/config.yml.dist @@ -1,3 +1,4 @@ +enabled: true indentation_character: ' ' blocks: [ 'div' ] inline: [ 'p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6' ] diff --git a/src/HtmlIndenterExtension.php b/src/HtmlIndenterExtension.php index 4d92cfe..5becfde 100644 --- a/src/HtmlIndenterExtension.php +++ b/src/HtmlIndenterExtension.php @@ -19,18 +19,11 @@ class HtmlIndenterExtension extends SimpleExtension */ protected function subscribe(EventDispatcherInterface $dispatcher) { - /* - // Only when debug is OFF - $app = $this->getContainer(); - $config = $app['config']; - $debug = $config->get('general/debug'); - - if (! $debug) { - $dispatcher->addListener(KernelEvents::RESPONSE, [$this, 'onKernelResponse']); - } - //*/ + $config = $this->getConfig(); - $dispatcher->addListener(KernelEvents::RESPONSE, [ $this, 'onKernelResponse' ]); + if ($config['enabled']) { + $dispatcher->addListener(KernelEvents::RESPONSE, [ $this, 'onKernelResponse' ]); + } } /**