Skip to content

Add Path.Lookup - #70

Merged
StefH merged 16 commits into
masterfrom
dictionary-lookup
Mar 1, 2023
Merged

Add Path.Lookup#70
StefH merged 16 commits into
masterfrom
dictionary-lookup

Conversation

@StefH

Copy link
Copy Markdown
Collaborator

No description provided.

@StefHStefH added the enhancement New feature or request label Feb 20, 2023
@StefHStefH self-assigned this Feb 20, 2023
@codecov

codecovBot commented Feb 20, 2023

Copy link
Copy Markdown

Codecov Report

Merging #70 (5e16b8c) into master (d6fe6df) will increase coverage by 0.99%.
The diff coverage is 68.13%.

❗ Current head 5e16b8c differs from pull request most recent head 2651c94. Consider uploading reports for the commit 2651c94 to get more accurate results

@@ Coverage Diff @@## master #70 +/- ##
==========================================
+ Coverage 43.98% 44.97% +0.99% 
==========================================
Files 40 43 +3 Lines 2626 2679 +53 Branches 362 367 +5 ==========================================
+ Hits 1155 1205 +50 - Misses 1372 1375 +3 
Partials 99 99 
Impacted FilesCoverage Δ
...c/Handlebars.Net.Helpers.Core/Utils/ObjectUtils.cs0.00% <0.00%> (ø)
...ebars.Net.Helpers.DynamicLinq/JObjectExtensions.cs57.25% <ø> (+4.62%)⬆️
...ers.DynamicLinq/Models/DynamicPropertyWithValue.cs80.00% <ø> (ø)
...ars.Net.Helpers/Extensions/MethodBaseExtensions.cs25.92% <31.57%> (+12.88%)⬆️
....Helpers.DynamicLinq/Helpers/DynamicLinqHelpers.cs18.40% <76.19%> (+5.36%)⬆️
src/Handlebars.Net.Helpers/HandlebarsHelpers.cs82.07% <90.90%> (+1.17%)⬆️
.../Handlebars.Net.Helpers/Helpers/DateTimeHelpers.cs66.66% <100.00%> (ø)
src/Handlebars.Net.Helpers/Helpers/PathHelpers.cs100.00% <100.00%> (ø)
...ars.Net.Helpers/PathStructure/PathResolverProxy.cs100.00% <100.00%> (ø)
... and 1 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@oformaniuk

Copy link
Copy Markdown
Member

How is this different from build-in lookup helper?

@StefH

Copy link
Copy Markdown
CollaboratorAuthor

@zjklee
Ah. I understand. There's a builtin helper.
But that helper does not allow for 3 arguments with a defaultValue.

So a change could be like:

usingHandlebarsDotNet.PathStructure;namespaceHandlebarsDotNet.Helpers{publicsealedclassLookupReturnHelperDescriptor:IHelperDescriptor<HelperOptions>{publicPathInfoName{get;}="lookup";publicobjectInvoke(inHelperOptionsoptions,inContextcontext,inArgumentsarguments){if(arguments.Length!=2&&arguments.Length!=3){thrownewHandlebarsException("{{lookup}} helper must have two or three arguments");}varsegment=ChainSegment.Create(arguments[1]);vardefaultValueIfNotFound=arguments.Length==3?arguments[2]:UndefinedBindingResult.Create(segment);return!options.TryAccessMember(arguments[0],segment,outvarvalue)?defaultValueIfNotFound:value;}publicvoidInvoke(inEncodedTextWriteroutput,inHelperOptionsoptions,inContextcontext,inArgumentsarguments){output.Write(Invoke(options,context,arguments));}}}

@oformaniuk

Copy link
Copy Markdown
Member

@StefH , looks good to me 🙂

@StefH

Copy link
Copy Markdown
CollaboratorAuthor

@zjklee Shall I create a PR for Handlebars.Net ?

@StefH

Copy link
Copy Markdown
CollaboratorAuthor

@zjklee See PR Handlebars-Net/Handlebars.Net#542

@StefHStefH changed the title Add Dictionary.LookupAdd Path.LookupFeb 21, 2023
@StefHStefH mentioned this pull request Mar 1, 2023
@StefH
StefH merged commit 52a23df into masterMar 1, 2023
@StefH
StefH deleted the dictionary-lookup branch March 1, 2023 15:54
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancementNew feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@StefH@oformaniuk