> Thanks for the code. I was thinking more of a macro solution, since
> this kind of thing seems to come up all the time. At least in my
> world.

That is precisely why I suggest using inline scripting... it allows
you to write use-case specific dynamic output generators that can be
very easily modified to fit different circumstances, without incurring
the extra complexity of programming a full-fledged plugin, just to
define a macro that will parse its parameters and perform essentially
the same actions as the inline script.

In fact, most of the code in the example inline script actually
corresponds pretty closely to your proposed macro params. (note: your
equivalent param is shown below by [...]).

[format] specify the output format
   var fmt="..."

[tag] select specific tiddlers by tag or tag expression
   var tids=store.getTaggedTiddlers("...");

[sliceList] extract and render slices from tiddler
   var val1=...
   var val2=...
   var val3=...
   out.push(fmt.format([val1,val2,val3]));
and could be generalized using arrays of slices and values:
   var slices=['sliceOne','sliceTwo','sliceThree'];
   var values=[];
   for (var s=0; s<slices.length; s++)
         values.push(store.getTiddlerSlice(t,slices[s]));
   out.push(fmt.format(values));

[sliceMatch] include/exclude certain tiddlers based on slice-testing
conditionals
   skipping over undesired tiddlers can be easily added at the start
of the 'for' loop:
      if (store.getTiddlerSlice(t,"someSlice") > someValue) continue;
      if (store.getTiddlerSlice(t,"someSlice") != someValue) continue;
      if ( ... some other use-case specific condition ... ) continue;

[header] and [footer] content output preceding/following the slice
data output
   can be easily added before the loop:
      out.push("...header content...");
   and after the loop:
      out.push("...footer content...");

Thus, with a little bit more code cleanup:

<script>
   // change the values and conditionals here:
   var fmt='|%0|%1|%2|';
   var slices=['sliceOne','sliceTwo','sliceThree'];
   var header="...header text...";
   var footer="... footer text ... ";
   var tag="... some tag ...";
   function skipTiddler(t) {
      if (store.getTiddlerSlice(t,"someSlice") > someValue) return
true;
      if (store.getTiddlerSlice(t,"someSlice") != someValue) return
true;
      return false;
   }
   // this code does not change:
   var out=[];
   var values=[];
   var tids=store.getTaggedTiddlers(tag);
   out.push(header);
   for (var i=0; i<tids.length; i++) {
      var t=tids[i].title;
      if (skipTiddler(t)) continue;
      for (var s=0; s<slices.length; s++)
            values.push(store.getTiddlerSlice(t,slices[s]));
            out.push(fmt.format(values));
      }
   }
   out.push(footer);
   return out.join('\n');
</script>

enjoy,
-e
Eric Shulman
TiddlyTools / ELS Design Studios
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/TiddlyWiki?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to