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

2

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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