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

Add .Resources.ByMatch and GetByMatch #4301

Closed
regisphilibert opened this issue Jan 19, 2018 · 3 comments
Closed

Add .Resources.ByMatch and GetByMatch #4301

regisphilibert opened this issue Jan 19, 2018 · 3 comments

Comments

@regisphilibert
Copy link
Member

Add to Resources a method for retrieving resources using a matching pattern (images/*.jpg)
Uses the same value to match against as the existing ByPrefix

@bep
Copy link
Member

bep commented Jan 19, 2018

We should also add GetByMatch fro completeness.

@bep bep added this to the v0.33.1 milestone Jan 19, 2018
@bep
Copy link
Member

bep commented Jan 19, 2018

I will add those to a patch release ... But I will probably wait to see if more bugs "happens" until I go that route. The implementation should be trivial.

@bep bep changed the title Add .Resources.ByMatch (or something) Add .Resources.ByMatch and GetByMatch Jan 19, 2018
bep added a commit to bep/hugo that referenced this issue Jan 20, 2018
A simple benchmarks comparing it to the *Prefix variant doing the same:

```bash
BenchmarkResourcesByPrefix-4         200000          6903 ns/op         505 B/op           3 allocs/op
BenchmarkResourcesByMatch-4          200000          8841 ns/op         505 B/op           3 allocs/op
```

Fixes gohugoio#4301
bep added a commit to bep/hugo that referenced this issue Jan 21, 2018
These methods takes a glob pattern as argument:

* by default matching from the bundle root
* matching is case insensitive and the separator is Unix style slashes: "/"
* the bundle root does (by default) not start with a leading slash
* if you renames the `Name` for the rsource in front matter (`src=...`), then that is the value used in `Match`.
* double asterisk matches beyond directory borders, so "**.jpg" will match any JPEG image in the bundle

See https://github.com/gobwas/glob

Fixes gohugoio#4301
bep added a commit to bep/hugo that referenced this issue Jan 21, 2018
These methods takes a glob pattern as argument:

* by default matching from the bundle root
* matching is case insensitive and the separator is Unix style slashes: "/"
* the bundle root does (by default) not start with a leading slash
* if you renames the `Name` for the rsource in front matter (`src=...`), then that is the value used in `Match`.
* double asterisk matches beyond directory borders, so "**.jpg" will match any JPEG image in the bundle

See https://github.com/gobwas/glob

This commit also deprecates `ByPrefix` and `GetByPrefix`.

Fixes gohugoio#4301
bep added a commit to bep/hugo that referenced this issue Jan 21, 2018
These methods takes a glob pattern as argument:

* by default matching from the bundle root
* matching is case insensitive and the separator is Unix style slashes: "/"
* the bundle root does (by default) not start with a leading slash
* if you renames the `Name` for the rsource in front matter (`src=...`), then that is the value used in `Match`.
* double asterisk matches beyond directory borders, so "**.jpg" will match any JPEG image in the bundle

See https://github.com/gobwas/glob

This commit also deprecates `ByPrefix` and `GetByPrefix`.

This should also be more effective, given a fair amount of reuse of the glob patterns:

```bash
BenchmarkResourcesByPrefix-4         300000          4284 ns/op        1130 B/op           7 allocs/op
BenchmarkResourcesMatch-4            300000          5220 ns/op         505 B/op           3 allocs/op
```

Fixes gohugoio#4301
bep added a commit to bep/hugo that referenced this issue Jan 22, 2018
These methods takes a glob pattern as argument:

* by default matching from the bundle root
* matching is case insensitive and the separator is Unix style slashes: "/"
* the bundle root does (by default) not start with a leading slash
* if you renames the `Name` for the rsource in front matter (`src=...`), then that is the value used in `Match`.
* double asterisk matches beyond directory borders, so "**.jpg" will match any JPEG image in the bundle

See https://github.com/gobwas/glob

This commit also deprecates `ByPrefix` and `GetByPrefix`.

This should also be more effective, given a fair amount of reuse of the glob patterns:

```bash
BenchmarkResourcesByPrefix-4         300000          4284 ns/op        1130 B/op           7 allocs/op
BenchmarkResourcesMatch-4            300000          5220 ns/op         505 B/op           3 allocs/op
```

Fixes gohugoio#4301
@bep bep modified the milestones: v0.33.1, v0.34 Jan 22, 2018
@bep bep closed this as completed in 9421380 Jan 22, 2018
bep added a commit that referenced this issue Jan 22, 2018
@github-actions
Copy link

github-actions bot commented Mar 8, 2022

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants