Skip to content

Commit

Permalink
Update options
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaohutai committed Aug 6, 2018
1 parent 64c6d72 commit ca381b5
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 13 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"proof-of-concept"
],
"require": {
"bolt/bolt": "^3.0"
"bolt/bolt": "^3.0",
"gajus/dindent": "^2.0"
},
"license": "MIT",
"authors": [
Expand Down
1 change: 1 addition & 0 deletions config/config.yml.dist
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
enabled: true
indentation_character: ' '
blocks: [ 'div' ]
inline: [ 'p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6' ]
Expand Down
15 changes: 4 additions & 11 deletions src/HtmlIndenterExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ]);
}
}

/**
Expand Down

0 comments on commit ca381b5

Please sign in to comment.