Answers.Body: <p>Your controller looks ok, though I would clean it up a bit and use more expressive variable names to reduce the surface area for bugs:</p>
  <pre class="lang-php prettyprint-override"><code>$templateVariables = [
      'status' =&gt; true,
      'message' =&gt; 'Sucess'
  ];
  return $this-&gt;renderTemplate(
      'craft-handle/test.twig',
      $templateVariables
  );
  </code></pre>
  <p>Now you will have access to the variables <code>status</code> and <code>message</code> in your <code>test.twig</code>:</p>
  <pre><code>{# templates/craft-handle/test.twig #}
  
  &lt;h1&gt;{{ status ? 'Success' : 'Failure' }}&lt;/h1&gt;
  &lt;p&gt;Message: {{ message }}&lt;/p&gt;
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-09-24T10:02:27.023Z
Answers.Text: It's working. Thanks for the quick reply.
Answers.UserDisplayName: Priya Goud
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-09-24T09:47:35.377Z
Answers.LastActivityDate: 2021-09-24T09:47:35.377Z
Answers.UserDisplayName: MoritzLost
Body: <p>In the plugin, I created a form and after the process, return the below response from the controller and redirect to the template. I am trying to print the response to the template but it's not working.</p>
  <pre><code>$multi_res  =array(&quot;status&quot;=&gt;True, &quot;message&quot;=&gt;'Sucess');
  return $this-&gt;renderTemplate(
        'craft-handle/test.twig',
        $multi_res            
       );
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-09-24T09:15:07.133Z
Comments.Text: Can you post your twig template? The controller code looks correct, so the issue is most likely in the template. Are you getting any errors?
Comments.UserDisplayName: MoritzLost
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-09-24T09:36:18.190Z
Comments.Text: I want to print the response on test.twig template but I am not sure how to print it. I need help to print responses.
Comments.UserDisplayName: Priya Goud
Tags: <craft3><plugin-development><twigextension>
Title: How to display controller response on twig template?
ThreadText: # How to display controller response on twig template?
  
  (Asked by: username_0 on 2021-09-24)
  
  In the plugin, I created a form and after the process, return the below response from the controller and redirect to the template. I am trying to print the response to the template but it's not working.
  
  ```
  $multi_res  =array("status"=>True, "message"=>'Sucess');
  return $this->renderTemplate(
        'craft-handle/test.twig',
        $multi_res            
       );
  
  ```
  
  **Tags:** craft3, plugin-development, twigextension
  
  > **Comments:**
  > **username_1**: Can you post your twig template? The controller code looks correct, so the issue is most likely in the template. Are you getting any errors?  
  > **username_0**: I want to print the response on test.twig template but I am not sure how to print it. I need help to print responses.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2021-09-24. Score: 1 | Accepted answer
  
  Your controller looks ok, though I would clean it up a bit and use more expressive variable names to reduce the surface area for bugs:
  
  ```php
  $templateVariables = [
      'status' => true,
      'message' => 'Sucess'
  ];
  return $this->renderTemplate(
      'craft-handle/test.twig',
      $templateVariables
  );
  
  ```
  
  Now you will have access to the variables `status` and `message` in your `test.twig`:
  
  ```
  {# templates/craft-handle/test.twig #}
  
  <h1>{{ status ? 'Success' : 'Failure' }}</h1>
  <p>Message: {{ message }}</p>
  
  ```
  
  > **Comments:**
  > **username_0**: It's working. Thanks for the quick reply.  
  
  ---
  
  