Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTML Minify cache template #355

Open
dejurin opened this issue Jan 3, 2020 · 5 comments
Open

HTML Minify cache template #355

dejurin opened this issue Jan 3, 2020 · 5 comments

Comments

@dejurin
Copy link

dejurin commented Jan 3, 2020

How about make minify cache template
how like this https://github.com/jenstornell/tiny-html-minifier
possible?

@bobthecow
Copy link
Owner

Unfortunately it's probably not possible to solve in a general case. Mustache templates usually aren't valid HTML, so any minification will likely break :-/

@dejurin
Copy link
Author

dejurin commented Jan 4, 2020

Yesterday Im was experiment with this. This can be applied when the file is cached.
Снимок экрана 2020-01-04 в 19 22 39
It would be useful to influence the content before writing to the cache.

@bobthecow
Copy link
Owner

But if we allow that, it's non-deterministic and we can't guarantee the sanity of the cache.

If you want to do something like this, a good place to do it would probably be in a custom loader.

@dejurin
Copy link
Author

dejurin commented Jan 4, 2020

Thank u.

@dejurin
Copy link
Author

dejurin commented Jan 5, 2020

I was found a very simple solution.
In file Compiler.php change in
function text($text, $level)

$code = sprintf($this->prepare(self::TEXT, $level), $this->flushIndent(), var_export($text, true));

on

$code = sprintf($this->prepare(self::TEXT, $level), $this->flushIndent(), var_export(trim($text), true));

I added only trim function, and got minify html.

Снимок экрана 2020-01-05 в 14 54 26

PS: If this solution will be test OK, your will maybe added this option?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants