Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Constant strings as an argument #27

Closed
Koudysmen opened this issue Oct 27, 2020 · 3 comments · Fixed by #29
Closed

Constant strings as an argument #27

Koudysmen opened this issue Oct 27, 2020 · 3 comments · Fixed by #29
Labels
bug Something isn't working

Comments

@Koudysmen
Copy link

Hi guys,

I have a problem with my custom Helper if i using more than one constant string as an argument in a row then my helper is not invoked.

Helper register

helpers.Register("ReplaceString", (HelperContext context, string searchString, string oldString, string newString) => searchString?.Replace(oldString, newString, StringComparison.InvariantCulture));

Render template

renderer.Render("Name: {{ReplaceString Name 'XXX' ''}}", new
            {
                Name = "JohnXXX"
            });

Basically I want to replace XXX with empty string. But the result is just Name: So there are something wrong.

But when I changed the order of the arguments in the template then my custom helper working correctly.

Helper register

helpers.Register("ReplaceString", (HelperContext context, string oldString, string searchString, string newString) => searchString?.Replace(oldString, newString, StringComparison.InvariantCulture));

Render template

renderer.Render("Name: {{ReplaceString  'XXX' Name ''}}", new
            {
                Name = "JohnXXX"
            });

Then result is correct: Name: John

In my assumption stubble helper does not support more than one constant string as an argument in a row currently. It will be great when stubble helper will be support it because this functionality would be useful for us.

Thanks, Michal

@Romanx
Copy link
Contributor

Romanx commented Nov 2, 2020

Hi,

Thanks for the comprehensive report, this looks like a genuine bug since this should be an accepted case. I'll take a look as soon as I can,

Thanks for using Stubble 👍

@Romanx Romanx added the bug Something isn't working label Nov 2, 2020
@Romanx Romanx closed this as completed in #29 Nov 8, 2020
@Romanx
Copy link
Contributor

Romanx commented Nov 8, 2020

Hey,

Thanks for reporting this. It was actually a one line fix in the end but we added tests around this area to make sure we don't regress. The fix is now on nuget in release 1.1.3

Thanks for using Stubble and let us know if you have any issues!

@Koudysmen
Copy link
Author

Hi,
Great, Thanks a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants