Dynamic Rubber Stamps

This is a proof-of-concept. It makes a small hack to the Stamp tool that allows dynamic information to be inserted. That is, rather than just static snippets, you can have snippets that are interpreted on the fly. This is useful, for instance, if you want to stamp the actual time and date, and not just a macro that can display the (changing) time. This is useful for logging times for various activities.

This only works with 5.3.0 and above, because it uses functions and the new substitute filter operator.

There are two example snippets included (and some sample data). One snippet produces a timestamp. The other produces a checklist formatted for markdown based on items tagged “ToDo”. Why markdown? Sometimes I’ll make lists in TW, but want to transfer the list to something like Simple Notes that can give you a live checklist.

The markdown snippet looks like:

### Check List
${[check.list[ToDo]]}$

You can see that you can change the tag to create whatever list you need. You can also modify the function for the date stamp to change the date format.

Dynamic snippets have a field “substitute” that needs to contain some value. I’m vaguely thinking that in the future they might actually contain values to be passed back to the stamp. There are some other limitations (like your titles shouldn’t contain “()” for the checklist), that can be fixed later on if people are interested.

As always, make a backup if you try this. There is no JS modifications, so it should be pretty safe, but you never know.

snippet-hack-release-2023-07-15-1826.json (3.2 KB)

Tab Snippet

Here’s a snippet you can use when you need a tab character.

Snippet - Tab Char-dynamic.json (248 Bytes)

7 Likes

This solves a traditional problem, having dynamic stamp in TW. Thank you @Mark_S

I’ve made the top post into a wiki so people can add their own useful snippets. Also added a tab character snippet, for those times you want to insert a tab.

3 Likes

@Mark_S very impressive, and useful. I see how you have used the substitute operator to “scan the snippet text”. If I understand this correctly the snippet tiddler requires the field substitute=yes (or any value).

  • If this flag or another method is chosen it seems a valid addition to the core.

You are using this in a way not implied by the documentation that only gives examples using strings inside a filter.

  • This suggests we need to improve the documentation and provide an example of this use.

However given your enlightened use of substitute, I can see other places it may be very useful, although dynamic stamp is substantial on its own.

  • This could be used on new tiddler text to apply variables and filter results at creation time. This is not limited to text, it can be used for field values as well.
  • Finally, we can have a true template for text that has place holders for dynamic values, thus look more like traditional mail merge and other templates. But also allowing sophisticated filters.

My mind is wandering towards other possibilities, thanks for the inspiration and insight.

Post script

If we are to press for a change to the core, there are other features we could introduce, changin the same tiddler, including a display-filter that determines when a stamp appears in the stamp list, thus a markdown stamp would only be visible in a markdown tiddler etc…