Answers.Body: <p>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.</p>
  
  <pre><code>{% set foo = entry.title %}
  {{ foo }}
  </code></pre>
  
  <p>EDIT:</p>
  
  <blockquote>
    <p>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?</p>
  </blockquote>
  
  <p>I am not sure if that's possible when accessing keys through the dot formatting (ie. <code>array.keyname</code>)</p>
  
  <p>But you could tweak the approach a little bit, to access dynamic keys in <code>entry</code> using the <code>attribute()</code> twig function, such as:</p>
  
  <pre><code>{% set foo = attribute(entry, prefixVar~"_fieldName") %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-12-02T05:05:13.487Z
Answers.Text: 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?
Answers.UserDisplayName: Tom Bauer
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-12-02T05:20:08.197Z
Answers.Text: Edited my answer, hopefully that should accomplish what you need!
Answers.UserDisplayName: taylor
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-12-02T04:43:23.647Z
Answers.LastActivityDate: 2015-12-02T05:19:43.663Z
Answers.LastEditDate: 2015-12-02T05:19:43.663Z
Answers.UserDisplayName: taylor
Body: <p>I would like to output a field from a variable like this:</p>
  
  <pre><code>{% set foo = "entry.title" %}
  {{ foo }}
  </code></pre>
  
  <p>In this example it outputs "entry.title".</p>
  
  <p>Other Example like this:</p>
  
  <pre><code>{% set prefixVar = "en_" %}
  {% set foo = "entry."~ prefixVar ~"title" %}
  {{ foo }}
  </code></pre>
  
  <p>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?</p>
  
Tags: <templating>
Title: Parse a String dynamic in Twig
ThreadText: # Parse a String dynamic in Twig
  
  (Asked by: username_0 on 2015-12-02)
  
  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?
  
  **Tags:** templating
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2015-12-02. Score: 2 | Accepted answer
  
  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") %}
  
  ```
  
  > **Comments:**
  > **username_0**: 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?  
  > **username_1**: Edited my answer, hopefully that should accomplish what you need!  
  
  ---
  
  