Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why there are "each" versions of functions? #3

Open
mitar opened this issue Jan 5, 2022 · 1 comment
Open

Why there are "each" versions of functions? #3

mitar opened this issue Jan 5, 2022 · 1 comment

Comments

@mitar
Copy link

mitar commented Jan 5, 2022

I think it could be simplified so that one could do:

type PageData struct {
	Link    string   `pagser:"a->attr(href)"`
	Links   []string `pagser:"a->attr(href)"`
}

The package could inspect the type associated with the tag and if it is slice, automatically assume "each" behavior. In general I think all functions should be returning slices, which then optionally are converted to an individual value (by default the first one, but you could set using ->Eq some other index).

@foolin
Copy link
Owner

foolin commented Oct 29, 2022

It like a good idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants