Handlebars-Net / Handlebars.Net.Helpers

Handlebars.Net helpers in the categories: 'Boolean', 'Constants', 'Enumerable', 'Environment', 'Math', 'Regex', 'String', 'DateTime' and 'Url'.
MIT License
40 stars 15 forks source link

Should DynamicLinq be used? #54

Closed natelaff closed 1 year ago

natelaff commented 2 years ago

Is the DynamicLinq helper production ready? It's not mentioned in readme and in code it seems to hint that it's only for backcompat.

I was going to craft a helper similar to Select where it could check the value of an item in array. For instance, I need to iterate through a lookup array, and check a collection to see if it has a matching ID there. I thought maybe I could do this with the linq helper using Any() or something, but thought I'd check your thoughts!

An ifExists or ifIn helper might be a nice add. I am going to take a stab at it... not quite sure how to make that dynamic the way I need but... we'll figure it out maybe

StefH commented 2 years ago

Handlebars.Net.Helpers.DynamicLinq can be used, I just did not have time yet to create/update the wiki

An ifExists or ifIn helper might be a nice add Yes, you can create a PR.

StefH commented 1 year ago

@natelaff

was going to craft a helper similar to Select where it could check the value of an item in array. For instance, I need to iterate through a lookup array, and check a collection to see if it has a matching ID there. I thought maybe I could do this with the linq helper using Any() or something, but thought I'd check your thoughts!

There is already a Enumerable helper for that : https://github.com/Handlebars-Net/Handlebars.Net.Helpers/wiki/Enumerable

But I also added more functionality to DynamicLinq. (https://github.com/Handlebars-Net/Handlebars.Net.Helpers/pull/71) and ()https://github.com/Handlebars-Net/Handlebars.Net.Helpers/pull/70.

I'll create a new NuGet including this logic.

And I did update the wiki a bit: https://github.com/Handlebars-Net/Handlebars.Net.Helpers/wiki/DynamicLinq

natelaff commented 1 year ago

@StefH cool! I will give it a try. Enumerable didn't work with complex objects. So the thinking was it would need to take in a property name that it would check if that value exists in that member.

StefH commented 1 year ago

@natelaff you can test version 2.3.14-preview-03