I have the following code in node.html.twig.
{{ dump(user) }}
I get this output.
object(Drupal\Core\Session\AccountProxy)#523 (4) {
["account":protected]=>
object(Drupal\Core\Session\UserSession)#91 (16) {
["uid":protected]=>
string(1) "1"
["roles":protected]=>
array(2) {
[0]=>
string(13) "authenticated"
[1]=>
string(13) "administrator"
}
["access":protected]=>
string(10) "1513942493"
["name"]=>
string(5) "admin"
["preferred_langcode":protected]=>
string(2) "en"
["preferred_admin_langcode":protected]=>
NULL
["mail":protected]=>
string(18) "[email protected]"
["timezone":protected]=>
string(13) "Europe/Berlin"
["langcode"]=>
string(2) "en"
["pass"]=>
string(55) "$S$E7IRVipuFHHectBpj8GkGZGPHlFWNQKG9ydDoRpwBDcCbzklpVaj"
["status"]=>
string(1) "1"
["created"]=>
string(10) "1513920795"
I want to render value of ["created"]=>string(10) "1513920795"
and ["uid":protected]=>string(1) "1"
. What is the syntax or code to output them from the template?
{{ variable }}
or{{ content.variable }}
respectively. The easiest way to inspect variables is to use xdebug and inspect them with a preprocess node hook in the themes.theme
file, or use Twig XDebug to set a breakpoint in the twig template.