I’m trying to get my head around resources metadata rules and their ordering.
I understand from the doc that we should start by the more precise rule and then add the broader ones otherwise detailed rules will be overwritten.
In this exemple it appears that only document/payment.docx will end up with the proper icon. All the others won’t. It is like the different rules’ “params” object is not merged but overwritten complety.
So only the resource with no params in its detailed route gets the right icon.
Is this by design ? I’m sure it makes sense somehow and I overlooked something, but I appear a bit lost here
Here, for the files where params -> ref is already set, params -> icon does not get set.This gets fixed with Hugo PR # 4316.
This behavior makes sense for name and title. But for params where new user-defined parameters can be added in step-wise src lines, the behavior feels wrong.
Update (2018/01/23): I confirm the param merging feature in Hugo PR # 4316. The Hugo Output links in the above test cases now show the outputs created using that PR build. Thanks @bep!
I’m not sure that can be expressed in a non-ambiguous way with the current syntax. I understand your particular example, but that is a fairly simple one. If someone can describe and implement a working “merge logic”, I will merge.
@bep One should be using the correct globbing pattern for src. Is author wasn’t meant to be applied to all files, then *.* shouldn’t have been applied.
On another note, even if some params are applied to unintended files, user has another level of control at the time of using those params via .Match… example: OK… author got applied to *.*… but then the user can choose to print the author on the page only for the set .Match glob. WDYT?
Maybe still a stupid example, but if I blindly merge the params map I would:
get values for the secret docs that I don’t want
you could argue that I should not have included “secret” in the second matcher, but how do I do that? I assume there are some negative matching possible here, but …
If the user has defined the src = "*.doc" rule then he should expect all of his doc files to hold username and password.
And he should expect any doc file with “secret” in his name or path to have someparams as well.
This is the behaviour I expect, and cannot see the harm in that
What I don’t expect is to lose the username and password params I defined for all of my doc files, simply because one of those doc needed an extra param.
I am sorry I cannot see the problem here. Maybe someone else can help me
Under the current behavior, the username and password would apply to "*Secret2*.doc" too! That also doesn’t look like the right behavior.
The solution is simple: The user should be careful when assigning parameters using blanket globs like *.*, *.jpg, etc.
The current logic that once name and title are set, they shouldn’t be set again makes sense. The suggestion is that that same logic be applied inside something like {{ range .Params }} instead of to the whole of .Params.
That is well defined behaviour and easy to work around. Your suggested change is extremely hard to wrap your head around if you have many rule sets, and it is ambiguous.
This is not about leaking secrets (I knew my example was bad).
With your suggested change I have no easy way to apply one parameter set to “mypattern.jpg” and another different default parameter set to the other images.
You can easily solve the other problem by duplicating the icon parameter etc.
So, the current solution may be sub-optimal for this particular use case, but at least it doesn’t break if you look hard at it.
With your suggested change I have no easy way to apply one parameter set to “mypattern.jpg” and another different default parameter set to the other images.
I am still struggling to understand why that is hard… one can easily plan ahead and have something like:
src = "*.jpg"
params
foo = "some param specific to JPEGs"
src = "*.pdf"
params
bar = "some param specific to PDFs"
Now if you enable param merging, it would be nice to have:
src = "*.[pj][dp][fg]"
params
zoo = "params common to .pdf and .jpg (and .ppg, pdg, .. ;-))"
It feels like we are talking about the same thing, but in one approach A is easy, B is difficult; and in the other approach A is difficult, B is easy… but both A and B are achievable in both approaches. You approach is to implicitly create filter sets for params. My approach is to let the user manually create filter sets using src.
src = "*noboo*.jpg"
params
foo = "some param specific to noboo JPEGs"
src = "*.jpg"
params
foo = "some param specific to JPEGs"
boo = "some other param"
So in the noboo case I do not want the boo value. How do I do that? You may argue that I can just ignore/throw it away, but I how do I do that if I just loop the key/values?
I cannot think of a real use case like that. I would just plan ahead and name the files appropriately (may be put files in boo/ subdir vs noboo/ subdir) if any such kind of mutually exclusive parameter assignment needs to happen. So it’s back to the usecase-per-user problem. The problem you are seeing doesn’t apply to me, and the problem I am seeing doesn’t apply to you
I see the use case you are referring too, but cannot identify with it.
I want to easily assigne params to mulitple resources. For me it seems the be the priority. Having to copy/paste the icon params for my exemple above doesn’t really make sense.
Having to be aware that noboo inherit the boo param no matter what is something I can live with. I could still overwrite it with boo = false if that comes to it.
But again, that is just one opinion. I think we need more.