[SMARTY] Parsing a string as template

Maximillian Schwanekamp <[email protected]>
Newsgroups gmane.comp.php.smarty.general
Message-ID <[email protected]>
Hello all,

The application I'm working on occasionally produces email (e.g. new
user welcome, password reminder, etc).  I use Smarty templates for the
body of the message.  I'm wondering if it's possible to use a smarty
instance to parse a given string (the email subject line) as a template,
without a pre-existing template file and without going to the lengths
required for setting an alternate template resource.  Right now, I have
the subject line in a capture block within the template itself, and then
define I have a public get method to return the $smarty->_tpl_vars array
value from the capture.  Is there a better way? 

For clarification, here's a snippet from how I do it presently:
message.tpl excerpt:
{strip}
{capture assign="subject"}
Here is your {$site_name} login info, {$first_name}
{/capture}
{/strip}
Dear {$first_name}...etc etc

login.php excerpt:
/* Template class extends Smarty to autoset template dirs, and has
method to get the _tpl_vars value */
$smarty =& new Template;
$mailer =& new Mailer;
$smarty->assign('site_name','Example Site');
$smarty->assign('first_name','Max');
$mailer->Body = $smarty->fetch('message.tpl');
$mailer->Subject = $smarty->get_template_var('subject'); // call to the
custom method
$sent = $mailer->Send();

I'm feeling like this has got to be a road that has been travelled
before.  Manuel Lemos' MimeMessage class (mentioned in the Smarty wiki)
has an example for using Smarty templates for the message body, but not
the subject line, AFAIK.  Any suggestions would be appreciated.  Thanks
in advance!

-- 
Maximillian Von Schwanekamp
http://www.neptunewebworks.com/

-- 
Smarty General Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.