Skip to content

Commit e0214ca

Browse files
committed
Working ViewEngine with examples
1 parent 7192b23 commit e0214ca

File tree

6 files changed

+18
-101
lines changed

6 files changed

+18
-101
lines changed

Examples/AspDotNetCore/AspDotNetCore.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
</ItemGroup>
3737

3838
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
39-
<Exec Command="HandlebarsCompiler.exe -c -f $(ProjectPath)" />
39+
<Exec Command="HandlebarsCompiler.exe -c $(ProjectPath)" />
4040
</Target>
4141

4242
</Project>

Examples/AspDotNetCore/Template.hbs.cs

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
using System.Net;
44
using System.Text;
55
using System.Collections.Generic;
6+
using CompiledHandlebars.RuntimeUtils;
7+
using static CompiledHandlebars.RuntimeUtils.RenderHelper;
68

79
namespace AspDotNetCore
810
{
@@ -17,38 +19,5 @@ public static string Render(AspDotNetCore.ViewModel viewModel)
1719
sb.Append("!</h1>\r\n</body>\r\n</html>");
1820
return sb.ToString();
1921
}
20-
21-
private static bool IsTruthy(bool b)
22-
{
23-
return b;
24-
}
25-
26-
private static bool IsTruthy(string s)
27-
{
28-
return !string.IsNullOrEmpty(s);
29-
}
30-
31-
private static bool IsTruthy(object o)
32-
{
33-
return o != null;
34-
}
35-
36-
private static bool IsTruthy<T>(IEnumerable<T> ie)
37-
{
38-
return ie != null && ie.Any();
39-
}
40-
41-
private static bool IsTruthy(int i)
42-
{
43-
return i != 0;
44-
}
45-
46-
private class CompiledHandlebarsTemplateAttribute : Attribute
47-
{
48-
}
49-
50-
private class CompiledHandlebarsLayoutAttribute : Attribute
51-
{
52-
}
5322
}
5423
}

Examples/AspDotNetCore/Views/Layouts/Main.hbs.cs

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
using System.Text;
55
using System.Collections.Generic;
66
using AspDotNetCore.Views.Partials;
7+
using CompiledHandlebars.RuntimeUtils;
8+
using static CompiledHandlebars.RuntimeUtils.RenderHelper;
79

810
namespace AspDotNetCore.Views.Layouts
911
{
@@ -14,7 +16,7 @@ public static string PostRender(System.String viewModel)
1416
{
1517
var sb = new StringBuilder(64);
1618
sb.Append("\r\n\t");
17-
sb.Append(Footer.Render("Partial"));
19+
sb.Append(Footer.Render("Partial in the layout"));
1820
sb.Append("\r\n</body>\r\n</html>");
1921
return sb.ToString();
2022
}
@@ -27,38 +29,5 @@ public static string PreRender(System.String viewModel)
2729
sb.Append("</title>\r\n</head>\r\n<body>\r\n\t");
2830
return sb.ToString();
2931
}
30-
31-
private static bool IsTruthy(bool b)
32-
{
33-
return b;
34-
}
35-
36-
private static bool IsTruthy(string s)
37-
{
38-
return !string.IsNullOrEmpty(s);
39-
}
40-
41-
private static bool IsTruthy(object o)
42-
{
43-
return o != null;
44-
}
45-
46-
private static bool IsTruthy<T>(IEnumerable<T> ie)
47-
{
48-
return ie != null && ie.Any();
49-
}
50-
51-
private static bool IsTruthy(int i)
52-
{
53-
return i != 0;
54-
}
55-
56-
private class CompiledHandlebarsTemplateAttribute : Attribute
57-
{
58-
}
59-
60-
private class CompiledHandlebarsLayoutAttribute : Attribute
61-
{
62-
}
6332
}
6433
}

Examples/AspDotNetCore/Views/Partials/Footer.hbs.cs

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
using System.Net;
44
using System.Text;
55
using System.Collections.Generic;
6+
using CompiledHandlebars.RuntimeUtils;
7+
using static CompiledHandlebars.RuntimeUtils.RenderHelper;
68

79
namespace AspDotNetCore.Views.Partials
810
{
@@ -17,38 +19,5 @@ public static string Render(System.String viewModel)
1719
sb.Append("!</h2>");
1820
return sb.ToString();
1921
}
20-
21-
private static bool IsTruthy(bool b)
22-
{
23-
return b;
24-
}
25-
26-
private static bool IsTruthy(string s)
27-
{
28-
return !string.IsNullOrEmpty(s);
29-
}
30-
31-
private static bool IsTruthy(object o)
32-
{
33-
return o != null;
34-
}
35-
36-
private static bool IsTruthy<T>(IEnumerable<T> ie)
37-
{
38-
return ie != null && ie.Any();
39-
}
40-
41-
private static bool IsTruthy(int i)
42-
{
43-
return i != 0;
44-
}
45-
46-
private class CompiledHandlebarsTemplateAttribute : Attribute
47-
{
48-
}
49-
50-
private class CompiledHandlebarsLayoutAttribute : Attribute
51-
{
52-
}
5322
}
5423
}

RuntimeUtils/CompiledHandlebars.RuntimeUtils.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
<TargetFrameworks>net45;net46;netstandard1.6</TargetFrameworks>
55
<AssemblyName>CompiledHandlebars.RuntimeUtils</AssemblyName>
66
<RootNamespace>CompiledHandlebars.RuntimeUtils</RootNamespace>
7+
<Version>0.3.3</Version>
8+
<Description>RuntimeUtils for the HandlebarsCompiler.</Description>
9+
<Authors>CurrySoftware GmbH</Authors>
10+
<Company>CurrySoftware GmbH</Company>
11+
<Product>HandlebarsCompiler</Product>
712
</PropertyGroup>
813

914
</Project>

ViewEngine.Core/CompiledHandlebars.ViewEngine.Core.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
<TargetFrameworks>netstandard1.6;net46</TargetFrameworks>
55
<AssemblyName>CompiledHandlebars.ViewEngine.Core</AssemblyName>
66
<RootNamespace>CompiledHandlebars.ViewEngine.Core</RootNamespace>
7+
<Version>0.3.3</Version>
8+
<Authors>CurrySoftware GmbH</Authors>
9+
<Company>CurrySoftware GmbH</Company>
10+
<Product>HanldebarsCompiler</Product>
11+
<Description>A ViewEngine for asp.net core that renders compiled handlebars templates.</Description>
712
</PropertyGroup>
813

914
<ItemGroup>

0 commit comments

Comments
 (0)