The idea is that pop gets back to the previous value and can be nested:
<$vars currentTiddler=1>
<$vars currentTiddler=2>
<$vars currentTiddler=3>
currentTiddler is <<currentTiddler>><br>
<$pop><$pop>
currentTiddler is <<currentTiddler>><br>
</$pop></$pop>
</$vars>
</$vars>
</$vars>
*outputs:*
currentTiddler is 3
currentTiddler is 1
The advantage here is that there is no change to any tw syntax, so no
backwards compatibility issues.
BJ
On Monday, April 23, 2018 at 2:27:35 AM UTC+2, TonyM wrote:
>
> Jed,
>
> It is true that accessing the nth tiddlers info your be tricky, but just
> being able to access the 0th would be enough to make big changes. By this I
> am referring to the tiddler in the face of the user. The logical place they
> are at, the item listed in the story. This makes me think perhaps we can
> come at it from another approach.
>
> Personally, It is not if it is core or not, just that a strait forward
> system exists to reference all fields in the 0th, N-1 and N
>
> If I understand BJ's suggestion its like the push and pop idea where the
> list pushes items onto a list and pop steps back one item on the list.
> Using stack metaphors.
>
> As far as I can see although this may very well be helpful, the key
> references will usually be the 0th, the Nth and the N-1th if you wish to
> start referencing this such as N-2th or 5th etc... in another iteration, to
> make the code understandable, then it is more reasonable to start using
> additional variables etc...
>
> Taking BJ's idea to push and pop his example pops to one layer before and
> that happens to be the 0th layer. This is a great example of the N-1th,
> note all we *need* is a way to reference the 0th without popping (imagine
> we are 3-4 deep)
>
> So on further consideration what if; as Jed said we had a "convenient
> shorthand"
> An enhancement to the <$list widget perhaps using a parameter, would allow
> us to request a push (of the references) of the containing tiddler to a
> stack, and then where ever you are in the nested lists you can either
> reference 0th or N-1th field values and/or use pop (one or more or N
> times). In reality a push need only be the storage of containing
> tiddler-title, if subsequently we have a way of referencing the fields and
> values from anywhere of that tiddlername. Basically the :N is replaced with
> the appropriate tiddler title.
>
> As an example (not literal) {{:-1!!fieldname}} {{:-N!!fieldname}}
> {{:0!!fieldname:0}} including [[:N!!fieldname]] [[pretty|:N!!fieldname]]
> [[pretty|:0!!fieldname]] especially [[pretty|:0!!title]]
>
> Of course we could perhaps call these "relative tiddler names".
>
> Alternatively we store the tiddlersname by name eg <$list push="parent"
> make the tiddlertitle calling this list be stored as parent. Then you can
> reference {{:parent!!fieldname}}
>
> Perhaps some of Mario's uni-link tech could effectively provide dynamic
> relative aliases.
>
> Regards
> Tony
>
> On Monday, April 23, 2018 at 12:38:40 AM UTC+10, Jed Carty wrote:
>>
>> It may be possible to add something like this to the core, but it
>> wouldn't be straight forward. The biggest problem is determining where the
>> outer containing tiddler is, like if you have multiple lists inside each
>> other how do you determine which containing tiddler you want? It would have
>> to be an nth parent sort of thing and I am not certain that would be any
>> simpler to use than what we have now.
>>
>>
--
You received this message because you are subscribed to the Google Groups
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit
https://groups.google.com/d/msgid/tiddlywiki/abe81fc8-e766-402f-931d-4c192f4e7356%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.