Answers.Body: <p>If you want to render a template in Craft 3 you can do</p>
  
  <pre><code>$html = Craft::$app-&gt;getView()-&gt;renderTemplate('path/to/template', $variables);
  </code></pre>
  
  <p>If you want to return/render a template within your Controller action you can do</p>
  
  <pre><code>return $this-&gt;renderTemplate('path/to/template', $variables);
  </code></pre>
  
  <p>If you want to render a plugin template you'll need to attach your plugins handle to your path</p>
  
  <pre><code> 'plugin-handle/path/to/template'
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-06-16T17:34:27.587Z
Answers.LastActivityDate: 2018-06-16T17:34:27.587Z
Answers.UserDisplayName: Robin Schambach
Body: <p>Coming to Craft after years with EE, I feel like a newbie again.</p>
  
  <p>I painfully managed to built and install a basic plugin for craft3 with composer, (with a little help from the docs and <a href="https://nystudio107.com/blog/so-you-wanna-make-a-craft-3-plugin" rel="nofollow noreferrer">NYstudio107's tutorial</a>).</p>
  
  <p>For now, the plugin does nothing, and to keep going, I would need to understand how to translate a pattern commonly used in EE.
  Get some data from a template, process it and return it.</p>
  
  <p>Get tag data and parameters</p>
  
  <pre><code>$data_to_process = ee()-&gt;TMPL-&gt;tagdata;
  $process_param = ee()-&gt;TMPL-&gt;fetch_param('parameter');
  </code></pre>
  
  <p>Output content to template</p>
  
  <pre><code>ee()-&gt;return_data = $processed_data;
  </code></pre>
  
  <p>Ho do you do such things in craft ?</p>
  
Tags: <plugin-development><craft3>
Title: Plugin development : from ExpressionEngine to Craft
ThreadText: # Plugin development : from ExpressionEngine to Craft
  
  (Asked by: username_0 on 2018-06-16)
  
  Coming to Craft after years with EE, I feel like a newbie again.
  
  I painfully managed to built and install a basic plugin for craft3 with composer, (with a little help from the docs and [NYstudio107's tutorial](https://nystudio107.com/blog/so-you-wanna-make-a-craft-3-plugin)).
  
  For now, the plugin does nothing, and to keep going, I would need to understand how to translate a pattern commonly used in EE.
  Get some data from a template, process it and return it.
  
  Get tag data and parameters
  
  ```
  $data_to_process = ee()->TMPL->tagdata;
  $process_param = ee()->TMPL->fetch_param('parameter');
  
  ```
  
  Output content to template
  
  ```
  ee()->return_data = $processed_data;
  
  ```
  
  Ho do you do such things in craft ?
  
  **Tags:** plugin-development, craft3
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-06-16. Score: 1
  
  If you want to render a template in Craft 3 you can do
  
  ```
  $html = Craft::$app->getView()->renderTemplate('path/to/template', $variables);
  
  ```
  
  If you want to return/render a template within your Controller action you can do
  
  ```
  return $this->renderTemplate('path/to/template', $variables);
  
  ```
  
  If you want to render a plugin template you'll need to attach your plugins handle to your path
  
  ```
   'plugin-handle/path/to/template'
  
  ```
  
  
  ---
  
  