0

How can I print a variable in the node template?

For example, if it's a variable of content, we can print it with the following code.

{{ content.field_name }}

If I have a {{ counter }} variable, how do I display it with Twig?

2
  • 1
    Welcome to Drupal Answers! Your question is not clear: You already know to use {{ counter }}, so what exactly don't you understand?
    – avpaderno
    Commented Nov 23, 2016 at 9:41
  • Where did counter come from?
    – No Sssweat
    Commented Nov 24, 2016 at 1:04

1 Answer 1

1

If it's a variable that came from a hook_preprocess_node, you can just print it in your twig template as you wrote it in your example:

{{ variable_name }}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.