Hi!
I just wanted to create a listbox containing the section names of a
tiddler. So I wrote something like this (broken for readability):
<<select myField rows:1 {{
store.getTiddlerText("myTiddlerWithSections").match( /^!.*$/gm );
}} >>
As you might expect, this did not work. Just the first section name
appeared and it hat an exclamation mark as first character.
So I had to find a way to get more parameters out of one JavaScript section.
Examining the ListBoxPlugin, I couldn't find a way except for - maybe - the
"*Tiddler" or "+Tiddler" notation. But "+" didn't fit to my needs and "*"
seemed a bit too much.
So I came up with another solution and I propse this as an enhancement for
the ListBoxPlugin.
If a parameter starts with "|" (pipe symbol) the parameter contains the
items, seperated by "|". It's required to have a "|" also at the end. This
looks exactly like a table row. The patch required are these 2 lines:
else if (p.startsWith("|")) // get items from "table row"
items= items.concat( p.slice(1,-2).split("|") );
which I put just before
else if (p.substr(0,1)=="+"||p.substr(0,1)=="*") { // read HR-separated tiddler
Using this enhancement, my initial problem can be solved very easily with
this small piece of code:
<<select myField rows:1 {{
store.getTiddlerText("myTiddlerWithSections").match( /^!.*$/mg
).join("").replace( /!(END$)?/g, "|")
}}>>
match: Find all Sections
join: join them to one long string like this: "!Sec1!Sec2!Sec3"
replace: Change each ! to a |. Additionally my last section ("END") is
removed.
--
You received this message because you are subscribed to the Google Groups
"TiddlyWikiDev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/tiddlywikidev?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.