1

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?

1

I figured it out. I will paste it here in case someone needs it:

$html = Craft::$app->getView()->renderTemplate('template.twig', $variables);
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.