tiddler slices: table row headings, spaces in labels

9 views
Skip to first unread message

FND

unread,
Dec 22, 2007, 4:00:06 AM12/22/07
to TiddlyWikiDev
Hi all,

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... )


-- F.

Lyall

unread,
Dec 22, 2007, 7:10:14 AM12/22/07
to TiddlyWikiDev
I created an improved slices plugin when I hit problems with slices.

http://remotely-helpful.com/TiddlyWiki/ImprovedSlicesPlugin.html

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

FND

unread,
Dec 22, 2007, 8:07:39 AM12/22/07
to Tiddly...@googlegroups.com
> 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.


-- F.


* I would have called it ExtendedSlicesPlugin

Lyall

unread,
Dec 22, 2007, 11:21:12 PM12/22/07
to TiddlyWikiDev
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

FND

unread,
Dec 30, 2007, 5:35:20 PM12/30/07
to Tiddly...@googlegroups.com
> 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).


-- F.

BubbleHead

unread,
Jan 31, 2008, 12:07:29 AM1/31/08
to TiddlyWikiDev
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;

... and I now get data from tables such as:

| !Item|Pewter Cup, 14th century|
| !Purchased|2008-01-25|
| !Paid|195|
| !Value|290|

with code like:

<<forEachTiddler
where
' tiddler.tags.contains("vessels")'
script
'function writeRow(index, tiddler, context) { var result = ""; if
(index == 0) {context.sum = 0; context.count = 0; result = "|!Item|!
Count|!Value|!Sum|\n";} context.sum = context.sum +
parseInt(store.getTiddlerSlice(tiddler.title, "Value")); context.count+
+; result += "|" + tiddler.title + "| " + context.count + "| " +
store.getTiddlerSlice(tiddler.title, "Value") + "| " + context.sum + "|
\n"; return result;}'
write
'writeRow(index, tiddler, context)'
>>

Rik
Reply all
Reply to author
Forward
0 new messages