Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion BlazorTemplater.Library/BlazorTemplater.Library.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
Expand All @@ -9,6 +9,14 @@
<Product>BlazorTemplater</Product>
</PropertyGroup>

<ItemGroup>
<EmbeddedResource Include="ComponentWithCss.razor.css" />
<EmbeddedResource Include="MultipleComponentsWithCss.razor.css" />
<EmbeddedResource Include="SimpleWithCss.razor.css" />
<EmbeddedResource Include="LayoutComponentWithCss.razor.css" />
<EmbeddedResource Include="TemplatedSimpleWithCss.razor.css" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components" Version="3.1.14" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="3.1.14" />
Expand Down
3 changes: 3 additions & 0 deletions BlazorTemplater.Library/ComponentWithCss.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<p class="nested">
This component has <strong>owned CSS</strong>
</p>
12 changes: 12 additions & 0 deletions BlazorTemplater.Library/ComponentWithCss.razor.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.nested {
font-size: large;
color: darkblue;
width: 100%;
padding: 1rem;
text-align: center;
}

.nested strong{
color: darkred;
font-style: italic;
}
17 changes: 17 additions & 0 deletions BlazorTemplater.Library/LayoutComponentWithCss.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@inherits LayoutComponentBase

<html>
<head>
<title>LayoutFile</title>
</head>
<body>
<div class="page">
<div class="main">
<p>This is a layout component that should be rendered components!</p>
<div class="content px-4">
@Body
</div>
</div>
</div>
</body>
</html>
7 changes: 7 additions & 0 deletions BlazorTemplater.Library/LayoutComponentWithCss.razor.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
p {
font-size: large;
color: darkgreen;
width: 100%;
padding: 1rem;
text-align: center;
}
5 changes: 5 additions & 0 deletions BlazorTemplater.Library/MultipleComponentsWithCss.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@layout LayoutComponentWithCss
<p>
<b>Jan 1st is @(new DateTime(2021,1,1).ToString("yyyy-MM-dd"))</b>
</p>
<ComponentWithCss />
8 changes: 8 additions & 0 deletions BlazorTemplater.Library/MultipleComponentsWithCss.razor.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
p
{
font-size: large;
color: darkblue;
width: 100%;
padding: 1rem;
text-align: center;
}
3 changes: 3 additions & 0 deletions BlazorTemplater.Library/SimpleWithCss.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<p>
<b>Jan 1st is @(new DateTime(2021,1,1).ToString("yyyy-MM-dd"))</b>
</p>
8 changes: 8 additions & 0 deletions BlazorTemplater.Library/SimpleWithCss.razor.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
p
{
font-size: large;
color: darkblue;
width: 100%;
padding: 1rem;
text-align: center;
}
4 changes: 4 additions & 0 deletions BlazorTemplater.Library/TemplatedSimpleWithCss.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@layout LayoutComponentWithCss
<p class="child">
<b>Jan 1st is @(new DateTime(2021,1,1).ToString("yyyy-MM-dd"))</b>
</p>
7 changes: 7 additions & 0 deletions BlazorTemplater.Library/TemplatedSimpleWithCss.razor.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
p.child {
font-size: medium;
color: darkblue;
width: 100%;
padding: 1rem;
text-align: center;
}
10 changes: 5 additions & 5 deletions BlazorTemplater.Tests/BlazorTemplater.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.3" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.3" />
<PackageReference Include="coverlet.collector" Version="3.0.3">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.4.3" />
<PackageReference Include="MSTest.TestFramework" Version="3.4.3" />
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
106 changes: 106 additions & 0 deletions BlazorTemplater.Tests/Templater_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -427,5 +427,111 @@ public void GetLayoutFromAttribute_TestWhenNotPresent()
}

#endregion

#region Css Isolated
/// <summary>
/// Test a SimpleWithCss component with no parameters
/// </summary>
[TestMethod]
public void RenderComponent_SimpleWithCss_Test()
{
const string expected = @"<style type=""text/css"">p
{
font-size: large;
color: darkblue;
width: 100%;
padding: 1rem;
text-align: center;
}</style><p>
<b>Jan 1st is 2021-01-01</b>
</p>";

var templater = new Templater();
var actual = templater.RenderComponent<SimpleWithCss>();

Console.WriteLine(actual);
Assert.AreEqual(expected, actual);
}

/// <summary>
/// Test a SimpleWithCss component with no parameters
/// </summary>
[TestMethod]
public void RenderComponent_TemplatedSimpleWithCss_Test()
{
const string expected = @"
<p>This is a layout component that should be rendered components!</p>
<div class=""content px-4"">
<style type=""text/css"">p {
font-size: large;
color: darkgreen;
width: 100%;
padding: 1rem;
text-align: center;
}p.child {
font-size: medium;
color: darkblue;
width: 100%;
padding: 1rem;
text-align: center;
}</style><p class=""child"">
<b>Jan 1st is 2021-01-01</b>
</p>";

var templater = new Templater();
var actual = templater.RenderComponent<TemplatedSimpleWithCss>();

Console.WriteLine(actual);
StringAssert.Contains(actual, expected, "Content not found");
}

/// <summary>
/// Test a SimpleWithCss component with no parameters
/// </summary>
[TestMethod]
public void RenderComponent_MultipleComponentsWithCss_Test()
{
const string expected = @"<p>This is a layout component that should be rendered components!</p>
<div class=""content px-4"">
<style type=""text/css"">.nested {
font-size: large;
color: darkblue;
width: 100%;
padding: 1rem;
text-align: center;
}

.nested strong{
color: darkred;
font-style: italic;
}p {
font-size: large;
color: darkgreen;
width: 100%;
padding: 1rem;
text-align: center;
}p
{
font-size: large;
color: darkblue;
width: 100%;
padding: 1rem;
text-align: center;
}</style><p>
<b>Jan 1st is 2021-01-01</b>
</p>
<p class=""nested"">
This component has <strong>owned CSS</strong>
</p>";

var templater = new Templater();
var actual = templater
.AddScoppedCss<ComponentWithCss>()
.RenderComponent<MultipleComponentsWithCss>();

Console.WriteLine(actual);
StringAssert.Contains(actual, expected, "Content not found");
}
#endregion Simple render
}
}
5 changes: 3 additions & 2 deletions BlazorTemplater.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31624.102
# Visual Studio Version 17
VisualStudioVersion = 17.10.34928.147
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "solution", "solution", "{C0365D75-5C0A-4E88-BC0F-FF595B731B6B}"
ProjectSection(SolutionItems) = preProject
Expand All @@ -18,6 +18,7 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{B0E3EF40-CE74-4196-993F-D65E256F52FB}"
ProjectSection(SolutionItems) = preProject
Docs\AddRazorSupport.md = Docs\AddRazorSupport.md
Docs\CssIsolated.md = Docs\CssIsolated.md
Docs\Layouts.md = Docs\Layouts.md
Docs\Templater.md = Docs\Templater.md
Docs\Usage.md = Docs\Usage.md
Expand Down
40 changes: 21 additions & 19 deletions BlazorTemplater/BlazorTemplater.csproj
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net5.0</TargetFrameworks>
<RazorLangVersion>3.0</RazorLangVersion>
<Authors>conficient, PhotoAtomic</Authors>
<Company>conficient</Company>
<Description>A HTML templating engine using Razor Components (.razor) files instead of .cshtml</Description>
<PackageProjectUrl>https://github.com/conficient/BlazorTemplater</PackageProjectUrl>
<RepositoryUrl>https://github.com/conficient/BlazorTemplater</RepositoryUrl>
<PackageTags>Blazor RazorComponents HTML Email Templating</PackageTags>
<Version>1.5.1</Version>
<PackageReleaseNotes>Added test for comment rendering</PackageReleaseNotes>
<LangVersion>Latest</LangVersion>
</PropertyGroup>
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net5.0;net8.0</TargetFrameworks>
<RazorLangVersion>3.0</RazorLangVersion>
<Authors>conficient, PhotoAtomic</Authors>
<Company>conficient</Company>
<Description>A HTML templating engine using Razor Components (.razor) files instead of .cshtml</Description>
<PackageProjectUrl>https://github.com/conficient/BlazorTemplater</PackageProjectUrl>
<RepositoryUrl>https://github.com/conficient/BlazorTemplater</RepositoryUrl>
<PackageTags>Blazor RazorComponents HTML Email Templating</PackageTags>
<Version>1.6.2</Version>
<PackageReleaseNotes>Added css isolated when rendering</PackageReleaseNotes>
<LangVersion>Latest</LangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components" Version="3.1.14" Condition="'$(TargetFramework)' == 'netstandard2.0'" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="3.1.14" Condition="'$(TargetFramework)' == 'netstandard2.0'" />
<PackageReference Include="Microsoft.AspNetCore.Components" Version="5.0.5" Condition="'$(TargetFramework)' != 'netstandard2.0'" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="5.0.5" Condition="'$(TargetFramework)' != 'netstandard2.0'" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components" Version="3.1.14" Condition="'$(TargetFramework)' == 'netstandard2.0'" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="3.1.14" Condition="'$(TargetFramework)' == 'netstandard2.0'" />
<PackageReference Include="Microsoft.AspNetCore.Components" Version="5.0.5" Condition="'$(TargetFramework)' != 'netstandard2.0'" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="5.0.5" Condition="'$(TargetFramework)' != 'netstandard2.0'" />
<PackageReference Include="Microsoft.AspNetCore.Components" Version="8.0.6" Condition="'$(TargetFramework)' != 'netstandard2.0'" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="8.0.6" Condition="'$(TargetFramework)' != 'netstandard2.0'" />
</ItemGroup>

</Project>
Loading