Skip to content

Commit b783d5f

Browse files
committed
Add usage guide
1 parent e0214ca commit b783d5f

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

Examples/AspDotNetCore/Readme.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,24 @@
1-
# Using the HandlebarsCompiler in a asp.net core (.net core) project
1+
# Using the HandlebarsCompiler.ViewEngine in a asp.net core mvc project
2+
3+
1. Add the CompiledHandlebars.ViewEngine.Core and CompiledHandlebars.RuntimeUtils Nuget Package
4+
2. Add the CompiledHandlebarsViewEngine to the MVC-Services and configure the ViewLocationFormats.
5+
```
6+
var ve_options = new CompiledHandlebarsViewEngineOptions()
7+
{
8+
ViewLocationFormats = new string[] { "~/Views/{1}/{0}.hbs", "~/Views/{0}.hbs", "~/{0}.hbs"
9+
};
10+
11+
services.AddMvc().AddViewOptions(options =>
12+
{
13+
options.ViewEngines.Add(new CompiledHandlebarsViewEngine(typeof(Startup).GetTypeInfo().Assembly, ve_options));
14+
});
15+
```
16+
3. Call the View in the Controller by Name
17+
```
18+
return View("Greet", name);
19+
```
20+
21+
# Using the HandlebarsCompiler in an asp.net core (.net core) project
222

323
Because of a [bug](https://github.com/dotnet/roslyn/issues/20808), the HandlebarsCompiler does not work correctly for asp.net core projects that target the .net core framework.
424

0 commit comments

Comments
 (0)