Since the content of the tiddler is overwritten, wouldn’t it be more appropriate to see this feature as a create a new tiddler from a template and therefore to be a button in the page toolbar?
Creating tiddler from a template exists in the core itself. For example, creating a Journal. Also in Mehregan Edition, you have shortcuts and also sidebar button to do so.
The idea here is to apply a template to a tiddler.
The issue of overwriting tiddler can be handled with extending the current codes. I like to have inputs from users to see how best handle this part,
Thanks @Mohammad this is a useful addition, however I would urge people not to have large templates, because they result in textural bloat, that is repeating content that would be delivered once via a view template, only updated in one place after initial use, and consuming less total bytes.
Certainly. But it does look as though this tool can be used to define (and prepopulate) other fields as well as, or perhaps instead of, the text field.
I find this technique to fall most of the way to the right on a scale of sophistication:
+---------------------------------------------------------------------------------------------------+
| New Tiddler ______________ Cloning and ______________ Using a _______X______ Using an Entry Form |
| every time Modifying ViewTemplate | plus a ViewTemplate |
| / |
| This technique --' |
+---------------------------------------------------------------------------------------------------+
@TW_Tones
Even using viewtemplate, you have to create fields and tag different tiddlers with different set of tags! So, applying template is handy. Not all tiddlers have repeated text!
I should also note, in my workflow, I use important data in tags, title and text where TW can easily find them. Searching in fields always is harder than the standard way of searching in title, tags, text.
@Mohammad I am not questioning the value, this is a useful tool, but with such power comes a responsibility, I am pointing out there are ways to use “content templating” that result in redundant and wasteful text, and there seems to be a tendency for new users to do this. It can also be manually intensive to reverse the consquences.
This is true but easy to address, and sometimes useful.
If caption and description fields were used as metadata for templates, they could not be at the same time used as values for newly created tiddlers based on these templates.
One solution for this problem could be to split templates metadata in dedicated “sidecart” tiddlers:
Template sidecart (template metadata):
caption: My fancy template
description: Use this as a tiddler prettyfier
tags: $:/tags/Template
target: myTemplate
title: myTemplate/sidecart
Template (template raw data):
caption: caption for new tiddlers
description: description for new tiddlers
tags: UserTag1 UserTag2
title: myTemplate
Here goes the template text...
Then in @Mohammad 's code the applied template title would be extracted from the sidecart target field.
I modified example templates and added sidecart template tiddlers in order to split data/metadata, and modified $:/kookma/ui/Buttons/apply-templates code to reflect these changes.
Now that you clone original tiddler before applying the template, do you think it could be useful to add a “revert to original” option to the “Apply Template” button?
If the temporary clone tiddler title used the qualify macro with a $:/temp/ prefix, then I believe clone title would be unique enough to allow content restoration.
I assume the current code do this. If you do not save the tiddler and click cancel operation, the original tiddler will be retrieved. But if you save the tiddler, the change will be permanent.
Oh, I didn’t thought about that. So let’s keep the tpl-caption.
And I find in my template-list plugin, I didn’t use these fields.
@Mohammad I also suggest using $:/tags/TextEditor/Template tag (I’m using this in my plugin, which simillar to $:/tags/TextEditor/Snippet in the core, I always check for core’s usage for potential compatability), means they are single tiddler template. This leave possibility for multi-tiddler template, like those paid Notion templates
Look at how Notion users gain money with 49$ each template. This is how TW could have achieved.
I’ll update my plugin to follow this standard, I find add some metadata and not copy them to final tiddler is useful, like add url for source of inspiration.
But I still think we should use $:/tags/TextEditor/Template tag, instead of $:/tags/Template, so Notion style multi-tiddler template can use it, what do you think?