Parse a String dynamic in Twig I would like to output a field from a variable like this:

{% set foo = "entry.title" %}
{{ foo }}


In this example it outputs "entry.title".

Other Example like this:

{% set prefixVar = "en_" %}
{% set foo = "entry."~ prefixVar ~"title" %}
{{ foo }}


In this example it outputs "entry.en_title". Is it possible in Twig to get the content of the entry field instead of the string?
Surrounding text in quotes declares it as a string, whereas no quotes will assume variables. If you remove the quotes, you should get what you need.

{% set foo = entry.title %}
{{ foo }}


EDIT:


  I realy want to render a string and get the fieldvalue. A other example would be like this: I have a Variable with a Prefix and now i would like to output a field with this prefix: {% set foo = "entry."~ prefixVar ~ "_fieldName" %} {{ foo }}. Is that possible?


I am not sure if that's possible when accessing keys through the dot formatting (ie. array.keyname)

But you could tweak the approach a little bit, to access dynamic keys in entry using the attribute() twig function, such as:

{% set foo = attribute(entry, prefixVar~"_fieldName") %}