-
-
Notifications
You must be signed in to change notification settings - Fork 397
Description
I have declared .net function
public static class ResourceService
{
public static string Resource(string language, string key)
{
if (_generalResources.TryGetValue(language, out IReadOnlyDictionary<string, string> value) && value.ContainsKey(key))
{
return value[key];
}
else
{
return null;
}
}
}And i have custom template, that have this section to render by scriban:
"{{ $"{resource "ru-RU" $"General.{string.capitalize require_for_auto_test}"}" }}"
require_for_auto_test is a boolean variable, that comes as incoming arguments
When I try to render template with this code snippet
ScriptObject scribanObject = new ();
scribanObject.Import(arguments, null, null);
scribanObject.Import(typeof(ResourceService));
TemplateContext context = new ();
context.PushGlobal(scribanObject);
string renderResult = await scribanTemplate.RenderAsync(context);And renderResult return not null or some other value from Resource function. Instead, renderResult returns "True". While debugging my c# code i discovered that scriban called imported function Resource without attempting to interpolate second argument (string key) of function (In C# debugger i see just "General."). After Resource function returned null, RenderAsync returns just "True" (or "False" - depends on value of require_for_auto_test variable) instead of "null". It's looks like scriban print result of string interpolation $"General.{string.capitalize require_for_auto_test}".
Expected behavior: at first, scriban interpolate string $"General.{string.capitalize require_for_auto_test}" and then calls function $"{resource "ru-RU" "General.True"}"
Current version of scriban library: 5.10.0