StubbleOrg / Stubble

Trimmed down {{mustache}} templates in .NET
Other
399 stars 58 forks source link

Execute method with parameter's default value #127

Closed valeev closed 2 years ago

valeev commented 2 years ago

Hello there, I am stuck with small task, I want to execute a function which has parameter but this parameter has default value

From example Below I am expecting to get "CityV1" from last render

using Stubble.Core.Builders;

var stubble = new StubbleBuilder().Configure(settings => {
    settings.SetIgnoreCaseOnKeyLookup(true);
    settings.SetMaxRecursionDepth(512);
}).Build();

var vals = new Values();

var temp = stubble.Render("{{temp}}", vals);
var town = stubble.Render("{{town}}", vals);
var city = stubble.Render("{{city}}", vals);

System.Console.WriteLine($"{temp}");  // Temp
System.Console.WriteLine($"{town}");  // Town123
System.Console.WriteLine($"{city}");  // 

public class Values
{
    public string Temp = "Temp";
    public string Town()
    {
        return "Town123";
    }
    public string City(int v = 1)
    {
        return $"CityV{v}";
    }
}

https://dotnetfiddle.net/9rqB6w

valeev commented 2 years ago

@Romanx thanks for fix, do you have any expectations when 1.10 can be released to nuget?

Romanx commented 2 years ago

Hi @valeev, hopefully I should be able to get it out today or tomorrow.

Thanks for submitting the issue and a clear repro

valeev commented 2 years ago

@Romanx hope you are doing well, just wanted to check situation around 1.10, is it possible to push it at least as pre-release? Thanks for reply in advance.

Romanx commented 2 years ago

Hey @valeev! Thanks for your patience this has now been released to nuget as v1.10.8

Thanks for using stubble and letting us know about this