Could the /import pragma and importvariables widget be enhanced to allow fieldnames other than text?

I ask the above (title) because it would be useful to populate a field with a pragma that I can import into tiddlers.

  • This I expect would allow either simple fields or text area fields to contain pragma

Why;

  • user selection or designer tools could thus populate a field on the current tiddler with pragma including functions and procedures in the current tiddler, to apply only to nominated tiddlers allowing the development of a self contained development tools.
  • Examples include developing filters, functions, procedure’s and widgets in a single tiddler, and eventualy generate appropriate support tiddlers.

I did raise this before but now the use is more even compelling.

How;

It should be as simple as allowing the inclusion of text references not just tiddler names in the import pragma, and include optional tiddler and field parameters (in addition to the filter parameter) on the import variables widget.

Eg \import {{!!fieldname}} or \import {{tiddlername!!fieldname}}

What;
This would allow me to create tools for the creation of buttons, macros and more, bundled in a single tiddler, that could be installed on demand, and deleted after generating the desired element. The single tiddler approach is clean an removable without additional tools.

[Post Scrtipt] I already have a set of tools this will complement including a tiddler to have its own view or edit template, this will allow a single tiddler to define in its own fields macros, functions, procedures that it uses for its own purpose.

  • This could include special parsing rules, or redefined widgets and more that apply only to the tiddler itself.
  • This could allow advanced users to implement a kind of sand box or write macros especially for transforming a bespoke tiddler and its content, without time consuming references to multiple tiddlers.
  • The result can be designed to programmatically generate tiddlers for a package or plugin.
  • Keeping such tiddler free of code in the text field allows slabs of content to be pasted into the text field without concern for deleting code within the text field.

I would be happy if this was in a plugin that overwrites the core for now, not core changes (yet).

Hi @TW_Tones I think you are asking for the ability to use the \import pragma to be able to import fields other than the text field.

At the moment, the argument to the \import pragma is a filter that identifies the titles of the tiddlers that should be imported.

As you note, one possibility would be for it to interpret each filter result as a text references, and not just as a tiddler title. That would not be a backwards compatible change, but it may be reasonable to argue that people are unlikely to be importing from tiddlers whose title contain either !! or ##.

Another possibility might be for a variant of the \import widget to interpret the filter results as the actual wikitext that is to be imported. This would allow a lot of flexibility: for example, the text to be imported could be stored within a complex JSON tiddler extracted with jsonget and jsonextract. The trouble with this approach is that it would defeat our current caching mechanism for parser results.

1 Like

Thanks @jeremyruston

A seperate pragma that interprets the filter result as wiki text (sourced from elsewhere) could introduce some interesting opportunities.

  • its a kind of preprocessing.

What would be the impact of this caching limitation?

In my current use case I want to use this in self contained tiddlers, to make use of localy defined pragma (found in a field on the current tiddler) that may or may not override global definitions.

  • That is, there may be no need to cache.

Perhaps another approach?

Whatever I do, it seems I will still need to start the current tiddler text field with the pragma be it only to import them.

  • I wonder if a special form of transclusion could do this?
  • or perhaps there is a way to introduce transcluded or imported variables, in the body template or story tiddler cascade?
    • enhancements to the import variables widget parameters would permit this.
    • this would allow the text field to be empty to start with.

I suspect there may be an acceptable workaround, but a new feature would be helpful.

  • I will continue to research this.

[Edited] Perhaps we could implement this via the rules pragma?
[Edited] I am also looking into a workaround, where if one has a pragma field a button appears to save it to a tiddler, so we can import it. In someways this allows us to edit and “commit” the pragma. A comparison between the field and the external text field could also indicate when they differ.