Hello,
TiddlyTemplating has been around for a little while now and there have
been a few discussions about it and suggestions that people use it to
solve problems - this is a search on just this group:
http://groups.google.com/group/TiddlyWikiDev/search?q=TiddlyTemplating&start=0&scoring=d&
I have been speaking with Martin today about pushing the basic
mechanism of templating into the core and what is required for that to
happen, as well as what outstanding questions exist.
To recap: the underlying idea behind TiddlyTemplating is that you can
create HTML templates and apply them to each of a set of tiddlers to
create an output. A use case that has existed right from the start is
a replacement for the various file saves that can be triggered from a
TiddlyWiki, namely: saving the file itself, taking a backup of the
original file, saving an empty TiddlyWiki, publishing an RSS feed of
changed tiddlers. Apart from consolidating the mechanism, it would
also reduce the time taken to save since it would obviate the need to
load the file from the file system first. Other use cases include
publishing ATOM feeds and web pages.
It looks like there are two stages to supporting a generic templating
model, with the existing save/publish mechanism replaced. I'll outline
them below. I apologise in advance for any over-lengthiness, but I
wanted to get it all down somewhere.
1) Core templating mechanism
This involves supporting the processing of templates and, if done
using current implementation, would involve integrating (most of) the
following code:
TemplatePlugin [1] - central function for expanding templates and two
macros for hooking into this
TemplateFormatterPlugin [2] - a special formatter used by the wikifier
to process templates
This would allow anyone to create macros/plugins that used the
templating process, but doesn't explicitly add any new functionality
as such. Martin pointed out that putting something in the core that
doesn't expose anything might be better off sitting in a plugin until
it's needed.
[1]
http://svn.tiddlywiki.org/Trunk/contributors/JonathanLister/plugins/TemplatePlugin.js
[2]
http://svn.tiddlywiki.org/Trunk/contributors/MartinBudden/experimental/TemplateFormatterPlugin.js
2) Replacing existing file saving/publishing
The implementation of this is incomplete, but at the moment the
following plugins and templates exist:
TiddlyTemplatingMacro [3] - actually this was made for the website
publishing, but uses generic methods and illustrates how to template
and publish files
RssTemplate, RssItemTemplate, RssItemCategoryTemplate [4],[5],[6] -
templates used to output a RSS feed
[3]
http://svn.tiddlywiki.org/Trunk/contributors/JonathanLister/plugins/TiddlyTemplatingMacro.js
[4],[5],[6]
http://svn.tiddlywiki.org/Trunk/contributors/JonathanLister/templates/
Unfortunately, three problems reared their head when discussing this
today:
a) Saving the backup
This saves the TiddlyWiki file as it existed *before* it was edited,
so is effectively a copy of what is on the file system. We're trying
to avoid loading from the file system before saving, so this will need
to be worked around.
b) Saving the TiddlyWiki
Martin's FastSavePlugin [7] extends the TemplateFormatterPlugin [2] to
process the TiddlyWikiTemplate [8]. However, this is very much
handling the file saving as a special case and it seems to me that
using any standard templating mechanism would be more stable. However,
the counter-argument is that the macros that would need to be written
and would sit in the new TiddlyWikiTemplate would only be used for
that use case, so from a code size point of view, it is not optimal.
[7]
http://svn.tiddlywiki.org/Trunk/contributors/MartinBudden/experimental/FastSavePlugin.js
[8]
http://svn.tiddlywiki.org/Trunk/contributors/MartinBudden/tiddlers/TiddlyWikiTemplate.tiddler
c) Default Templates
What is the best way to include any default templates in the system?
When they are integral to the fundamental feature of being able to
save your TiddlyWiki, is it important to make them hard/impossible to
change? Does this mean an implementation of read-only shadow tiddlers,
the use of internal variables, or something else?
Thanks for your patience if you've made it this far. I'd welcome
comments on anything mentioned so far, but particularly part 2. I hope
to have part 1 ready to go (as core patches) over the next day or two.
J.