Using BBEdit’s Update Document Feature

Posted April 2nd @ 9:50 am  |  Filed in: General Code, OS X    

I’m becoming a hardcore Textmate guy when it comes to getting things done. When I open any other Texteditor, it’s using Emacs or Vim, and I’m just messing around (and discovering that Textmate has many of their cool features), and wondering when, when!?, is Textmate 2.0 coming out? *sigh* I can’t wait to see the new features.

Anyways, there is one thing I keep using BBEdit for - repetitive HTML newsletter design. With all the inline styles you have to do with newsletters, any sort of automation setup pays off.

click for full sizeBasically, you take 2 files, one with your variable declarations and one with your HTML template, and run the Update -> Document command to spit out the completed HTML file. Here’s how it works - I’ll run through the step I take to do the ChronicBabe.com newsletter. In this example, I’m creating this newsletter: How to get out of a rut.

  1. I receive the newsletter’s content in an MS Word document. I copy the entire thing into a new BBEdit window, and clean up all the MS Word gobbly-gook with TextSoap.
  2. I open my variables file in a new window, and just drag and drop the appropriate text into the variables. Note that this file needs to be formatted a certain way. At the top we need:
    <!-- #bbinclude "template.html"

    where “template.html” is the relative path to our HTML template, using the same folder your variables are in makes it easy. Our variables then look like:

    #h1_text# = "put your header text here"

    And at the very end of the file we need:

    -->
    <!-- end bbinclude -->

    Note that you cannot have quotes inside the variables! You need to either escape them with a backslash (which means un-escaping the finished file), or use their HTML entity. This is why I separate as many links from the content as possible, like in the Amazon and Fab 5 Sites sections of this particular newsletter.

  3. click for full sizeWhen you’re all done, select Markup -> Update -> Document. If all goes well, your variable file will “suck in” the template file, complete with the variables. If it looks like it stopped short, that likely means you have a stray quote somewhere. Locate it, Undo the update, and try again.
  4. Though variables are all commented out, I usually clean everything up and cut/paste the final HTML, sans variable declarations, into a clean file.
  5. From there, I save and reopen the newly minted HTML newsletter in Textmate for further tweaking and image placements. Often this is just placing text links, as my client often provides them as “… check out this site (link to: www.somesite.com).” Textmate makes this trivially easy with the hyperlink helper function, and I hardly touch the mouse, which is how I like it.
  6. From there, the newsletter is ready to go!

For monthly newsletter service, I typically charge a flat fee to keep billing easier. This saved me so much time that I actually lowered the fee for my client. Call me crazy, but when you run a referral based business, it rewards you with more business. Cheers.

No Comments Yet

You can be the first to comment!

Leave a comment

OpenID Login

Standard Login

Options:

Size

Colors