Red.EcsRenderer 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Red.EcsRenderer --version 1.0.0
                    
NuGet\Install-Package Red.EcsRenderer -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Red.EcsRenderer" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Red.EcsRenderer" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Red.EcsRenderer" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Red.EcsRenderer --version 1.0.0
                    
#r "nuget: Red.EcsRenderer, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Red.EcsRenderer@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Red.EcsRenderer&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Red.EcsRenderer&version=1.0.0
                    
Install as a Cake Tool

Ecs Renderer for RedHttpServer

The ecs renderer is a simple templating engine extension for RedHttpServer

Usage

After installing and referencing this library, the Red.Response has the extension method RenderPage(pageFilePath, parameters, ..).

The pageFilePath must be the path of a .ecs file.

The .ecs file format

The .ecs file format is an extension used for html pages with ecs-tags.

Tags

  • <% foo %> will get replaced with the text data in the RenderParams object passed to the renderer

  • <%= foo =%> will get replaced with a HTML encoded version of the text data in the RenderParams object passed to the renderer

  • <%- files/footer.html -%> will get replaced with the content of the file with the specified path. Can be both absolute or relative. Only html, ecs, js, css and txt is supported for now, but if you have a good reason to include another filetype, please create an issue regarding that.

Example

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Status page</title>
</head>
<body>
    <b>Uptime in minutes: <% uptime %></b></br>
    <b>Version: <% version %></b>
</body>
</html>
server.Get("/statuspage", async (req, res) =>
{
    await res.RenderPage("pages/statuspage.ecs", new RenderParams
    {
        { "uptime", DateTime.UtcNow.Subtract(startTime).TotalMinutes },
        { "version", RedHttpServer.Version }
    });
});

Could result in:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Status page</title>
</head>
<body>
    <b>Uptime in minutes: 42</b></br>
    <b>Version: 3.0.0</b>
</body>
</html>

The file extension is enforced to avoid confusion with regular html files without tags.

The format is somewhat inspired by the ejs format, though you cannot embed JavaScript, or C# for that matter, in the pages.

Embed your dynamic content using RenderParams instead of embedding the code for generation of the content in the html.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 is compatible.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.0 3,467 4/30/2019 2.0.0 is deprecated because it is no longer maintained.
1.2.0 1,658 9/12/2018 1.2.0 is deprecated because it is no longer maintained.
1.0.0 2,243 3/26/2018 1.0.0 is deprecated because it is no longer maintained.

First release