问题
According to https://stackoverflow.com/a/19554524/6450661, standard Twig provides a method via {{ app.request }}
that I can use to pass $_GET, $_POST, $_SESSION, etc. variables.
Using Timber, is there a similar method? I can use Timber\URLHelper's get_params() method to access $_GET variables, but that's about all I can seem to find.
回答1:
I looked through the source code and at least found the answer for $_GET and $_POST variables, so here it is if it helps anyone.
To access $_POST variables, use this:
{{ request.post.name_of_var }}
To access $_GET variables, use this:
{{ request.get.name_of_var }}
来源:https://stackoverflow.com/questions/56810653/passing-php-global-variables-via-twig-timber