Easy Question, tags ! inside <script>

5 views
Skip to first unread message

Mike

unread,
Apr 2, 2009, 6:00:06 PM4/2/09
to TiddlyWiki
Can't seem to wrap my brain around the obvious:
<script>return store.getTaggedTiddlers("Completed").length.toString();
</script>
Works (found on TiddlyTools)
I would like to complicate it with
<script>return store.getTaggedTiddlers("Completed" && !
"Urgent").length.toString();
</script>
Not Working

I am sure the answer is at the tip of my brain. . .

I also tried
<script>return store.getTaggedTiddlers
("Completed","Urgent").length.toString();
</script>

and a few other variations using var and trying to subtract the two

I appreciate any guidance, (Converting my fET calls to JS)

Mike

Eric Shulman

unread,
Apr 2, 2009, 8:38:03 PM4/2/09
to TiddlyWiki
> I would like to complicate it with
> <script>return store.getTaggedTiddlers("Completed" && !
> "Urgent").length.toString();
> </script>
>
> I appreciate any guidance, (Converting my fET calls to JS)

store.getTaggedTiddlers() only accepts a single tag value. Once you
retrieve the list of matching tiddlers, you could then write a loop
that checks each tiddler individually to look for the presense or
absense of any additional tag values, and then remove those items from
the list.

BUT... that's a lot of work, and not really needed. First, start by
installing
http://www.TiddlyTools.com/#MatchTagsPlugin
http://www.TiddlyTools.com/#MatchTagsPluginInfo

This plugin adds support for getting a list of matching tiddlers based
on compound boolean expressions using tag values, connected by AND
(&&), OR (||), and NOT (!) operators, with surrounding nested
parentheses as needed. For example:

(tagA && ((tagB || !tagC) && !(tagD || tagE)))

The plugin provides a macro, <<matchTags ...>> that permits you to
quickly generate and render simple formatted lists as tiddler output.
The plugin also defines an extended function that can be be invoked in
place of store.getTaggedTiddler:

store.getMatchingTiddlers("tag expression")

For example, something like this should work for your use-case:

<script>
return store.getMatchingTiddlers("Completed && !
Urgent").length.toString();
</script>

Lastly, the plugin also extends the core function:
store.filterTiddlers("[tag[tagValue]")
so that it can also be accept boolean expressions in place of the
single tagValue. As a result, any other existing plugins that make
use of this core function will be *automatically* enhanced with
boolean expression handling as well!

enjoy,
-e
Eric Shulman
TiddlyTools / ELS Design Studios
Reply all
Reply to author
Forward
0 new messages