Request - templating in TW made easy (for everyone - including me...)

67 views
Skip to first unread message

Måns

unread,
Mar 3, 2011, 5:12:31 AM3/3/11
to TiddlyWiki
Hi TiddlyWikiWizards

I think TiddlyWiki should get seriously into the game of templating...
This thread:https://groups.google.com/group/tiddlywiki/browse_thread/
thread/b29b12d52932b5e6?
tells me sth very important about TiddlyWiki's status - (I think) some
things need more attention from developpers...

I've been "fiddling" with TiddlyWiki for a few years now - and I find
myself creating templates for almost everything...
Fact is that I don't know javascript - therefore everything I do -
need some plugin which delivers the needed scripts...

I've learnt to use ForEachTiddlerPlugin and I can create lists or
tables for (almost) anything I want. Most of the time I create
templates from my fETs, which let me reuse them in many different
usercases... Fact is that I'm *can't* remember my fET-syntax anyway -
so I *have* to keep copies of everything anyway....

Today slices, sections and fields are the containers of data in a TW,
however it's not easy to collect and present it in ways that you'd
like.
I think this is a *very* fundamental problem facing any newbie. Why
should they bother to use slices, sections or fields, if they can't
retrieve/fetch the data quite easily?....

I think Jon's http://newtimeline.tiddlyspace.com/#TiddlyWikiListPlugin
tries to address this problem, however it can't deliver nuanced
information based on slices or sections because the core misses the
needed granularity via the <<view>> macro.... In other words: The view-
macro hasn't been updated to match the current uses of slices,
sections or fields...

Eric has tried to address most of these problems with his
http://www.google.com/url?sa=D&q=http://www.TiddlyTools.com/%23WikifyPlugin
and http://www.google.com/url?sa=D&q=http://www.TiddlyTools.com/%23SectionLinksPlugin

I'd like to ask Jon to elaborate on the templating options provided by
TiddlyWikiListPlugin - However I can't see any point in trying to
convince Jon to add features which are not even possible without
Eric's plugins.... If they are - I'm not sure that the most basic
lists or tables showing slices, sections or fields can be tacled with
Jon's and Eric's plugins alone - I don't think so...

What about "default text" - when values are missing? - I don't find
any solution for this anywhere in the threads... I think this is
basic, and should be provided by the core...

There's more - however I have to run now ...

Cheers Måns Mårtensson

rakugo

unread,
Mar 7, 2011, 8:49:23 AM3/7/11
to TiddlyWiki
I agree that templating should be made more easy in TiddlyWiki.
It looks like this is beginning as recently http://trac.tiddlywiki.org/ticket/1286
got moved into the core.

Since this works on a macro level any macro can be created/used for
use in a template. I've always been scared of the way
ForEachTiddlerPlugin is used as most of the time I see users copying
and pasting javascript code from other people's TiddlyWiki's, a lot of
the time not understanding what that javascript code does. Many of the
ForEachTiddler macro calls are very very difficult to parse and
understand but most of the time they appear to be doing something
simple like getting all tiddlers tagged "hello"

The most useful macros for this kind of templating is the view macro
which allows printing of attributes in different formats such as link,
date, text and wikified (these are the core view types)

The area this does not cover is slices. However I'm pretty confident
this could be fixed by a minor change to the core / a small plugin in
the TiddlyWiki getValue function I plan to look into this very
swiftly.
This would enable <<view ##slicename text>> to work

It is possible one might want to extend the view macro to provide
default text as you suggest. All though I think one could live with
out this for a little longer (the above is more important).

The move to github, I am sure will shake up a lot of this and make it
easy to solve these sorts of problems.
Jon

On Mar 3, 10:12 am, Måns <humam...@gmail.com> wrote:
> Hi TiddlyWikiWizards
>
> I think TiddlyWiki should get seriously into the game of templating...
> This thread:https://groups.google.com/group/tiddlywiki/browse_thread/
> thread/b29b12d52932b5e6?
> tells me sth very important about TiddlyWiki's status - (I think) some
> things need more attention from developpers...
>
> I've been "fiddling" with TiddlyWiki for a few years now - and I find
> myself creating templates for almost everything...
> Fact is that I don't know javascript - therefore everything I do -
> need some plugin which delivers the needed scripts...
>
> I've learnt to use ForEachTiddlerPlugin and I can create lists or
> tables for (almost) anything I want. Most of the time I create
> templates from my fETs, which let me reuse them in many different
> usercases... Fact is that I'm *can't* remember my fET-syntax anyway -
> so I *have* to keep copies of everything anyway....
>
> Today slices, sections and fields are the containers of data in a TW,
> however it's not easy to collect and present it in ways that you'd
> like.
> I think this is a *very* fundamental problem facing any newbie. Why
> should they bother to use slices, sections or fields, if they can't
> retrieve/fetch the data quite easily?....
>
> I think Jon'shttp://newtimeline.tiddlyspace.com/#TiddlyWikiListPlugin
> tries to address this problem, however it can't deliver nuanced
> information based on slices or sections because the core misses the
> needed granularity via the <<view>> macro.... In other words: The view-
> macro hasn't been updated to match the current uses of slices,
> sections or fields...
>
> Eric has tried to address most of these problems with hishttp://www.google.com/url?sa=D&q=http://www.TiddlyTools.com/%23Wikify...
> andhttp://www.google.com/url?sa=D&q=http://www.TiddlyTools.com/%23Sectio...

Eric Shulman

unread,
Mar 7, 2011, 10:09:01 AM3/7/11
to TiddlyWiki
> The area this does not cover is slices. However I'm pretty confident
> this could be fixed by a minor change to the core / a small plugin in
> the TiddlyWiki getValue function I plan to look into this very
> swiftly.
> This would enable <<view ##slicename text>> to work

http://www.TiddlyTools.com/#WikifyPlugin
provides formatted output of fields, slices and section (as well as
literals and computed values).

Usage:
<<wikify "formatstring" value value value ....>>

where "formatstring" is text containing 'substitution markers' (%0-
%9), and the 'value' params are references to slices, sections,
fields, using the following syntax:

::slicename
here::slicename
TiddlerName::slicename

##sectionname
here##sectionname
TiddlerName##sectionname

fieldname
fieldname@here
fieldname@TiddlerName

Outputting a simple field:
<<wikify "%0" fieldname>>
produces the same results as the TW core macro:
<<view fieldname wikified>>

In addition to just displaying field, slice or section values,
<<wikify>> can also assemble and render more complex wiki-formatted
content (such as "PrettyTiddlyLinks") from multiple values:
<<wikify "[[%0|%1]]" fieldname1 fieldname2>>

enjoy,
-e

rakugo

unread,
Mar 7, 2011, 1:38:02 PM3/7/11
to TiddlyWiki
Sometimes a slice may contain something other than wikitext for
instance a date string or you may not want to wikify it (especially on
a shared Wiki). Hence why I think the view macro would be the logical
place for slice printing..
Jon

On Mar 7, 3:09 pm, Eric Shulman <elsdes...@gmail.com> wrote:
> > The area this does not cover is sli However I'm pretty confident

rakugo

unread,
Mar 8, 2011, 8:31:41 AM3/8/11
to TiddlyWiki
I've submitted a ticket and patch
http://trac.tiddlywiki.org/ticket/1439

The code is quite trivial and has been added to the http://newtimeline.tiddlyspace.com
space
The plugin is here: http://newtimeline.tiddlyspace.com/#GetValueSectionSliceTweak

This change allows you to use <<view ::slice text>>, <<view ##section
wikified>> etc etc..

I'd appreciate any feedback especially if this has any side effects.

Jon

Måns

unread,
Mar 8, 2011, 6:49:05 PM3/8/11
to TiddlyWiki
Hi Jon

> This change allows you to use <<view ::slice text>>, <<view ##section
> wikified>> etc etc..

That is GREAT Jon!!

> I'd appreciate any feedback especially if this has any side effects.
When a slice doesn't exist - all tiddler content will be rendered -
see:
http://klasser.tiddlyspace.com/#ForEachExample

Cheers Måns Mårtensson

Måns Mårtensson

unread,
Mar 10, 2011, 10:03:25 AM3/10/11
to TiddlyWiki
@Jon

-Bump-

> I'd appreciate any feedback especially if this has any side effects.
When a slice doesn't exist - all tiddler content will be rendered -
see:
http://klasser.tiddlyspace.com/#ForEachExample

Cheers Måns Mårtensson


2011/3/9 Måns <huma...@gmail.com>

--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To post to this group, send email to tiddl...@googlegroups.com.
To unsubscribe from this group, send email to tiddlywiki+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/tiddlywiki?hl=en.


rakugo

unread,
Mar 10, 2011, 11:04:07 AM3/10/11
to TiddlyWiki
Hi Måns,
So far I have been unable to replicate this.

If the slice doesn't exist, it will return a blank value.

Looking at your template it seems to be working correctly...

Could you write me a much smaller test case and let me know what
browser you are using and version (as maybe it is a browser problem)
Jon

*<<view title link>>
<<view ##testsection wikified>>
**summary: <<view ::summary>>
**nonexisting results in: <<view ::noneexisting>>
<<view ##testsection wikified>>

You are wikifying
On Mar 10, 3:03 pm, Måns Mårtensson <humam...@gmail.com> wrote:
> @Jon
>
> -Bump-
>
> > I'd appreciate any feedback especially if this has any side effects.
>
> When a slice doesn't exist - all tiddler content will be rendered -
> see:http://klasser.tiddlyspace.com/#ForEachExample
>
> Cheers Måns Mårtensson
>
> 2011/3/9 Måns <humam...@gmail.com>

Måns

unread,
Mar 10, 2011, 11:16:40 AM3/10/11
to TiddlyWiki
Hi Jon

Minimal testcase:
http://minitest.tiddlyspot.com/#TemplateExample%20ProjectTest

Cheers Måns Mårtensson

rakugo

unread,
Mar 10, 2011, 11:44:17 AM3/10/11
to TiddlyWiki
Excellent, thanks!

The output I get is:
###################
ProjectTest
This is a testsection
consisting of
several
lines

summary: this is a summary
nonexisting results in:
This is a testsection
consisting of
several
lines
##############################
Which I believe is correct due to your template.

<<view ::noneexisting>> prints an empty string for me in this example.
Does it do something else for you? If so can you let me know browser
and version?

Jon

Eric Shulman

unread,
Mar 10, 2011, 11:50:46 AM3/10/11
to TiddlyWiki
> So far I have been unable to replicate this.
> If the slice doesn't exist, it will return a blank value.

Looking at the TW262 core code:

store.getTiddlerText() calls on store.getTiddlerSlice()

If the slice exists, then getTiddlerSlice() returns a value which is,
in turn, returned by getTiddlerText() to the calling function (e.g.,
the <<view>> macro).

However, if the slice does not exist, then getTiddlerSlice() returns a
NULL (i.e., a "blank value", as intended), but... getTiddlerText()
does *not* return that null value to the calling function. Instead,
it falls through to the "non-slice" handling that follows the slice
retrieval code, and this code ends up returning the entire tiddler
text to the caller.

-e

Eric Shulman

unread,
Mar 10, 2011, 12:02:08 PM3/10/11
to TiddlyWiki
> store.getTiddlerText() calls on store.getTiddlerSlice()

addendum:

John Hind raised this very issue on TWDev just a few weeks ago
(related to ticket #1134 and the corresponding TiddlyTools CoreTweak)

Please see this posting (on TWDev):
http://groups.google.com/group/tiddlywikidev/msg/a0db0956e08dd3ba

I think John's analysis and proposed solution (returning defaultText
or NULL) is correct and should be implemented in getTiddlerText().
However, because use of this function is widespread throughout the
core (and plugins, of course), it's potential impact on existing code
has to be properly considered by as many developers as possible,
before it is added to the core.

-e

Måns

unread,
Mar 10, 2011, 6:05:06 PM3/10/11
to TiddlyWiki
Hi Jon

I believe Eric explained why ... - however here's a screenshot of how
it looks in my browser: (7.0.517.44 (64615) Built on Ubuntu 10.10,
running on Puppy Linux)
http://minitest.tiddlyspot.com/#ImageExample%20ProjectTest

Cheers Måns mårtensson

Måns

unread,
Mar 10, 2011, 6:27:57 PM3/10/11
to TiddlyWiki
Hi again - I was too quick (or slow, you might think)
Jon was of course right and I didn't see the difference...
The nonexisting slicecall does not render anything (but a blank
string?...)

Now I have made a "simple example" in the not so simple TW where
Eric's WikifyPlugin is installed as well- don't know if this has
something to do with the result, however it's very different:
http://klasser.tiddlyspace.com/#TstProject%20TemplateExample

Here the nonexisting slicecall renders something - namely all tiddler
content...

I'm very sorry - to bother you with this overloaded (pluginwise) TW,
however it shows that there *is* a conflict somewhere, which alters
the behaviour of Jon's Plugins, which otherwise works as intended (in
a vanillaTW)... or I have made some dumb typo, :-( ...

Cheers Måns Mårtensson


> I believe Eric explained why ... - however here's a screenshot of how
> it looks in my browser: (7.0.517.44 (64615) Built on Ubuntu 10.10,
> running on Puppy Linux)http://minitest.tiddlyspot.com/#ImageExample%20ProjectTest

Eric Shulman

unread,
Mar 10, 2011, 8:10:28 PM3/10/11
to TiddlyWiki
> Now I have made a "simple example" in the not so simple TW where
> Eric's WikifyPlugin is installed as well- don't know if this has
> something to do with the result...
> Here the nonexisting slicecall renders something - namely all tiddler
> content...

CoreTweaks #1134 *replaces* the getTiddlerText() function. The code
in this tweak is based on TW250, not TW262, so there may be some
differences. As a temporary work-around, try disabling CoreTweaks
#1134 by commenting it out, like this:

First, find this line of code in CoreTweaks:
TiddlyWiki.prototype.getTiddlerText = function(title,defaultText)
and insert this line BEFORE it:
/*
Then, scroll down to find the end of the function definition:
};
and add this line AFTER it:
*/

These added lines surround the redefined function inside a javascript
comment block, so that #1134 is effectively disabled, while still
allowing the rest of the CoreTweaks in that tiddler to be processed
normally.

Note: I need to review ALL the CoreTweaks and revise them as needed to
ensure compatibility with current TW262 core implementations. I'll
post a follow-up when an update is available.

enjoy,
-e
Eric Shulman
TiddlyTools / ELS Design Studios
----------
Was this answer useful? If so, please help support TiddlyTools:

TiddlyTools direct contributions: (paypal)
http://www.TiddlyTools.com/#Donate
UnaMesa tax-deductible contributions:
http://about.unamesa.org/Participate (paypal)
TiddlyWiki consulting:
http://www.TiddlyTools.com/#ELSDesignStudios
http://www.TiddlyTools.com/#Contact

cmari

unread,
Mar 11, 2011, 9:57:39 AM3/11/11
to tiddl...@googlegroups.com
> This change allows you to use <<view ::slice text>>, <<view ##section
> wikified>> etc etc..

I agree, this is really helpful - especially because, unlike <<wikify>>, the <<view>> macro works in transclusion.

One thing I discovered (maybe remembered?) while exploring the possibilities and after much painful trial and error:

section and slice names must be all lower case (no camelCase)
cmari

Måns

unread,
Mar 11, 2011, 10:02:43 AM3/11/11
to TiddlyWiki
Hi Eric and Jon

> CoreTweaks #1134 *replaces* the getTiddlerText() function.  The code
> in this tweak is based on TW250, not TW262, so there may be some
> differences.  As a temporary work-around, try disabling CoreTweaks
> #1134 by commenting it out,

Thanks - disabling CoreTweak #1134, made the TemplateExample work as
Jon suggested it should, and as it did in the "vanillaexample" :-)
http://klasser.tiddlyspace.com/#TemplateExample
http://www.google.com/url?sa=D&q=http://minitest.tiddlyspot.com/%23TemplateExample%2520ProjectTest

Cheers Måns Mårtensson

Kosmaton

unread,
Mar 11, 2011, 11:00:12 AM3/11/11
to tiddl...@googlegroups.com
Hello -

Finally, victory in the Battle of Backstage Button[1]. Now
http://triptych-theme.tiddlyspace.com is ready for deployment, I hope.
Many thanks to everyone who helped out!

Can I add it to http://themes.tiddlyspace.com? How? I can't seem to find
instructions there.

cheers,

Kosmaton

[1] Put CSS in MarkupPostBody to overrule StyleSheetBackstage...

--
http://veminra.tiddlyspace.com

Måns

unread,
Mar 12, 2011, 5:21:10 PM3/12/11
to TiddlyWiki
Hi Kosmaton

Re: Add theme to themes space?
Is a title for a new thread..

Cheers Måns Mårtensson

On 11 Mar., 17:00, Kosmaton <Kosma...@gmx.com> wrote:
>   Hello -
>
> Finally, victory in the Battle of Backstage Button[1]. Nowhttp://triptych-theme.tiddlyspace.comis ready for deployment, I hope.
> Many thanks to everyone who helped out!
>
> Can I add it tohttp://themes.tiddlyspace.com?How? I can't seem to find

PMario

unread,
Mar 17, 2011, 9:50:14 AM3/17/11
to TiddlyWiki
Hi Jon,
cmari points out, that <<view ::slices>> needs to be all _lowercase_
which is not right for slices but for custom fields.

So
http://newtimeline.tiddlyspace.com/#GetValueSectionSliceTweak
imo needs a fix.

fieldName = fieldName.toLowerCase();

could be done in the else path, where the fields are handled.
slice handling should be possible with CamelCase.

I haven't tested it !!
-m

On Mar 8, 2:31 pm, rakugo <jdlrob...@gmail.com> wrote:
> I've submitted a ticket and patchhttp://trac.tiddlywiki.org/ticket/1439
>
> The code is quite trivial and has been added to thehttp://newtimeline.tiddlyspace.com
Reply all
Reply to author
Forward
0 new messages