sep, tiddler, unique%title%, %tiddler%<$list filter="a b c +[make[%count%---%title%---%oddeven%]]">
<!-- returns the full serialized compound e.g. "1---a---odd" -->
{{!!title}}
<!-- returns only the counter -->
<<splitAndSelect separator:"---" index:"1" >>
<!-- returns only the title -->
<<splitAndSelect "---" "2" >>
<!-- returns "odd" or "even" depending on division of count by 2; could you implement that by the way ;) -->
<<splitAndSelect "---" "3" >>
<!-- returns and empty string as the 4th slot doesn't exist in the array -->
<<splitAndSelect "---" "4" >>
<$list>var str = this.getVariable("currentTiddler");
var result = str.split(arguments[1])[arguments[2]];
return (result != null ? result : str);
<$select>
<$list filter="[[|Do not display a neighbourhood]]
[[1|1 steps away]]
[[2|2 steps away]]
[[3|3 steps away]]
[[*|No limit]]">
<option value=<<tmap "splitAndSelect" "|" "0">>><<tmap "splitAndSelect" "|" "1">>
</$list>
</$select>
<select>
<option value="">Do not display a neighbourhood</option>
<option value="1">1 steps away</option>
<option value="2">2 steps away</option>
<option value="3">3 steps away</option>
<option value="*">No limit</option>
</select>
Minor suggestion:splitAndSelect thingy as a global macro which would be great for deserialization.Hi Tobias,
Very(!!) nice filter you created! Quite revolutionary, I have to say.
It is more than just a very handy swiss army knife (uuid creation, concatinations, placeholders, for loops with the use of count, step and max directives, how cool!) – it opens the gate for a whole lot of possibilies! Great stuff.
A proposal:
With your plugin, it is now possible for the first time to mix titles with other content on the fly in a sophisticated way using tw-filters.
However your plugin would even become more powerful if you included a macro that allows de-serialization afterwards.
What this means: In the filter expressions users can combine/merge/mix titles with other stuff and could use delimiters e.g. "---". Your plugin at the moment does a great job at serializing the data into one string that can be accessed later on.
So in addition, it would be nice if you added a deserilzer function e.g. named "splitAndSelect" (as a global macro).
<$list filter="a b c +[make[%count%---%title%---%oddeven%%]]">
<!-- returns the counter -->
<<splitAndSelectseparator:"---"index:"1" >>
<!-- returns the title -->
<<splitAndSelect "---" "2" >>
<!-- returns the "odd" or "even" depending on division of count by 2; could you implement that by the way ;) -->
<<splitAndSelect "---" "3" >>
<!-- returns and empty string as the 4th slot doesn't exist -->
<<splitAndSelect "---" "4" >>
<$list>
As you certainly guessed it, splitAndSelect is just a wrapper for a JS split and a subsequent array access operation (see code below).
You could copy the code of the splitAndSelect "macro" from TiddlyMap (I use it there for deserialization of lists in my own scenarios).var str = this.getVariable("currentTiddler");
var result = str.split(arguments[1])[arguments[2]];
return (result != null ? result : str);
In TiddlyMap I use it e.g. like this:
<$list filter="[[|Do not display a neighbourhood]]
[[1|1 steps away]][[2|2 steps away]]
[[3|3 steps away]][[*|No limit]]">
<$select>
<option value=<<tmap "splitAndSelect" "|" "0">>><<tmap "splitAndSelect" "|" "1">>
</$select>
</$list>
Which produces<select>
<option value="">Do not display a neighbourhood</option>
<option value="1">1 steps away</option>
<option value="2">2 steps away</option>
<option value="3">3 steps away</option>
<option value="*">No limit</option>
</select>Minor suggestion:
As you noticed in the example above, I added a suggestion for an automatic variable %evenodd% that outputs "even" or odd" depending on the division by 2. I guess that might come handy in the future?! On the other hand users could also write a macro for that task, so I am not sure if it really makes sense to include it as part of your plugin…
In summary: great job and I hope you can add thesplitAndSelectthingy as a global macro which would be great for deserialization.
-Felix
P.S. Which github repo url to use for further discussing this plugin?
--
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 tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
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/57ea88a9-cd86-4d06-86ec-8daf66ed375c%40googlegroups.com.
<$list filter="a b c +[make[%count%;;%title%;;%max%]]" variable="s">
<div style="background: #ffffcc; padding: 3px; margin: 10px;">
''Serialized string:'' <<s>>
''Deserialized string:''
|!Index |!First Element |!Second Element |
|{{{ [<s>split[;;]nth[1]] }}}| {{{ [<s>split[;;]nth[2]] }}}| {{{ [<s>split[;;]nth[3]] }}}|
</div>
</$list>I always wished this was possible in TW ;) Hope my description helps others who are also interested in advanced loops.
@Tobias there seems to be a bug though: do you notice the missing value in the third iteration?
-Felix
However: The split filter is what I was looking for (in combination with nth() filter)
@Tobias there seems to be a bug though: do you notice the missing value in the third iteration?
Most TiddlyWiki filters treat titles as sets and so does (even) split.
Will think about it and probably change it's behavior to not produce sets,
! Simple
// Creates a new unique title based on the current tiddler: //
<<` """{{{ [[]make[]] }}}""">>For those of us less experienced, where would I find copy/paste code as examples?
pad:max — zero-pad count to length of maxpad:5 — zero-pad count to 5 digits: 00001