Showing an HTML preview from within JavaScript?

I’m aware of the HTML Preview action step, but is there a way to directly trigger an HTML preview window purely from JavaScript, i.e. within a Script step in an Action? I’d want to pass in the template string too.

There is not. Would be a good addition, I will make a note of it. For now you can set a custom template tag in your script, then use it in the HTML Preview step that follows it. Sample:

draft.setTemplateTag("content", myHtmlContentString);

Then in subsequent steps in the action the [[content]] tag is available. I’ve used this technique in this Markdown Preview with iCloud CSS example action, which loads a CSS file from iCloud Drive and inserts it in the preview. Great trick if you have a blog/site CSS file you edit elsewhere and want a preview that matches.

2 Likes