Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

Best way to parse a text email template

Quote Reply
Best way to parse a text email template
 
I'm trying to parse a custom text email template but am having some trouble.

Inside the template I want to parse both 'Template' and 'Config' tags.

This is what I've currently got and what the problem is...

Code:
my $formatted_message = Links::user_page('email-pwdgenerator.txt', { %$CFG } );

This works ok but it reproduces the email with "=" scattered through it. See the example snippet below...

Quote:
You are receiving this notice because you're listed as a registered user
on= our web site at:

Maybe I'm using the wrong command - can anyone help?

Thanks

Regan.
Quote Reply
Re: [ryel01] Best way to parse a text email template In reply to
Try giving your email template an html extension and using Links::SiteHTML::display instead of Links::user_page
Quote Reply
Re: [afinlr] Best way to parse a text email template In reply to
I tried using "Links::SiteHTML::display" but it doesn't keep the formatting of the email.

When I run it through that it deletes an double returns.

So for eg. this message to you ends up looking like...


Code:
I tried using "Links::SiteHTML::display" but it doesn't keep the formatting of the email.
When I run it through that it deletes an double returns.
So for eg. this message to you ends up looking like...

no spaces.

?

regan.
Quote Reply
Re: [afinlr] Best way to parse a text email template In reply to
Found a funny bug.

When I save the template with Macintosh line breaks etc, it displays fine.

But if I use unix line breaks it crunches up together.

And if I upload a file with mac line breaks (which works fine) and then use the template editor to re-save the altered file, it crunches up together again.

I wonder if the Site::HTML parser ignores line breaks thinking that it's a html file going through it???

regan.
Quote Reply
Re: [ryel01] Best way to parse a text email template In reply to
When using Links::SiteHTML::display(), you need to be sure you have the "compress" part turned off in Setup > Build Options .. just something I have worked out over time :)

Hope that helps.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Best way to parse a text email template In reply to
In Reply To:
When using Links::SiteHTML::display(), you need to be sure you have the "compress" part turned off in Setup > Build Options ..

Hi Andy

Hmmm... doesn't really help because the code is going in a plugin! Wink

So I'll have no control over their build setup. Unimpressed

I thought using SiteHTML::display() may get rid of the nasty little "=" that keep appearing for no apparent reason.

regan.

Last edited by:

ryel01: Jul 7, 2004, 3:15 AM
Quote Reply
Re: [ryel01] Best way to parse a text email template In reply to
Try this;

Code:
my $msg = GT::Template->parse ( 'email-expired.txt', $hit, { compress => 0, root => $CFG->{admin_root_path} . '/templates/' . $CFG->{build_default_tpl} } );

...thats a direct take out from one of my plugins :)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Best way to parse a text email template In reply to
Ah you beat me to it by about 30 seconds! Smile

I scoured the .pm files to see how they work and came up with the same result. I also wanted to load in all the template globals too and found that in the same place. It's good - can even turn off the compression just for the email...

Code:
# load our template globals
$GLOBALS ||= GT::Config->load("$CFG->{admin_root_path}/templates/$CFG->{build_default_tpl}/globals.txt", { inheritance => 1, local => 1, cache => 1 });

my $gttobj = new GT::Template({
root => "$CFG->{admin_root_path}/templates/$CFG->{build_default_tpl}",
compress => 0
});

my $formatted_message = $gttobj->parse('email_pwdgen_txt.html', [$CFG, $GLOBALS]);

thanks for your help Andy!

regan.
Quote Reply
Re: [ryel01] Best way to parse a text email template In reply to
Maybe GT could shed some light on this. I've been working with Regan, and it seems that there is a bug in GT::Mail::Bulk ? It seems to be adding in = where lines are too long; as well as \n\r (or \n\n?) each line. So, instead of it showing up like;

Quote:
This is a test la la la foo bar yes, its a test =)
This is a test la la la foo bar yes, its a test =)
This is a test la la la foo bar yes, its a test =)
This is a test la la la foo bar yes, its a test =)

.. it comes out like;

Quote:
This is a test la la la foo bar yes, its a test =)


This is a test la la la foo bar yes, its a test =)


This is a test la la la foo bar yes, its a test =)


This is a test la la la foo bar yes, its a test =)

Anyone at GT got an ideas? Unsure

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!