Setting spaceless in presenter

materix
Backer | 83
+
0
-

I wrap all my @layout-latte-files with {spaceless}-tags. But while developing I like not to have spaceless enabled.

Is it possible to enable spaceless in a template from the presenter-class (e.g. using debug-mode), so I do not have to manually modify the latte-template-files?

Michalek
Member | 211
+
+1
-

Maybe you can just rewrite spaceless while developing?

function beforeRender() {
    if (\Tracy\Debugger::isEnabled() === true) {
        $this->template->addFilter('spaceless', fn(string $s) => $s); // disable spaceless
    }
}
Marek Bartoš
Nette Blogger | 1275
+
+3
-
{if \Tracy\Debugger::$productionMode === true}
	{include foo|spaceless}
{else}
	{include foo}
{/if}

But probably not worth it. You will break space-sensitive code (like <pre><code> tags) and webserver should do fairly better job compressing the page anyway.

Last edited by Marek Bartoš (2024-04-14 13:52)