OK... so I thought of a really neat way to achieve your goal *without
modifying my macro!*
Give this a try:
First, Create a tiddler (e.g., MyMacros/edit-list), tagged with
$:/tags/Macro, containing:
\define my-edit-list(
id, tiddler, field, index, timestamp,
default, placeholder, tooltip, type, width,
filter, find, goto, confirm, focus,
focusPopup, cancelPopups, listwidth, listheight, scroll,
fontsize, stretch, colors, multiple, view
)
<$vars
id={{{ [[$id$]!is[blank]else<id>!is[blank]else[]]
}}}
tiddler={{{ [[$tiddler$]!is[blank]else<tiddler>!is[blank]else[]]
}}}
field={{{ [[$field$]!is[blank]else<field>!is[blank]else[text]]
}}}
index={{{ [[$index$]!is[blank]else<index>!is[blank]else[]]
}}}
timestamp={{{
[[$timestamp$]!is[blank]else<timestamp>!is[blank]else[yes]] }}}
default={{{ [[$default$]!is[blank]else<default>!is[blank]else[]]
}}}
placeholder={{{
[[$placeholder$]!is[blank]else<placeholder>!is[blank]else[]] }}}
tooltip={{{ [[$tooltip$]!is[blank]else<tooltip>!is[blank]else[]]
}}}
type={{{ [[$type$]!is[blank]else<type>!is[blank]else[]]
}}}
width={{{ [[$width$]!is[blank]else<width>!is[blank]else[15em]]
}}}
filter={{{ [[$filter$]!is[blank]else<filter>!is[blank]else[]]
}}}
find={{{ [[$find$]!is[blank]else<find>!is[blank]else[no]]
}}}
goto={{{ [[$goto$]!is[blank]else<goto>!is[blank]else[no]]
}}}
confirm={{{ [[$confirm$]!is[blank]else<confirm>!is[blank]else[no]]
}}}
focus={{{ [[$focus$]!is[blank]else<focus>!is[blank]else[no]]
}}}
focusPopup={{{
[[$focusPopup$]!is[blank]else<focusPopup>!is[blank]else[no]] }}}
cancelPopups={{{
[[$cancelPopups$]!is[blank]else<cancelPopups>!is[blank]else[yes]] }}}
listwidth={{{
[[$listwidth$]!is[blank]else<listwidth>!is[blank]else[100%]] }}}
listheight={{{
[[$listheight$]!is[blank]else<listheight>!is[blank]else[1]] }}}
scroll={{{ [[$scroll$]!is[blank]else<scroll>!is[blank]else[10]]
}}}
fontsize={{{
[[$fontsize$]!is[blank]else<fontsize>!is[blank]else[1em]] }}}
stretch={{{ [[$stretch$]!is[blank]else<stretch>!is[blank]else[yes]]
}}}
colors={{{ [[$colors$]!is[blank]else<colors>!is[blank]else[no]]
}}}
multiple={{{ [[$multiple$]!is[blank]else<multiple>!is[blank]else[no]]
}}}
view={{{ [[$view$]!is[blank]else<view>!is[blank]else[<<item>>]]
}}}
>
<$macrocall $name="edit-list"
id=<<id>>, tiddler=<<tiddler>>,
field=<<field>>, index=<<index>>, timestamp=<<timestamp>>,
default=<<default>>, placeholder=<<placeholder>>,
tooltip=<<tooltip>>, type=<<type>>, width=<<width>>,
filter=<<filter>>, find=<<find>>,
goto=<<goto>>, confirm=<<confirm>>, focus=<<focus>>,
focusPopup=<<focusPopup>>, cancelPopups=<<cancelPopups>>,
listwidth=<<listwidth>>, listheight=<<listheight>>, scroll=<<scroll>>,
fontsize=<<fontsize>>, stretch=<<stretch>>,
colors=<<colors>>, multiple=<<multiple>>, view=<<view>> />
\end
Basically, you define an alternative "wrapper" around my macro, that
handles the $vars-based parameter definitions, and then call my macro from
it.
The advantage is that *you don't have to change even one line of my code*,
and you can even *re-define the fallback default values*!
To use it you can put something like this in a tiddler:
<$vars tiddler="foo" filter="[all[tiddlers]!is[system]]">
<<my-edit-list>>
</$vars>
<$vars tiddler="bar" field="tags" filter="[all[tiddlers+shadows]tags[]]"
width=20em placeholder="select a tag">
<<my-edit-list>>
</$vars>
enjoy,
-e
On Monday, July 26, 2021 at 6:36:07 AM UTC-7 Eric Shulman wrote:
> On Monday, July 26, 2021 at 5:07:07 AM UTC-7 TW Tones wrote:
>
>> This method mentioned later for setting variables to use in edit-list may
>> be better (although untested)
>> <$vars
>> field={{{ [[$field$]is[blank]then<fieldname>] }}}
>> paramname={{{ [[$paramname$]is[blank]then<varname>] }}}
>> >
>>
>
> The following handles two levels of fallback:
>
> 1. if the param is passed to the macro
> 2. else if the param is set as a variable
> 3. else use a default value
>
> For example, the field value should default to "text" if not provided by
> either param or variable:
> <$vars field={{{ [[$field$]!is[blank]else<field>!is[blank]else[text]] }}}>
>
> -e
>
--
You received this message because you are subscribed to the Google Groups
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/tiddlywiki/27a83b1c-f06d-4dc3-ad71-ede84f92224dn%40googlegroups.com.