I just came across two apparent limitations regarding tiddler slices.
My data looked like this: |!ID|200712220001| |!Last Name|Doe| |!First Name|John| I expected the following code to return the respective slice's value: store.getTiddlerSlice(title, "ID"); store.getTiddlerSlice(title, "Last Name"); store.getTiddlerSlice(title, "First Name"); However, this didn't work (returned "undefined").
There seem to be two reasons for that: 1. table row headings Unlike bold and italic formatting, the "!" indicating a row heading seems not to be ignored. 2. spaces in labels It appears that a slice's label must not contain spaces.
So I had to resort to using much less appealing formatting instead: ''ID'': 200712220001 ''~LastName'': Doe ''~FirstName'': John
Are these limitations known or even intentional, or should I create a ticket for this? (I don't dare touching the slicesRE though... )
The regexps for slices are faulty, there is already a ticket
outstanding for it.
In the mean time, the above plugin fixes the problem pending the core
being fixed and also provides some nifty additions in a backward
compatible manner :-)
The code could, actually, be incorporated into the core.
...Lyall
On Dec 22, 7:00 pm, FND <Ace_No...@gmx.net> wrote:
> I just came across two apparent limitations regarding tiddler slices.
> My data looked like this:
> |!ID|200712220001|
> |!Last Name|Doe|
> |!First Name|John|
> I expected the following code to return the respective slice's value:
> store.getTiddlerSlice(title, "ID");
> store.getTiddlerSlice(title, "Last Name");
> store.getTiddlerSlice(title, "First Name");
> However, this didn't work (returned "undefined").
> There seem to be two reasons for that:
> 1. table row headings
> Unlike bold and italic formatting, the "!" indicating a row heading
> seems not to be ignored.
> 2. spaces in labels
> It appears that a slice's label must not contain spaces.
> So I had to resort to using much less appealing formatting instead:
> ''ID'': 200712220001
> ''~LastName'': Doe
> ''~FirstName'': John
> Are these limitations known or even intentional, or should I create a
> ticket for this? (I don't dare touching the slicesRE though... )
> I created an improved slices plugin when I hit problems with slices.
Thanks, Lyall. I know about your ImprovedSlicesPlugin - and while there's certainly a raison d'ętre for it as a plugin*, I believe that the core slices should remain simple label/value pairs.
Nevertheless, the core RegEx could do with some improvements, and your ticket (http://trac.tiddlywiki.org/ticket/370) certainly deserves some attention. If you could submit a patch, that would make it much easier for Jeremy or Martin to review the suggested changes and consider them for inclusion in the core.
I have already provided patch info, as described in the ticket. Not an
actual 'patch' input file but given a revised regex to use.
Still, I think the ImprovedSlicesPlugin code could become core,
primarily because it is backward compatible (actually better than
backward compatible, cos it works) as well as providing some useful,
optional additional functionality.
...Lyall
On Dec 22, 11:07 pm, FND <Ace_No...@gmx.net> wrote:
> > I created an improved slices plugin when I hit problems with slices.
> Thanks, Lyall.
> I know about your ImprovedSlicesPlugin - and while there's certainly a
> raison d'ętre for it as a plugin*, I believe that the core slices should
> remain simple label/value pairs.
> Nevertheless, the core RegEx could do with some improvements, and your
> ticket (http://trac.tiddlywiki.org/ticket/370) certainly deserves some
> attention.
> If you could submit a patch, that would make it much easier for Jeremy
> or Martin to review the suggested changes and consider them for
> inclusion in the core.
> I have already provided patch info, as described in the ticket. Not an > actual 'patch' input file but given a revised regex to use.
An actual patch would greatly enhance the chances of this being given another look (which is only natural; the easier you make it for the maintainers, the quicker they can review and possibly commit the changes).
> I just came across two apparent limitations regardingtiddlerslices.
> My data looked like this:
> |!ID|200712220001|
> |!Last Name|Doe|
> |!First Name|John|
> I expected the following code to return the respective slice's value:
> store.getTiddlerSlice(title, "ID");
> store.getTiddlerSlice(title, "Last Name");
> store.getTiddlerSlice(title, "First Name");
> However, this didn't work (returned "undefined").
> There seem to be two reasons for that:
> 1. table row headings
> Unlike bold and italic formatting, the "!" indicating a row heading
> seems not to be ignored.
> 2. spaces in labels
> It appears that a slice's label must not contain spaces.
> So I had to resort to using much less appealing formatting instead:
> ''ID'': 200712220001
> ''~LastName'': Doe
> ''~FirstName'': John
> Are these limitations known or even intentional, or should I create a
> ticket for this? (I don't dare touching the slicesRE though... )
> -- F.
I had similar probs, and don't know if it's koshur, but here's what my
solution is:
I delved into the core JS of Jeremy's Tiddlywiki after installing the
"forEachTiddler" plugin and found the line,
TiddlyWiki.prototype.slicesRE = /(?:[\'\/]*~?([\.\w]+)[\'\/]*\:[\'\/]*
\s*(.*?)\s*$)|(?:\|[\'\/]*~?([\.\w]+)\:?[\'\/]*\|\s*(.*?)\s*\|)/gm;
I edited that to,
TiddlyWiki.prototype.slicesRE = /(?:[\'\/]*~?([\.\w]+)[\'\/]*\:[\'\/]*
\s*(.*?)\s*$)|(?:\|[\'\/ \!]*~?([\.\w]+)\:?[\'\/]*\|\s*(.*?)\s*\|)/gm;