Skip to content

Add option to use dot attribute access #44

@beasteers

Description

@beasteers

Hi! I just want to say that I love this package and it's super useful for things like offloading dashboard search and filtering logic to config files so thank you!

My only hangup is that you have to do y of x of config instead of config.x.y which to me feels a bit confusing and counter-intuitive. And it makes it harder to teach others about how to use the expressions because it goes against how you access data in most other languages.

I wonder if it'd be possible to add a filter compile option that allows you to enable dot attribute access? That way we could keep the default functionality, but allow for a more familiar config.x.y to access attributes (instead of key literals) if a user prefers.

A headstart on a solution?

I'm not very familiar with language grammar definitions so I'm sure this isn't all right, but I'm hoping it's in the right direction.

Add ['\\.', 'return ".";'], after this line?
https://github.com/m93a/filtrex/blob/20a016d5c13527047520de4573eaeda98a49e69f/src/generateParser.js#L39

Replace this regex with: '[a-zA-Z$_][a-zA-Z0-9$_]*'
https://github.com/m93a/filtrex/blob/20a016d5c13527047520de4573eaeda98a49e69f/src/generateParser.js#L44

Add ['left', '.'], after
https://github.com/m93a/filtrex/blob/20a016d5c13527047520de4573eaeda98a49e69f/src/generateParser.js#L80

Add ['e . SYMBOL', code(['prop(', 1, ',', 3, ')'])], (I think?)
https://github.com/m93a/filtrex/blob/20a016d5c13527047520de4573eaeda98a49e69f/src/generateParser.js#L111

Metadata

Metadata

Assignees

No one assigned

    Labels

    designAn issue regarding the user experienceenhancementNew feature or requestimplementedThis feature is implemented in `develop` and ready for testing

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions