Handlebars-Net / Handlebars.Net

A real .NET Handlebars engine
MIT License
1.25k stars 216 forks source link

Add one More Compile Method Overload #527

Closed HaruTzuki closed 1 year ago

HaruTzuki commented 1 year ago

I am working in a project and I thought this will be a great method.

sonarcloud[bot] commented 1 year ago

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

100.0% 100.0% Coverage
0.0% 0.0% Duplication

rexm commented 1 year ago

I'm curious what is the use case for this?

HaruTzuki commented 1 year ago

In order to compile a text with handlerbars you need first to compile the text to take the template and after that you need to pass the object. I decided it will be great this to happens in one line if you need to use it in a lamda expression e.g.

public string GetText(string source, object handles)=>Handlebars.Compile(source, handles); // something like that.

rexm commented 1 year ago

I’m not sure we’d want to promote this style of usage to be a peer method with the other Compile methods. For many developers who do not understand all the implications, this is needlessly recompiling the template every time the input changes, just to save a line of code. If it’s so important to include as a convenience, how could we make it more obvious this is fundamentally different than merely compiling?

HaruTzuki commented 1 year ago

Ok then... Delete the PR.

rexm commented 1 year ago

Happy to reopen if anyone feels strongly enough about this to address the ergonomics issue.