1
votes

I execute a query and use that array for my twig template.

In my html:

{% for a in test%}

{{a.H}} {{a.2B}}<br> 

{% endfor %}

The column title H works fine, but when I try to use 2B I get this error:

Fatal error: Uncaught Twig_Error_Syntax: Unexpected token "name" of value "B" ("end of print statement" expected)

Why can't I start with a number? Is there a way to fix this without having to rename my database column names?

1

1 Answers

3
votes

According to a manual, this can be done as:

{{ attribute(a, '2B') }}

Also you can try:

{{ a['2B'] }}