In looking over the docs on template rendering I am not seeing a way to pass in an Entry model. It seems more efficient to pass in an existing model rather than have the template do another lookup. Something like:

$html = craft()->templates->render('path/to/template', $myEntry); 

Here is my use case. I want to use the craft template rendering engine to compose email messages.

1 Answer 1


You can just pass in the EntryModel straight to the view.

$html = craft()->templates->render('path/to/template', [ 'entry' => $entryModel ]); 
  • Okay, exactly what I was looking form. Can you tell me where you locate this info in the docs? I could not find it. Commented Sep 23, 2014 at 18:09
  • I didn't. I was looking for the same thing, and after a bit of fumbling about, looking at the rendering process etc., I simply tried passing it, and it worked. All the hard lifting is done by the models, I think. The render layer just show whatever is passed to it, so it's as simple as that. Commented Sep 23, 2014 at 18:11
  • This answer is spot on... It's not documented, but this is exactly the right way to do it. Twig templates will handle Model objects just as easily as the PHP does, basically treating it as an associative array.
    – Lindsey D
    Commented Sep 23, 2014 at 19:41

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.