<p>You can just pass in the EntryModel straight to the view.</p>

<pre><code>$html = craft()-&gt;templates-&gt;render('path/to/template', [ 'entry' =&gt; $entryModel ]); 
</code></pre>

CC BY-SA 3.0
2014-09-23T18:09:37.753Z
Okay, exactly what I was looking form. Can you tell me where you locate this info in the docs? I could not find it.
David A McInnis
CC BY-SA 3.0
2014-09-23T18:11:06.117Z
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.
Fred Carlsen
CC BY-SA 3.0
2014-09-23T19:41:03.617Z
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
CC BY-SA 3.0
2014-09-23T18:04:59.137Z
2014-09-23T18:04:59.137Z
Fred Carlsen
<p>In looking over the docs on <a href="http://buildwithcraft.com/docs/plugins/templates" rel="nofollow">template rendering</a> 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:</p>

<pre><code>$html = craft()-&gt;templates-&gt;render('path/to/template', $myEntry); 
</code></pre>

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

<templating><emails>
Passing Entry to craft()->templates->render()
# Passing Entry to craft()->templates->render()

(Asked by: username_0 on 2014-09-23)

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.

**Tags:** templating, emails

---

## 1 answers

### Answer by username_1 on 2014-09-23. Score: 10 | Accepted answer

You can just pass in the EntryModel straight to the view.
$html = craft()->templates->render('path/to/template', [ 'entry' => $entryModel ]);

> **Comments:**
> **username_0**: Okay, exactly what I was looking form. Can you tell me where you locate this info in the docs? I could not find it.  
> **username_1**: 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.  
> **username_2**: 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.  

---

