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
NamingConvention and IIndexable or IDictionary #43
Comments
uhm seems I got it resolved, but have to check twice... UPDATE: |
Hi Alessandro, This is an interesting question! I'm pretty sure that (rightly or wrongly) this behaviour was intentional on my part. The motivation behind naming conventions was obviously to allow C# developers to use the naming conventions they are used to when writing their drops and filter methods, but let template authors use standard Liquid / Ruby naming conventions. But that doesn't apply to IIndexable or IDictionary, whose keys are (presumably) strings, and not code identifiers. Anonymous objects are different again, and perhaps should have the naming convention applied. I hesitate to make that kind of very-backwards-incompatible change - what do you think? Are you finding it's a real issue? |
Hi Tim, |
To me the behavior should be consistent everywhere. If the naming convention does not apply everywhere, I cannot tell people "the template is case insensitive", because that is partial truth. It is case insensitive when you use code identifiers, but otherwise it does not (there are other exceptions, see below). This seems like a leaky abstraction. Template writers should not care whether something is an IDictionary, an anonymous class, or a Drop. To them it is just a container with properties they can access by name. It might seem difficult to implement due to the following cases:
But to me, if someone picked a naming convention that is case insensitive, it is their responsibility to not let this happen or to know this is not possible given their Hashes/Drops/etc. LiquidMarkup processing should just pick the first thing it comes across that matches in a case insensitive manner. I found other places where this applies as well (depending on the result here, they will be created as separate issues):
|
I agree, and I do plan to standardise this behaviour in 2.x. I agree with you that if developers choose a case-insensitive naming convention, then it's reasonable to expect all name lookups to be case-insensitive too. On your secondary points:
|
To me effectively any look ups have to take the naming convention and string comparison into account. I am using this naming convention:
Which to me, would mean that anything can be specified in any case (constants, tags, filters, filter arguments, built-in variables, etc.). It might be that I am trying to use LiquidMarkup for something it was not intended to be used for. If I am going someplace with this that does not fit into the purpose of DotLiquid, please let me know. |
Hi Tim,
it seems we have a major bug... if we pass in an IIndexable or IDictionary, DotLiquid does not take into account NamingConvention and keys resolution fail.
I've been looking on a way to resolve but found anything, do you have any idea?
The text was updated successfully, but these errors were encountered: