Oh,

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

Regards
Tones

On Monday, 26 July 2021 at 17:42:45 UTC+10 Eric Shulman wrote:

> On Monday, July 26, 2021 at 12:02:43 AM UTC-7 TW Tones wrote:
>
>> I thought I had missed this all a long, not that it was in the process of 
>> creation.
>>
>
> I created the edit-list macro quite a while ago for use in 
> http://TiddlyTools.com/filtergenerators.html, but I've only recently 
> completely re-written it to be much more robust and have many new optional 
> parameters.
> I've also finally put in the work to document it properly and publish it 
> as a stand-alone TiddlyTools URL (http://TiddlyTools.com/edit-list.html)
>
> So these two questions arise;
>>
>>    - Can we abolish the ID or make it equal to a 
>>    *tiddler-title-fieldname* (slugifyeld)?
>>
>> I'm actually doing something like this already.   The code currently 
> generates an ID by combining the target tiddler title, the target fieldname 
> or indexname, an optional ID param, and a system <<qualify>>.  To do this, 
> I use the following:
> <$vars   tid={{{ [[$tiddler$]!match[]else<currentTiddler>] }}} 
> re="[^a-zA-Z0-9\-\_]">
> <$vars    id={{{ [[$index$]!match[]else[$field$]] 
> +[addprefix[/]addprefix<tid>addsuffix[_$id$]] }}}>
> <$vars    id={{{ 
> [<id>search-replace[$:/],[]search-replace:g:regexp<re>,[_]addsuffix<qualify>search-replace[--],[-]]
>  
> }}}>
>
> Note that this is somewhat different than using the slugify[] filter 
> operator, as my method converts all non-alphanumerics (plus "-" and "_" 
> into "_"), and preserves capitalization.  In contrast, slugify[] retains 
> period "." and converts letters to lower case.
> Retaining "." is not an option for my code, since the id is actually used 
> to construct CSS selectors, which use "." as part of their syntax, so it 
> can't be part of the ID itself.  In any case, without using the *optional* 
> "id:..." param, each edit-list instance is very likely to be unique, and 
> the "id:..." param is now only needed under very specific circumstances.
>
>>
>>    - 
>>       - Yes I expect I will have multiple edit-list macros in one 
>>       tiddler, and possibly more than one tiddler displayed at once.
>>    
>> See the "id parameter" discussion in the Notes section here: 
> https://tiddlytools.com/edit-list.html#TiddlyTools%2FMacros%2Fedit-list%2FInfo
>  
> for more details
>
>>
>>    - Is there any way I could avoid passing the same parameter=value 
>>    pairs every time? such that I need only set the other parameters?
>>       - field=<<fieldname>>  
>>       filter=<<field-values-filter>> placeholder=<<field.placeholder>>  
>>       tooltip=<<field-tooltip>>
>>       - I could make a custom version of edit-list perhaps by modifying 
>>       the $vars widget?
>>    
>> Elsewhere I have used a design pattern where if the parameter is 
>> provided, use it eg $parameter$, if the parameter is not provided eg 
>> emptyValue use another source.
>> eg; field parameter has no value use <<fieldname>> 
>>
> Is it correct then *if following the $vars widget in edit list* I could 
>> specify something like this?
>> <$set name=field value=<<field>> emptyValue=<<fieldname>> >
>> <$set name= filter value=<<filter>> emptyValue=<<field-values-filter>> >
>> <$set name= placeholder value=<<placeholder>> emptyValue= 
>> <<field.placeholder>>   >
>> <$set name=tooltip value=<<tooltip>> emptyValue=<<field-tooltip>> >
>>
> Then before the closure of $vars place </$set></$set></$set></$set> *can 
>> you tell me where this is?*
>>
>
> Here's a neat little trick:  if the <$vars> are declared at the top level 
> of the macro definition (i.e., not nested within some other widgets or 
> HTML), then they are all automatically closed when the end of the macro is 
> reached.  Thus, I only need to declare the <$vars> (or <$set>) and don't 
> have to worry about having any matching </$vars> (or </$set>)
>  
>
>> It would become possible for pesky designer like me to edit the edit-list 
>> macro to make use of my own variables, rather than parameters by providing 
>> a variable in the matching set parameter, however if the $paramname$ is set 
>> it will still behave as advertised/documented?
>>
>> Then I could simply use <<edit-list>> OR <$macrocall $name=edit-list 
>> *[additional 
>> parameter values]* /> and my default variables will be used.
>>
>
> This is an interesting approach.
>
> *I really appreciate your self documenting and well laid out macro*, it 
>> makes it possible for me to modify, or more importantly ask you for this 
>> feature, while presenting an actual mechanism, hopefully to make such a 
>> modification possible. If you can do this I may revisit my field 
>> definitions and allow them to set the variables needed by the edit-list 
>> macro if desired, making it much simpler to use, because I can guide the 
>> user to providing the parameters needed to the edit-list macro.
>>
>
> Let me give it a try and see how well I can make it work. 
>
> -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 tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/4728655f-bc67-4244-b952-da497892c7d6n%40googlegroups.com.

Reply via email to