Question: tm-download-file how to add fields on the fly?

Is it possible to add some fields to the downloaded file (tiddler) on the fly?

I am using the tm-download-file like

<$action-sendmessage $message="tm-download-file" 
 $param="$:/core/templates/exporters/JsonFile" 
exportFilter=<<exportFilter>> 
filename=<<exportButtonFilename  "basket.json" >> />

I like to add a description field with some value to the exported JSON tiddler (file)!

How can I do that?

Maybe I’m not understanding your context enough, but…

Since you’re processing actions at that point, can’t you just…

<$action-setfield $tiddler... $field=description $value... />

I like to add a description field with some value to the exported JSON tiddler (file)!

The core does this using the currently undocumented <$jsontiddler> widget. In the following example:

  • the “tiddler” attribute is the tiddler to output
  • “escapeUnsafeScriptChars” is specific to embedding JSON within a script tag
  • the attributes starting with $ are added to the JSON output without affecting the underlying tiddler
1 Like

Yes, that’s true. And the mechanism for adding new fields also only works for fields without spaces. That’s all fine for the usage in the core (and I think most typical usages), but might would indeed need further work if excluding or overriding field names containing a space was required.