Menu icon Foundation
PlainText Emails

I'm wondering if there's any consideration for plaintext emails in the Foundation for Emails workflow. Emails that I send out have both a plaintext and HTML versions, so I need to be authoring both at the same time and I wouldn't mind using some of the panini templating features to provide the boilerplate text in these plaintext emails. It would be nice to be able to use the Foundation for Emails workflow for both. I've tried, but hit upon a snag. 

I first created a new layout called, "plaintext.html", that just has the

    {{>body}

tag, so that the HTML in the default.html layout isn't applied to any page that uses this layout. Then, I created a new file that uses this layout, by placing the following at the top of the file, like this,

 

    ---
    layout: plaintext
    ---

But, these files will be minified, when I run,

    npm run build

(as that's supposed to happen)

Is there a way to disable minification for specific pages that use specific layouts?

Also, the workflow seems to only look at files in ./src with a file ending of, ".html". I have to name all of my plaintext files  with this filename, which could be confusing.

 

plaintext

I'm wondering if there's any consideration for plaintext emails in the Foundation for Emails workflow. Emails that I send out have both a plaintext and HTML versions, so I need to be authoring both at the same time and I wouldn't mind using some of the panini templating features to provide the boilerplate text in these plaintext emails. It would be nice to be able to use the Foundation for Emails workflow for both. I've tried, but hit upon a snag. 

I first created a new layout called, "plaintext.html", that just has the

    {{>body}

tag, so that the HTML in the default.html layout isn't applied to any page that uses this layout. Then, I created a new file that uses this layout, by placing the following at the top of the file, like this,

 

    ---
    layout: plaintext
    ---

But, these files will be minified, when I run,

    npm run build

(as that's supposed to happen)

Is there a way to disable minification for specific pages that use specific layouts?

Also, the workflow seems to only look at files in ./src with a file ending of, ".html". I have to name all of my plaintext files  with this filename, which could be confusing.

 

Corey Schaaf about 3 years ago

I actually use a method for archiving at the page level that may work for you. It requires a little bit of setup, but works really well. It takes advantage of front matter, but requires you to install some additional packages via command line. There's a link to it below. 

Make sure you read the whole thread. I go into a step by step process towards the middle / end of the posting, but it would be beneficial for you to understand the context of the implementation before jumping right into it. 

https://github.com/zurb/foundation-emails/issues/470

 

 

 

Justin J about 3 years ago

I appreciate your response, Corey, I'll study this when  have time, Cheers,

David Diomede about 3 years ago

There is a great gulp module called html2txt. Works very well and has some nice customization options. I haven gotten it to work outside of foundation, but would love to get it to work with the inky workflow. If anyone manages to get it to work with inky I would love to see it.

Justin J about 3 years ago

I don't really want a html to plaintext utility - my app already has that.

 

What I want to do is to work with the HTML versions of my message as well as custom plaintext ones. I've found that just trying to strip out the HTML to make a plaintext version sometimes results in some ugly looking plaintext.

 

Here's what I've done - and it's super easy:

 

I've modified my gulpfile.babel.js and added a function for plaintext,

 

    function plaintext() {
      return gulp.src('src/pages/**/*.txt')
        .pipe(gulp.dest('dist'));
    }

All that does is copy my plaintext files from src/pages to /dist. I can get fancier, later.

 

Then I added that to my task list,

    gulp.task('build',
      gulp.series(clean, pages, plaintext, sass, images, inline));

And my watch list,  

     gulp.watch('src/pages/**/*.txt').on('change', gulp.series(plaintext));

And that's not too bad. I'd like to get some of the panini templating utilities happening, which I think isn't too hard to do now, now that I know how to prevent minifying.

 

(apologies if my terminology is a little off)

 

 

David Diomede about 3 years ago

This is good, I do agree that most incliners create some ugly, text. I have found html2txt to do a great job and provide a full range of options and create some a really clean text file, which would also allow you to use panni in the workflow. I just wish I could get html2txt to work in the foundation workflow. I've come close, but get the following errors:

The following tasks did not complete: default, build, <anonymous>
[13:33:22] Did you forget to signal async completion?
[]

Justin J about 3 years ago

Hi David, maybe you could start a new thread about your issue, then? They're free ;)