Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

beforeCompile() or afterCompile()

Are there any events like that available? Couldn't find any info about that possibility in the documentation.

I am asking because I would like to remove all new lines from compiled template, obviously I wand to write readable .volt template but when it is compiled into php code and stored I want all new lines removed.

There is event in view that allows to modify the contents before it is rendered but that means the function would be running every time a page is accessed which is not needed in my case.

Any ideas how this could be done appreciated.



7.3k
$di->set('view', function() {

// Create Event Manager
        $eventsManager = new \Phalcon\Events\Manager();

// Create listener for "view" type
            $eventsManager->attach("view:afterRenderView", ...

Documentation requires full reading :)



1.4k
Accepted
answer

I am aware of that (and even mentioned it in my post) but that method doesn't allow to modify the compiled view content, only to modify the content before it is rendered (sent to browser)

I want my view file to be saved minified already and not minify it before every request.



7.3k

You can use any cache for this.