Assistance modifying the excise javascript to allow the transclude to use a template

Folks, The tiddler $:/core/modules/editor/operations/text/excise.js contains code to replace the excised content with a transclusion, link or macro. I am interested in modifying the transclusion process to use as a template the value (if any) found in $:/config/excise-template.

  • Do not know how to reference the content of a tiddler to do this;

Here is the operative code;

		case "transclude":
			operation.replacement = "{{" + operation.replacement+ "}}";
			break;

If a template is set in $:/config/excise-template then use it, thus giving the result;
{{tiddlername||templatename}} and if the template name is empty, it is Ok to return {{tiddlername||}} because this still works to simple transclude tiddlername without a template. {{tiddlername||}} also permits the user to insert a tamplatename if desired.

Can someone please tell me how to retrieve the content of $:/config/excise-template and place its value in the template name position?

Why?;

  • First it adds a feature I need to selectively excise to use different templates. For example when excising text from a tiddler and wanting to classify the excision as different types.
  • Second this additional hackability has no effect on normal operation of the excise tool unless a template value exists.

If it became a core change;

  • As a result it may form part of a core change request to enable this feature.
  • Perhaps when blank we could avoid including the || to be sure, but it does not seem necessary.
  • If implemented the only change is as requested AND an enhanced OR alternative $:/core/ui/EditorToolbar/excise-dropdown tiddler. This also does not display a template selection in the excise tool unless $:/config/excise-template exists.

If you do choose to accept this mission, here is a bundle of tiddlers that replace the excise dropdown and provides the config tiddler. So you can confirm it works.

excise-to-template.json (3.4 KB)

Try this:

		case "transclude":
            var suffix = "||" + this.wiki.getTiddlerText("$:/config/excise-template", "");
			operation.replacement = "{{" + operation.replacement + suffix + "}}";
			break;
1 Like

This works perfectly @btheado thanks very much Brian.

  • let me know if you want the resulting solution.
  • This also illustrates how to do this in future hacks :nerd_face:
  • I manged to keep the existing behaviour and add another option in the excise type dropdown.