/***
!StyleSheet
body {
color: #F00;
}
!Code
***/
//{{{
var name = "StyleSheetFoo";
config.shadowTiddlers[name] = store.getTiddlerText(tiddler.title +
"##StyleSheet");
store.addNotification(name, refreshStyles);
//}}}
Unfortunately, there's a significant flaw to this useful technique: It
doesn't support CSS comments. Adding "/* lorem ipsum */" anywhere in the
StyleSheet section results in a syntax error when the plugin is evaluated.
I can imagine some hacky workarounds - e.g. using fake "//" markers
instead of the valid "/* ... */", removing them with a .replace when
creating the shadow tiddler - but none of those seem very satisfying.
Any clever ideas on how this issue might be resolved?
-- F.
[1] pioneered by Mike and Jeremy, if I recall correctly
[2] http://tiddlywiki.org/wiki/Dev:Comments#Wikified_Contents
I had a feeling this was an Ericism - my apologies!
> Also note that, in addition to directly setting CSS via setStylesheet,
> 'section payloads' can also be deposited into shadow definitions
I also prefer providing customizable shadow tiddlers (as illustrated in
my original post). However, I generally avoid setStylesheet altogether
and use addNotification with refreshStyles, which nicely encapsulates
the necessary steps.
-- F.