File tree Expand file tree Collapse file tree 2 files changed +27
-2
lines changed Expand file tree Collapse file tree 2 files changed +27
-2
lines changed Original file line number Diff line number Diff line change @@ -144,6 +144,29 @@ After declaration you can use it like:
144144@endlogged
145145```
146146
147+ ### Hook
148+
149+ For use cases such as HTML minification, there's a custom hook for manipulating rendered HTML output:
150+
151+ ``` php
152+ # site/config/config.php
153+
154+ # For this example, we are using 'voku/html-min'
155+ use voku\helper\HtmlMin;
156+
157+ return [
158+ # ...
159+
160+ 'hooks' => [
161+ 'blade.render:after' => function (string $html): string {
162+ return (new HtmlMin())->minify($html);
163+ },
164+ ],
165+
166+ # ...
167+ ];
168+ ```
169+
147170## Credits
148171- [ Kirby Blade] ( https://github.com/afbora/kirby-blade ) by [ @afbora ] ( https://github.com/afbora )
149172- [ Torch] ( https://github.com/mattstauffer/Torch ) by [ @mattstauffer ] ( https://github.com/mattstauffer )
Original file line number Diff line number Diff line change @@ -34,10 +34,12 @@ public function render(array $data = []): string
3434 View::share ('pages ' , $ data ['pages ' ]);
3535 View::share ('page ' , $ data ['page ' ]);
3636
37- return View::file ($ this ->file (), $ data )->render ();
37+ $ html = View::file ($ this ->file (), $ data )->render ();
38+ } else {
39+ $ html = Tpl::load ($ this ->file (), $ data );
3840 }
3941
40- return Tpl:: load ( $ this -> file ( ), $ data );
42+ return App:: instance ()-> apply ( ' blade.render:after ' , compact ( ' html ' ), ' html ' );
4143 }
4244
4345 public function isBlade (): bool
You can’t perform that action at this time.
0 commit comments