TextExpander.appendOutput() function is a way to incrementally build the return results. Just use
TextExpander.appendOutput(newOutput) and it’s added to the output results. The final output of the script is what will be inserted when the snippet is triggered.
You can get the abbreviation the script was triggered with using
TextExpander.triggeringAbbreviation, and the Bundle ID of the application the snippet was triggered in using
TextExpander.expansionContext. These allow you to build logic that provides different responses based on these variables, potentially allowing snippets code to be re-used. For example, you could build one snippet that handled five different abbreviations, then nest it into five snippets. Each snippet would pass its own abbreviation to a case statement in the main script, and perform actions without having to rewrite the script five times.
Filled values are available in the
TextExpander.filledValues object, with keys based on the field name. If you have a fill-in named “Format”, you can retrieve its value using
%filltop% placeholder in the script to have the fill-in popup show only the options without displaying the entire script. That’s a very cool addition that I’ll be incorporating across a lot of the TE-Tools.
strftime library, which it nests into snippets for each day of the week1. Then you can use
nd.tue to insert the date for the next Tuesday in the calendar while typing.
nd.sat are available.
By default, dates are inserted in the format “Tuesday, June 02.” Each snippet has a line at the top like this:
var fmt = '%A, %B %d';
You can use
strtime format placeholders to change that to whatever is most appropriate for your locale/preference.
There’s also a snippet called
nd.x which offers a fill-in popup where you can select a day of the week and a date format. This one is an example for building your own and customizing.
You can also change the prefix, but the script requires the dot and then the 3-letter abbreviation for the weekday to be at the end of the abbreviation, e.g.
strftimeformat options are handy. ↩