Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// Drafts 4 script step to create custom tags
// using the a line or a default value if that line is empty or missing
// split draft into an array of lines
var lines = draft.content.split('\n');
// reusable function to define tag based on line or default string
function createLineTag(lineNumber,default) {
var tagName = "line"+(lineNumber+1).toString();
if(lines[lineNumber] && lines[lineNumber].length > 0) {
draft.defineTag(tagName, lines[lineNumber]);
}
else {
draft.defineTag(tagName, default);
}
}
// call for each line you want a tag for...
createLineTag(0, "first line default string");
createLineTag(1, "second line default string");
// templates in steps after this script step in an action
// can use [[line1]], [[line2]] tags to get line or default values.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.