How to export a tiddler using a script

Hi there

I want to be able to export a tiddler containing geospatial data as a .tid file using a script triggered by a button.

I have done some searching but cannot find any useful information.

Is this possible?

Cheers, Rob

Give this a try:

<$let  tid="SomeTiddler"
	format="$:/core/templates/exporters/TidFile"
	target={{{ [<tid>slugify[]] [<format>get[extension]] +[join[]] }}}>
<$button>
	export <<tid>> to .TID file
	<$action-sendmessage $message=tm-download-file
		$param=<<format>> exportFilter=<<tid>> filename=<<target>>/>
</$button>

Notes:

  • tid is the title of the tiddler you want to export
  • format is the TWCore shadow that defines the format of the file content to output when exporting a TID file
    • if you wanted to create a JSON file, you would use “$:/core/templates/exporters/JsonFile
  • target assembles the <tid> and <format> values to construct the desired filename
    • the tiddler title is “slugified” to remove or replace any characters that are not permitted in filenames
    • the appropriate filename extension (i.e. “.tid”) is defined by a field in the specified <format> tiddler
  • the tm-download-file message triggers the TWCore’s download saver for the specified tiddler, using the desired exporter format and target filename.

References:

enjoy,
-e