@jeremyruston Zell, the doc may need a fix if not the code. I will have a try and if succesful, have a PR submitted.
Glad to see my very first suggestion seems interesting. Surely it would be enough and able to please many people.
@jeremyruston Zell, the doc may need a fix if not the code. I will have a try and if succesful, have a PR submitted.
Glad to see my very first suggestion seems interesting. Surely it would be enough and able to please many people.
I have played with transclusions and filtered transclusions a lot. They offer a nice opportunity for user code simplification without needing global macros. I will illustrate if requested, one gap I perceive is as follows;
{{||template}}
transcludes the template using current tiddler{{namedtiddler||template}}
transcludes the template using namedtiddler, which can in fact be anything and the value made use of within the âtemplateâ. the current tiddler title can be used as a parameter to the template. If you have used current Tiddler to pass another value you can use <<storyTiddler>>
{{!!fieldname}}
will transclude the field in currentTiddler.{{||template!!fieldname}}
will transclude here the content of âtemplate!!fieldnameâ and the content of transclude text field is ignored (understandable).{{namedtiddler!!fieldname||template}}
and {{!!fieldname||template}}
do not pass the fieldname or its content to the template.
In conclusion
Of course any facility found in the shortcut transclusions or the transclude widget should be similar, and arguably in filtered transclusions as well.
I would need to revisit this as a question if we were to look at improving the transclude (short and widget) and filtered transclusion as I have only come upon these limitationâs and a range of possibilities when deep in other projects.
Having a short look. Iâd consider this an âoversightâ or a âbugâ. IMO you should open a github issue for this one.
There may be some arguments against implementing it ⌠eg: Tiddler titles could look that way ?!
Yea, Iâve missed that sometimes too. ⌠I think there are some open github issues for this one already
Back in the thread, I made almost the same statements I made in this one.
One remaining gap in the current macro parameters and I would hope we can avoid if we build a method to pass variables in a transclusion, is to find a way to represent all parameters.
Using named parameters as param=value or positional parameters âvalue1 value2â mean we must name each parameter. This means we can not design solutions with a variable number of parameters. If for example we have a special parameter name such as $*$ that could be used in macros and transclusions, that would contain the name=value or values of all parameters" then it would be easier to write solutions with an variable sized set of parameters. Which we can subsequently parse in the macro or transclusion.
IMO thatâs not true. With a new implementation we can have as many named parameters as we want. Core parameters may need special $names, similar to the action-widgets. But user parameters wonât have any limits.
Those examples donât really make sense â the part before the double vertical bar is the title of the tiddler that is assigned to âcurrentTiddlerâ; we canât assign namedtiddler!!fieldname
to currentTiddler
.
@jeremyruston is right that {{namedtiddler!!fieldname||template}}
is not allowable. But then, there is a little problem because {{namedtiddler!!fieldname}} is legal and one //will tend to think// that
||just specify a template to be used in the tiddler named on the left part. In the present example, it would be said that the name is not
namedtiddler!!fieldnamebut the value in the
fieldnamefield of the
namedtiddlertiddler. If that value was
fubarthen that would be translated into
{{fubar||template}}`.
The question is: is that an expected assumption or not (not a correct one, just one that we can expect in real life).
I for one does expect just that.
If I am to be wrong, then maybe we could try to devise an other wiki marking. Because if {{namedtiddler!!fieldname}}
produce fubar
it is rather unexpected (if not perceived as plainly illogical) that {{namedtiddler!!fieldname||template}}
does not produce {{fubar||template}}
but is in fact an incorrect expression.
PS : why //slash// does not produces italics ? what marking are we using here? (Iâm not asking for â*â but for a name like tw5 or markdown or bb-quote.)
Use markdown syntax: _
underscore_
==> underscore
You can also use html: <i>
italics</i>
==> italics
I think that the subtleties of a syntax like TiddlyWikiâs are inevitable given the complexity of the task it is designed to address. To properly understand it requires an understanding variables, which is obviously a conceptually complex topic. So we try to simplify things by making the âcurrentTiddlerâ variable be implicit as often as we can, but eventually users will have to get to grips with whatâs going on if they want to do complex things.
Today I found a problem with transclude widget that was not previously told (at least, explicitely). Here it is.
I have a foo tiddler which has a field called bar, that it includes to get its text complete. The full text firld content could be:
Hello! {{!!bar}}
If I code elsewhere {{fu}}
everything is nice. If I code <$transclude tiddler=fu/>
it,s broken beause the currentTiddler is not //fu//. So that I have to code <$tiddler tiddler=fu><$transclude tiddler=fu/></$tiddler>
. This is not a new mechanism, but for such a simple task, it seems overkill.
The coding in fu does not seem to be wrong for me. Iâm reluctant to code {{fu!!bar}}
instead of {{!!bar}}
as it would be broken if fu is renamed (itâs less robust).
Should we not expand the include widget to allow for it to be able to be, by itself, able to do as the {{fu}}
syntax? If so, an attribute like âautorefâ could do it. {{fu}}
would be equivalent to <$trasnclude autoref tiddler=fu/>
.
@jypre this has come up before with the transclude widget tiddler=theTemplate tiddler. It is equivalent to
{{||theTemplate}}
One way to think of it is tranclude is by default overlaying a tiddler template on the current tiddler. The current tiddlers title and fields can be seen âthrought the templateâ.
If you want to transclude the tiddler without it applying to the current tiddler try {{theTemplate}}
I have actualy pushed the transclude method a lot further. So if you state your need I may be able to offer a trick or two.
Perhaps if the tranclude widget permitted a currentTiddler parameter?
@pmario âif the tranclude widget permitted a currentTiddler parameter?â yes that would be nice. but it would require repeating the tiddler name, whereas an argumet like fromSameTiddler=yes
would avoid that and this could be handy to build the expression from a filter run.
{{fubar}}
would then be identical to <$transclude tiddler=fubar fromSameTiddler=yes/>
(or a better name than //fromSameTiddler//)
Does not seem as sweet to me as taking the existing format
<$tiddler tiddler=tiddlername><!-- sets current tiddler -->
<$transclude tiddler=templateTiddler/>
</$tiddler>
And improve it as such
<$transclude template=templateTiddler currentTiddler=tiddlername />
where template= is simply an alias for tiddler=
On further thought we can extend this further to accept any variable/value pair, and make them accessible in the transclude.
<$transclude template=templateTiddler varname=value varname2=value2/>
where providing current tiddler is just another varname/value pair.
Yes I think it would make sense too since several widgets messages allows hashmap parameter (or âparamObjectâ) .
The technique of passing parameters to a transclusion via variables is useful, but lacks one critical element: it is not currently possible to reliably have the transcluded tiddler apply a default value for parameters that have not been explicitly specified.
I am exploring ways to add that capability (âparameterised transclusionâ) with the intention that weâd use the <$transclude tiddler=templateTiddler varname=value varname2=value2/>
syntax to pass parameters. For backwards compatibility, there would be an implied currentTiddler=<<currentTiddler>>
parameter, but it could be overridden.
Within the transcluded tiddler, there would be something like a \parameters
pragma to specify the parameters and their default values.
@jeremyruston out of curiosity why do you consider this necessary?
apply a default value for parameters that have not been explicitly specified
As a designer I am happy to take responsibility both for providing as well as using other variables such as âvarname=value varname2=value2â with the exception of the aforementioned alias parameter template for template and currentTiddler
There are many use cases, but a key underlying motivation is consistency. As you know, in the core thereâs an uneven mix where some of the reusable building blocks that we provide are designed as transclusions (eg the switchers like $:/snippets/paletteswitcher
), while many more are provided as macros (eg the TOC macros). Broadly, the core uses transclusions where possible, but is forced to use macros in the cases where there are multiple and/or optional parameters.
For authors, the advantage is that it is possible to publish a tiddler that is designed to be transcluded, and then later add optional parameters without breaking backwards compatibility.
We would also introduce a shortcut syntax for a transclusion with parameters.
Thanks @jeremyruston for that insight and perspective. Also I look forward to learning more on;
As you can see in this thread this was the latest issue in this thread
Which is in my view a combination of misunderstanding and room for improvement in the transclusion widget and shorthand versions. So being able to make this a little clearer and/or pass additional parameterâs a good outcome and I think your @jeremyruston âparameterised transclusionâ will help.
As a result of your @jeremyruston own deep and creative history with tiddlywiki, learning from you about the use of transclusions in the core and the perspective you have is very interesting to me.