TiddlyWiki / TiddlyWiki5

A self-contained JavaScript wiki for the browser, Node.js, AWS Lambda etc.
https://tiddlywiki.com/
Other
7.97k stars 1.18k forks source link

generic template transclusion #1421

Closed tobibeer closed 1 year ago

tobibeer commented 9 years ago

Extend the $transclude widget so as to allow specifying a with parameter as discussed in here.

A practical example: Consider $:/core/ui/ViewTemplate/tags and wanting to either prepend or append something to its inner contents or insert something before or after it in the dom.

Here is how the proposed with parameter would achieve that:

In $:/core/ui/ViewTemplate, the transclude widget call would be extended like so: <$transclude tiddler=<<listItem>> with="ANY"/>

This would tell the transclude widget to fetch any tiddlers tagging to these...

...and and either insert them before or after or append/prepend their contents.

The following would just consider BEFORE and AFTER...

<$transclude tiddler=<<listItem>> with="BEFORE AFTER"/>

In other words with="ANY" is synonymous for with="BEFORE AFTER APPEND PREPEND".

pmario commented 9 years ago

I think, there is a point, where we need to stop making the default theme automatically expendable. The core knows about list-after parameter, that lets you extend the default templates.

If you need to modify the DOM you'd better modify the template itself.

IMO as soon as you mess around with inner and outer HTML code your compatibility with the core templates is gone anyway.

TiddlyWiki is already terribly slow. Adding more and more list widgets to make the layout more flexible and more complicated, needs to stop somewhere.

just my 2 cents.

Jermolene commented 9 years ago

Hi @tobibeer (jumping straight back in after my break) it seems that the problem that this proposal is addressing is to make it easier to insert custom components into the user interface. We already have a mechanism for doing that via system tags. That mechanism includes reasonably flexible options for the ordering of composition. The new proposal appears to be solving the problem of a particular part of the core template not being tag-driven. We can fix that in two ways: by making that area be driven by a system tag, or by splitting the area off into a separate shadow tiddler so that it can be more easily redefined.

I'm also not keen on the way that this proposal makes transclusion, one of TiddlyWiki's core low-level components a lot more complicated. It feels like the problems are better solved further up into the core template layer.

tobibeer commented 9 years ago

If you need to modify the DOM you'd better modify the template itself.

And lose out on core updates.

IMO as soon as you mess around with inner and outer HTML code your compatibility with the core templates is gone anyway.

How so? Sounds very over-generalizating to me.

TiddlyWiki is already terribly slow. Adding more and more list widgets to make the layout more flexible and more complicated, needs to stop somewhere.

I assume you have noticed that it won't affect every aspect, but only those transclusions that specifically declare it.

Plus, it is a general method that allows a great amount of flexibilty as compared to hoping / waiting for the core to enable certain components individually via the desired extensions... which would look terribly superfluous when there was independent before or after constructs in those templates.

Performance begs for a thorough assessment to figure out what makes TiddlyWiki slow. This renders nothing so long as those queries against the tiddler store don't return anything ...for thusly enhanced transclusions.

This is no proposal that comes out of boredom. It's not a rarity that people want to modify or just add things to places. Suggesting people to override core templates sounds like something I would want to avoid as much as possible.

pmario commented 1 year ago

@Jermolene -- I think this one can be closed. We do have cascades and parametrized transclusions now. Which combined should allow us to implement a mechanism similar to the OP.

Jermolene commented 1 year ago

Hi @pmario I think that's correct; the OP has been implemented within the view template rather than at the level of the transclude widget itself.

pmario commented 1 year ago

So we can close it?

Jermolene commented 1 year ago

Thanks @pmario