Question:

Passing Entry to craft()->templates->render()

Amara: 2 weeks ago

In looking over the docs on template rendering (http://buildwithcraft.com/docs/plugins/templates) 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.

Answer:
Austin: 2 weeks ago

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

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