Answers.Body: <p>I figured it out. I will paste it here in case someone needs it:</p>
  
  <pre><code>$html = Craft::$app-&gt;getView()-&gt;renderTemplate('template.twig', $variables);
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-03-28T16:28:53.213Z
Answers.LastActivityDate: 2019-03-28T16:28:53.213Z
Answers.UserDisplayName: Ded Nolyxeux
Body: <p>I'm getting started with plugin/module development. I want to get the template file, pass some variables to it, and get rendered HTML of that template into a string variable. </p>
  
  <p>How do I do that?</p>
  
Tags: <plugin-development>
Title: Get HTML of rendered template inside module
ThreadText: # Get HTML of rendered template inside module
  
  (Asked by: username_0 on 2019-03-27)
  
  I'm getting started with plugin/module development. I want to get the template file, pass some variables to it, and get rendered HTML of that template into a string variable.
  
  How do I do that?
  
  **Tags:** plugin-development
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2019-03-28. Score: 2
  
  I figured it out. I will paste it here in case someone needs it:
  
  ```
  $html = Craft::$app->getView()->renderTemplate('template.twig', $variables);
  
  ```
  
  
  ---
  
  