On Feb 28, 4:04 am, magev958 <[email protected]> wrote:
> Hi, a long time ago I got some help with the code to get a one line of
> the tiddler content in an FET-list 
> -http://groups.google.com/group/tiddlywiki/browse_frm/thread/724504928...
>
> <<forEachTiddler
>  where
>  'tiddler.tags.contains("information")'
>  sortBy
>  'store.getValue(tiddler,"created")'
>  descending
>  script
>  '
>  function getFirstLine(s) {
>  var m = s.match(/\s*(.*)/);
>  return m != null && m.length >= 1 ? m[1] : "";
>  }
>  ' write
>  '(index < 5) ? "[["+tiddler.title+"]] - "+tiddler.creator+" -
> "+tiddler.created+" - "+getFirstLine(tiddler.text)+"\n" : ""'>>
>
> My question this time is if I can get different formating depending on
> tag? For example if I have "priority1", "priority2", "priority3", can
> I get "priority2" with a red border and "priority3" with a yellow
> background?

You could wrap the output in CSS styles (i.e.,
"@@attr:value;attr:value;...content...@@"), based on the tag value.
First, in the "script" clause of your FET, add a new function
definition following the closing "}" of getFirstLine:

function getStyle(t) {
   if (t.isTagged("priority1")) return "text:normal";
   if (t.isTagged("priority2")) return "border:red";
   if (t.isTagged("priority3")) return "background-color:yellow";
}

Then, in the "write" clause of the FET, add the enclosing CSS syntax
and invoke getStyle(), like this:

'(index < 5) ? "@@"+getStyle(tiddler)+";[["+tiddler.title+"]] -
"+tiddler.creator+" - "+tiddler.created+" -
"+getFirstLine(tiddler.text)+"@@\n" : ""'

Producing output like this (using "priority2 as an example):

@@border:red;[[SomeTitle]] - CreatorName - date - ...first line...@@

That should do it.

enjoy,
-e
Eric Shulman
TiddlyTools / ELS Design Studios

----
WAS THIS ANSWER HELPFUL?  IF SO, PLEASE MAKE A DONATION
   http://www.TiddlyTools.com/#Donations
note: donations are directly used to pay for food, rent,
gas, net connection, etc., so please give generously and often!

Professional TiddlyWiki Consulting Services...
Analysis, Design, and Custom Solutions:
   http://www.TiddlyTools.com/#Contact

-- 
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