StubbleOrg / Stubble

Trimmed down {{mustache}} templates in .NET

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Any idea to .net core Startup.cs Factory for StubbleBuilder?

anisite opened this issue · comments

Hi,

How can I use Stubble in my .net core web site? All my actual dependencies are injected with .AddScoped(). Your example are do not include injection sample code.

I can't find pretty solution to create a custom Helper with HttpContext injection in that Helper.

If I want, by example write in my template : {{UserName}} and automatically read that user name in HttpContext FROM an helper... no solution ?

Thank you!

Hi there,

Stubble is agnostic of wherever the data is provided. You could write a method of providing information from the HttpContext although i'd advise against that as it feels like something that could be abused.

You can register a stubble renderer into your DI container and resolve it in your controller. When you're providing data to your template you can pull the data off the context as you would normally in your controller.

Hopefully that helps some,

Ok, I will look into it!