TopazView 1.1.0

Prefix Reserved
dotnet add package TopazView --version 1.1.0                
NuGet\Install-Package TopazView -Version 1.1.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="TopazView" Version="1.1.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add TopazView --version 1.1.0                
#r "nuget: TopazView, 1.1.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.
// Install TopazView as a Cake Addin
#addin nuget:?package=TopazView&version=1.1.0

// Install TopazView as a Cake Tool
#tool nuget:?package=TopazView&version=1.1.0                

TopazView

TopazView is a lightweight view engine that utilizes the Topaz JavaScript Engine. It serves as an alternative to the Razor View Engine, offering several key features and benefits.

Downloads

Key Features:

  • Faster startup: TopazView is designed to provide quicker startup times compared to other view engines.
  • Faster dynamic rendering: With TopazView, dynamic rendering is optimized for improved performance.
  • JavaScript syntax familiarity: TopazView employs JavaScript syntax, making it more accessible and familiar to web developers.
  • Simple learning curve: The template syntax used in TopazView closely resembles Razor, ensuring a smooth learning curve for developers.
  • Support for page models, layouts, sections, helper functions: TopazView provides comprehensive support for page models, layouts, sections, and helper functions, enabling developers to create dynamic and modular views.
  • Complete .NET API support: TopazView leverages the power of Topaz JavaScript engine to provide comprehensive access to the entire .NET API, giving developers extensive flexibility in their web development.

How to use TopazView?

The following sample shows the most basic setup of the TopazView.

using Tenray.TopazView;

var path = "web/views";
var viewEngine = new ViewEngineFactory()
    .SetContentProvider(new FileSystemContentProvider(path))
    .CreateViewEngine();

var contentWatcher = new FileSystemContentWatcher();
contentWatcher.StartWatcher(path, viewEngine);

The following is a sample of view rendering.

using Tenray.TopazView;

var context = viewEngine.CreateViewRenderContext();
context.Model = new { Title = "My Awesome TopazView Template" }.ToJsObject();
var html = await ViewEngine
    // provide an existing text file's relative path with any extension.
    .GetOrCreateView("/home/index.view")
    .GetCompiledView()
    .RenderViewToString(context);

The following is a sample view template file (index.view).

@Layout="../layouts/layout.view"

<div>@model.Title</div>

@{
    for(const i of [1,2,3]) {
        page.raw(i + ' <br>')
    }
}

@if(@model.Title) {
    <div>model has a title.</div>
}
else {
    <div>model has no title.</div>
}

TopazView Sample for WebView 2:

Experience the live editor of TopazView to witness TopazView in action. TopazView WebView 2 Sample

TODO list:

To further enhance TopazView, the following tasks are on the agenda:

  • Write documentation: Thorough documentation is essential for enabling developers to understand and utilize TopazView effectively.
  • Provide samples: Offering a collection of sample applications and code snippets will assist users in grasping the practical usage of TopazView.
  • Create developer-friendly exception page: Building an exception page specifically tailored to developers will facilitate error debugging and enhance the overall development experience.

Feel free to contribute to the project by tackling any of these tasks or suggesting additional improvements. Your involvement is greatly appreciated!

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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 is compatible.  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 is compatible.  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 is compatible. 
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
1.1.0 80 11/14/2024
1.0.9 94 9/27/2024
1.0.8 205 6/18/2023
1.0.7 175 6/17/2023
1.0.6 146 6/17/2023
1.0.5 156 6/11/2023
1.0.4 158 6/10/2023
1.0.3 148 6/10/2023
1.0.2 180 6/10/2023
1.0.1 174 6/8/2023
1.0.0 134 6/8/2023