Close enough. I instantiate a Model-Glue GenericCollection (which is how Unity implements its state container) and use the setValue() method to populate it with the data the view needs. I then call renderView() on the instantiated ViewRenderer, and pass it the state container, the view collection, and the path to the view template.
The viewCollection is a required argument of renderView() to support view stacking, but since in my case I'm not performing any view stacking my viewCollection is empty. If I later find myself needing to send different types of emails and I wanted to create a common template view, it would be easy enough to add the rendered view to my viewCollection and then render the template view. Of course, the further I go down that road the further it feels like I'm duplicating Model-Glue's functionality (even if I am reusing MG's CFCs). -- Dennis On Mon, Aug 3, 2009 at 11:40 AM, James Allen <[email protected]>wrote: > Oooh I like the sound of that – very inventive. > > > > So your HTML templates work very much like views with data passed into them > via the ViewCollection? > > > > --- > > James Allen > > E: [email protected] > > Blog: http://jamesallen.name > > Twitter: @CFJamesAllen (Coldfusion / Web development) > > Twitter: @jamesallenuk (General) > > > > *From:* [email protected] [mailto:[email protected]] *On > Behalf Of *Dennis Clark > *Sent:* 03 August 2009 16:27 > *To:* [email protected] > *Subject:* [Model-Glue] Re: sending emails from MG. > > > > I took a similar approach with HTML templates, but instead of rolling my > own template processing I had my "controller" code create its own > ViewCollection and ViewRenderer instances using the internal Model-Glue > CFCs. > > I know this is an undocumented and unsupported use of those CFCs but using > them saved me a lot of time up front, and even if a future update of MG > broke the code I can't imagine it would be too difficult to fix. > > -- Dennis > > On Sun, Aug 2, 2009 at 12:27 PM, James Allen <[email protected]> > wrote: > > > I use HTML templates that do sit within my views folder but they are read > in > via my EmailService (inside the email bean) and then sent out that way. > > I like this as it means anyone could edit the templates (I use placeholders > for replaceable content). Also keeps them nicely located. I recently had to > send them all to a colleague who needed to make text changes but is not > technical at all. > > Works well. > > --- > James Allen > E: [email protected] > Blog: http://jamesallen.name > Twitter: @CFJamesAllen (Coldfusion / Web development) > Twitter: @jamesallenuk (General) > > > > -----Original Message----- > From: [email protected] [mailto:[email protected]] On > Behalf Of Sir Rawlins > Sent: 01 August 2009 16:03 > To: model-glue > Subject: [Model-Glue] sending emails from MG. > > > Hello Guys, > > I wanted to get your opinions on how you distribute emails from within > your MG apps. I'm sure I remember reading a thread a while back about > how some people consider an email a 'view' and so would render the > HTML as a view, this I guess was called from the model using an cfhttp > call or something? and then distributed. > > I myself have always just used a cfsavecontent tag in the model which > saves the HTML into a variable, this is then passed to a mailerservice > which contains all my POP/SMTP settings and this actually does the job > of sending the email. > > I wanted to see what others were doing as for me having the HTML mixed > in the model always felt a little messy to me. > > Cheers guys, appreciate your thoughts. > > Rob > > > > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "model-glue" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/model-glue?hl=en For more about Model-Glue, check http://www.model-glue.com . -~----------~----~----~----~------~----~------~--~---
