How to , is it possible to escape into and use raw php in Latte templates in Nette?

577 Views Asked by At

How to escape into and use raw php in Latte in Nette , eg can be used for debugging and other non standard, not best practices cases , logging and what not as its not standard, and rather in edge or debugging cases perhaps obviously

2

There are 2 best solutions below

0
On

For debugging purposes, there should be enought build-in {dump} or {dump $var} macro.

https://latte.nette.org/en/tags#toc-dump

5
On

In .latte (@layout.latte) files, one might use this syntax, a {php} or alias {do} latte tag to execute raw code inside it, like

{do Tracy\Debugger::barDump(get_defined_vars()); }

or any standard php like

{php var_dump([1,2,3,4]); echo "text"; }

https://latte.nette.org/en/tags#toc-do