Skip to content
This repository has been archived by the owner on Mar 19, 2024. It is now read-only.

Latest commit

 

History

History
26 lines (17 loc) · 1.21 KB

README.md

File metadata and controls

26 lines (17 loc) · 1.21 KB

DEPRICATION NOTICE

This project is no longer used by myself and thus not maintained anymore. Consider using https://github.com/sebastienros/fluid instead.

IsolatedRazor

Offers a secure and isolated template rendering engine using the Razor syntax. This project is heavily based on RazorEngine.

The Razor templates are compiled into temporary assemblies (cached) and then executed in a secure AppDomain which does not has access to the disk, database or the network.

Supports ASP.NET (dynamic ViewBag in templates) and shadow-copying (shadow-copied assembly can contain model class). To install IsolatedRazor, run the following command in the Package Manager Console:

PM> Install-Package IsolatedRazor

Usage

To see IsolatedRazor in action you can check the IsolatedRazor.Demo.* projects.

Short usage example:

using (var templater = new IsolatedRazor.RazorTemplater(templatePath))
{
    string result = await templater.ParseAsync("MyTemplate",
        "<div>Hello @Model.Name! It is @DateTime.Now</div>", timestamp, model).ConfigureAwait(false);
}

Constructing the IsolatedRazor.RazorTemplater instance is rather slow, so if you can you should reuse it.