<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>

CC BY-SA 4.0
2019-03-28T16:28:53.213Z
2019-03-28T16:28:53.213Z
Ded Nolyxeux
<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>

<plugin-development>
Get HTML of rendered template inside module
# 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);


---

