HTMLTemplate Action in following script

Does any one know how the HTMLTemplate action is accessible in a followed script action?

Or if it is not?

I know that I can use the script version of the HTMLTemplate and therefore replace the template action.

Just asking…

disclaimer

I am aware of the documentation.
I read it through and might have missed some important footnote.
Or a implicit note on the right side of my iPhone screen…

Do you mean the “Define Template Tag” action step, the “HTML Preview” action step, or something else?

There are lots of actions that could be related to “HTML Template”, but my guess is you are actually referring to an action step within a single action.

Yeah. That was written to vage.

I do have a multistep action:

  1. script action
  2. HTML Preview / HTML Template
  3. script action

Will the data of the 2. step will be accessible in the 3. step?

The advanced preview docs have examples showing how to pass data.

Thanks I did not find that during my search.

It is a great resource but does not state if the generated HTML can be retried from the HTMLPreview. The goal would be to get the result completely with template tags expanded.

This is only a minor issue though I would use the script like so:

scripting solution

expand template tags and preview HTML:

let html_template = "<html><body>[[title]]:<br/><br/>[[string]] <br/>[[ssst]] [[object]] </body></html><br>[[script]][[br]]let links = [[object]] [[/script]]"
let html = draft.processTemplate(html_template);

let preview = HTMLPreview.create();
if (preview.show(html)) {
  // continue button was pressed
}
else {
  // cancel button was pressed
}

You could do it with template tags as well, just remember they are strings. You are constructing an HTML string (with embedded JS, whatever), as long as your template tags output the correct script strings, they will work fine - but there’s no automatic conversion going on between types.

1 Like

And is your script action invoking mdpre - before the HTML Preview action?

Not yet.
I only tried to adapt nomnoml.

  1. Setup URLs for boxes (I tried to store an object/dict in a template tag)
  2. Add more custom template tags for the HTML document
  3. Generate the view in HTML Preview
  4. Test the onClick callback during HTML Preview

On iOS I got as many alert shown as I suggested.
On macOS only on alert was displayed after that no more interactions (no second alert).

I have to investigate fitters on this topic for example saving the HTML document locally and opening it it a browser window.