Skip to content

Commit b6c238e

Browse files
committed
minor #74 Minor improvements in README (HeahDude)
This PR was merged into the 3.0.x-dev branch. Discussion ---------- Minor improvements in README Commits ------- 95ac61e Minor improvements in README
2 parents d9d70e1 + 95ac61e commit b6c238e

File tree

1 file changed

+20
-50
lines changed

1 file changed

+20
-50
lines changed

README.md

Lines changed: 20 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -45,23 +45,29 @@ public function registerBundles()
4545

4646
## Configuration in Symfony 3
4747

48+
The configuration is the same as the following section, but the path should be
49+
`app/config.yml` instead.
50+
51+
## Configuration in Symfony 4 and up
52+
4853
If you do not explicitly configure this bundle, an HTMLPurifier service will be
4954
defined as `exercise_html_purifier.default`. This behavior is the same as if you
5055
had specified the following configuration:
5156

5257
```yaml
53-
# app/config.yml
58+
# config/packages/exercise_html_purifier.yaml
5459

5560
exercise_html_purifier:
5661
default_cache_serializer_path: '%kernel.cache_dir%/htmlpurifier'
5762
```
5863
59-
The `default` profile is special in that it is used as the configuration for the
60-
`exercise_html_purifier.default` service as well as the base configuration for
61-
other profiles you might define.
64+
The `default` profile is special, it is *always* defined and its configuration
65+
is inherited by all custom profiles.
66+
`exercise_html_purifier.default` is the default service using the base
67+
configuration.
6268

6369
```yaml
64-
# app/config.yml
70+
# config/packages/exercise_html_purifier.yaml
6571
6672
exercise_html_purifier:
6773
default_cache_serializer_path: '%kernel.cache_dir%/htmlpurifier'
@@ -81,45 +87,12 @@ option to suppress the default path.
8187

8288
[configuration documentation]: http://htmlpurifier.org/live/configdoc/plain.html
8389

84-
## Configuration in Symfony 4 and up
85-
86-
If you do not explicitly configure this bundle, an HTMLPurifier service will be
87-
defined as `exercise_html_purifier.default`. This behavior is the same as if you
88-
had specified the following configuration:
89-
90-
```yaml
91-
# config/packages/exercise_html_purifier.yaml
92-
93-
exercise_html_purifier:
94-
default_cache_serializer_path: '%kernel.cache_dir%/htmlpurifier'
95-
```
96-
97-
The `default` profile is special, it is *always* defined and its configuration
98-
is inherited by all custom profiles.
99-
`exercise_html_purifier.default` is the default service using the base
100-
configuration.
101-
102-
```yaml
103-
# config/packages/exercise_html_purifier.yaml
104-
105-
exercise_html_purifier:
106-
default_cache_serializer_path: 'tmp/htmlpurifier'
107-
html_profiles:
108-
default:
109-
config:
110-
Cache.SerializerPermissions: 777
111-
custom:
112-
config:
113-
Core.Encoding: 'ISO-8859-1'
114-
```
115-
11690
## Autowiring
11791

11892
By default type hinting `\HtmlPurifier` in your services will autowire
11993
the `exercise_html_purifier.default` service.
12094
To override it and use your own config as default autowired services just add
121-
this in you `app/config/services.yml` in you use symfony 3 or `config/services.yaml`
122-
if you use symfony 4:
95+
this configuration:
12396

12497
```yaml
12598
# config/services.yaml
@@ -131,7 +104,8 @@ services:
131104

132105
### Using a custom purifier class as default
133106

134-
If you want to use your own class as default purifier, define a new alias:
107+
If you want to use your own class as default purifier, define the new alias as
108+
below:
135109

136110
```yaml
137111
# config/services.yaml
@@ -141,10 +115,7 @@ services:
141115
exercise_html_purifier.default: '@App\Html\CustomHtmlPurifier'
142116
```
143117

144-
In such case, the custom purifier will use its own defined configuration,
145-
ignoring the bundle configuration.
146-
147-
### Argument binding
118+
### Argument binding (Symfony >= 4.4)
148119

149120
The bundle also leverages the alias argument binding for each profile. So the
150121
following config:
@@ -170,11 +141,10 @@ public function __construct(\HTMLPurifier $galleryPurifier) {} // gallery config
170141
## Form Type Extension
171142

172143
This bundles provides a form type extension for filtering form fields with
173-
HTMLPurifier. Purification is done during the PRE_SUBMIT event, which
174-
means that client data will be filtered before binding to the form.
144+
HTMLPurifier. Purification is done early during the PRE_SUBMIT event, which
145+
means that client data will be filtered before being bound to the form.
175146

176-
The following example demonstrates one possible way to integrate an HTMLPurifier
177-
transformer into a form by way of a custom field type:
147+
Two options are automatically available in all `TextType` based types:
178148

179149
```php
180150
<?php
@@ -213,7 +183,7 @@ This bundles registers a `purify` filter with Twig. Output from this filter is
213183
marked safe for HTML, much like Twig's built-in escapers. The filter may be used
214184
as follows:
215185

216-
``` jinja
186+
```twig
217187
{# Filters text's value through the "default" HTMLPurifier service #}
218188
{{ text|purify }}
219189
@@ -252,7 +222,7 @@ $builder
252222
// ...
253223
```
254224

255-
```jinja
225+
```twig
256226
{# in a template #}
257227
{{ html_string|purify('custom') }}
258228
```

0 commit comments

Comments
 (0)