Slices

32 views
Skip to first unread message

Hugo Pires

unread,
Dec 18, 2007, 12:47:04 PM12/18/07
to TiddlyWiki
Hello

What is the correct syntax for naming a slice?

Thank you

Hugo

Eric Shulman

unread,
Dec 18, 2007, 1:02:34 PM12/18/07
to TiddlyWiki, ho...@unamesa.org
> What is the correct syntax for naming a slice?

The most unambiguous syntax for defining a slice is to use a "slice
table":

| slicename | slicevalue |
| slicename | slicevalue |
etc.

note: for increased readability, *some* limited use of wiki-formatting
syntax such as bold ('') or italics (//) IS permitted surrounding the
slicenames, and you can also include a trailing colon (:) following
the name, e.g.,

| slicename: | value |
| //slicename// | value |

However, you cannot use the full range of wiki formatting (i.e., no
class wrappers, macro calls, inline scripts, etc)... just a simple
slicename with a bit of minor styling...

To USE a slice value, simply place the slice table in a tiddler (e.g.,
[[SomeTiddler]]), and then retrieve the slice values and embed them in
other tiddler content using:

<<tiddler "SomeTiddler::slicename">>

HTH,
-e
Eric Shulman
TiddlyTools / ELS Design Studios

FND

unread,
Dec 18, 2007, 1:14:20 PM12/18/07
to Tiddl...@googlegroups.com
> What is the correct syntax for naming a slice?

There are two ways; either using simply "label: value" pairs (as in the
ColorPalette shadow tiddler), or using a two-column table
("|label|value|" - many plugins make use of that).

What is your use case - maybe we can give you some more detailed
assistance...


-- F.

Hugo Pires

unread,
Dec 20, 2007, 5:15:11 AM12/20/07
to TiddlyWiki
Thank you

Is it possible to have a slice with more than one value:

| slicename | slicevalue(1) | slicevalue(...)|slicevalue(n)|

Merry Xmas

Hugo

FND

unread,
Dec 20, 2007, 11:20:18 AM12/20/07
to Tiddl...@googlegroups.com
> Is it possible to have a slice with more than one value

No; slices are simple label:value pairs.
You could of course come up with some special syntax to separate the
individual values (e.g. "label:value1;value2;value3"), but you'd need to
write a function for processing the value string then.

We could probably give you some more helpful answers if we knew what you
are trying to achieve.


-- F.

Hugo Pires

unread,
Dec 20, 2007, 12:04:51 PM12/20/07
to TiddlyWiki
So, I will try to explain:

I've been doing some experiments on "extended data" abilities. I was
trying to find some alternatives/complements to tags and I find that:

*JSON data is flexible but I need external plugins
*Custom fields are inside core TW
*So do slices

I need to search inside a tiddler for a complex relation eg.

A contains x of B

Thank you

Hugo

Eric Shulman

unread,
Dec 20, 2007, 12:55:29 PM12/20/07
to TiddlyWiki
> I've been doing some experiments on "extended data" abilities. I was
> trying to find some alternatives/complements to tags and I find that:

> *Custom fields are inside core TW
> *So do slices

Slices are embedded as "user-visible" content within the body of a
tiddler (though they CAN be enclosed in /%...%/ comment delimiters),
which makes them portable between standard TW documents, without
needing any customizations.

When working with slices, these may be helpful:
http://www.TiddlyTools.com/#SliceGridPlugin
http://www.TiddlyTools.com/#ShowSlices (script)

Slices are most useful when you want to quickly enter a few "ad hoc"
data values into a tiddler that otherwise contains regular wiki-
formatted content. However, slices are intended simply for defining
name:value pairs and are NOT designed to handle "extended data"
types. That's where custom fields take over...

Defining and using custom fields in your tiddlers is relatively
straighforward:

First, you customize your [[ViewTemplate]] and [[EditTemplate]] to add
the approriate "<<view fieldname wikified>>" and "<<edit fieldname>>"
macros, respectively. This will add a custom field called "fieldname"
to every NEW tiddler as it is created and each EXISTING tiddler when
it is next edited, and will display the value entered in "fieldname"
as wiki-formatted content when viewing all tiddlers.

Of course, exactly how and where to put those macros in the templates
is determined by your specific use-case. Also, if you want different
custom fields to be applied to different sets of tiddlers, then you
*don't* want to modify the common ViewTemplate/EditTemplate
definitions.

Instead, you can use
http://www.TiddlyTools.com/#TaggedTemplateTweak
to create alternative templates that use a tag value as a prefix
(e.g., "MyTagViewTemplate" and "MyTagEditTemplate"). Simply tag a
tiddler with that prefix ("MyTag"), and it will use the alternative
view/edit templates automatically. For some examples of custom view/
edit templates using TaggedTemplateTweak, check out:

http://www.TiddlyTools.com/#CDSample
http://www.TiddlyTools.com/#CDViewTemplate
http://www.TiddlyTools.com/#CDEditTemplate
and
http://www.TiddlyTools.com/#[[MediaSample - QuickTime]]
http://www.TiddlyTools.com/#[[MediaSample - Windows]]
http://www.TiddlyTools.com/#MediaViewTemplate
http://www.TiddlyTools.com/#MediaEditTemplate

Hugo Pires

unread,
Dec 20, 2007, 1:06:34 PM12/20/07
to TiddlyWiki
I guess I can also use the FieldEditorPlugin or the EditFieldPlugin...
And what about the "more complex" relations?

Thank you

Hugo

wolfgang

unread,
Dec 20, 2007, 3:11:22 PM12/20/07
to TiddlyWiki
Hi Hugo,

there is also a ImprovedSlicesPlugin, which does handly more than one
value columns in slice tables:

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

Regards,

W.

Ken Girard

unread,
Dec 20, 2007, 3:45:54 PM12/20/07
to TiddlyWiki
Let me see if I get this:
You want to search through the text of a tiddler (A) and come up with
number of times that (B) is there? That should be easy with ForEach,
and a custom field whos value is (B).

I currently I do something similar with the following:

<<forEachTiddler where 'tiddler.tags.contains("Training") &&
store.getValue(tiddler,"assignedto") &&
(store.getValue(tiddler,"assignedto") ==
store.getValue(context.inTiddler,"searchfield"))'
sortBy
'store.getValue(tiddler,"traindate")'
write '"|"+store.getValue(tiddler,"assignedto")+"
|"+store.getValue(tiddler,"traindate")+" |[["+tiddler.title+"]]|\n"'
>>

With this code, and a custom field (searchfield) in the containing
tiddler, I get a list of all tiddlers that have the same value in
thier assingedto field as I have entered into the searchfield field.
It lets me quickly see what I've assigned Joe to do, and then click
edit and change the searchfield value to Jane and find out what she is
assigned to do.

Ken Girard

unread,
Dec 20, 2007, 4:03:56 PM12/20/07
to TiddlyWiki
Wrong code. It is an older broken one.
This is what I meant:
<<forEachTiddler where
'tiddler.tags.contains("Training") &&
store.getValue(tiddler,"assignedto") &&
(store.getValue(tiddler,"assignedto").readBracketedList().contains(store.getValue(context.inTiddler,"searchfield")))'
sortBy
'store.getValue(tiddler,"traindate")'
write '"|"+store.getValue(tiddler,"assignedto")+"
|"+store.getValue(tiddler,"traindate")+" |[["+tiddler.title+"]]|\n"'
>>

Ken Girard
> > Hugo- Hide quoted text -
>
> - Show quoted text -

Hugo Pires

unread,
Dec 21, 2007, 5:11:57 AM12/21/07
to TiddlyWiki
Thank you very much. The ImprovedSlicesPlugin will allow me to include
complex relation INSIDE the tiddler.

Merry Christmas

Hugo

Lyall

unread,
Dec 22, 2007, 11:09:14 PM12/22/07
to TiddlyWiki
It's nice to know someone else uses it :-)

...Lyall
Reply all
Reply to author
Forward
0 new messages