"list" filter op without text reference?

In my current project, I have several occurrence of things like I want to iterate on the columns names stored on the columns field of a tiddler named by a variable. All this would be fine if filter code like this was possible:

[<mydata>list[columns]]

But the list filter op only operates on text reference! I can build the reference within the filter but I can’t use :map next because it would only take the first column name! (and it would be quite a lot of code for so trivial a thing)

I could use get then split since my column names don’t have any space but:
1 ) it would lose a clear intent;
2) what if I had space (or similar but different use case)?

Would it be a good idea to alter list so that I could code:

[<mydata>list:field[columns]]

or even (while we’re at it)

[<mydata>list:index[columns]]

or should it be better to create a new listfield operator to have:

[<mydata>listfield[columns]]

Try this filter:
[<mydata>get[columns]enlist-input[]]

Thank you @EricShulman this is fine.

Yet I would say it would be nice to have

[<mydata>enlist-input[columns]]

but surely enlist-input would not be the right name. enlist-field… About the same proposal.

Anyway, it allows me to immediately have a better, functioning code!

Another method:

<$tiddler tiddler=<<mydata>>>
<$list filter="[list[!!columns]]">

</$list>
</$tiddler>

@EricShulman I ajso saw that but in my case, I cannot alter the currentTddler value.

In the end, I eleborate the listfield filter operator which enables to power code such as below:

{{{ [prefix[$:/user/eva/db/]listfield[tablabel],[columns]] }}}

The code is very simple. I have not coded the “!” modifier for I cannot sea a good reason to use it. See the json file of this post. Here is the code:

(function(){

/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";

/*
Export our filter function
*/
  exports.listfield = function(source,operator,options) {
    let results = [];
    let fields = (operator.operands) ? operator.operands : ["list"];
    source(function(tiddler,title) {
        fields.forEach((item, index) => {
          let list = options.wiki.getTiddlerList(title, item, "");
          results = results.concat(list);
        });
    });
    return results;
  };

})();

_system_user_common_filters_listfield.js.json (1.0 KB)