| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Codecov Report
@@ 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
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Sorry, something went wrong.
|
How is this different from build-in lookup helper? |
Sorry, something went wrong.
|
@zjklee So a change could be like: using HandlebarsDotNet.PathStructure;
namespace HandlebarsDotNet.Helpers
{
public sealed class LookupReturnHelperDescriptor : IHelperDescriptor<HelperOptions>
{
public PathInfo Name { get; } = "lookup";
public object Invoke(in HelperOptions options, in Context context, in Arguments arguments)
{
if (arguments.Length != 2 && arguments.Length != 3)
{
throw new HandlebarsException("{{lookup}} helper must have two or three arguments");
}
var segment = ChainSegment.Create(arguments[1]);
var defaultValueIfNotFound = arguments.Length == 3 ? arguments[2] : UndefinedBindingResult.Create(segment);
return !options.TryAccessMember(arguments[0], segment, out var value)
? defaultValueIfNotFound
: value;
}
public void Invoke(in EncodedTextWriter output, in HelperOptions options, in Context context, in Arguments arguments)
{
output.Write(Invoke(options, context, arguments));
}
}
} |
Sorry, something went wrong.
|
@zjklee Shall I create a PR for Handlebars.Net ? |
Sorry, something went wrong.
|
@zjklee See PR Handlebars-Net/Handlebars.Net#542 |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
No description provided.