Skip to main content
Home  ›  Blog

Introducing Razor Blade 1.0

Do you want to strip away HTML in a string, convert BRs to NewLines and back, truncate it without stopping in the middle of an & or ä? This and more is what Razor Blade is for. 

A Library for Typical Tasks

Razor Blade is a new c# library solving many trivial but common tasks in Razor Templates. The v1 release contains commands to...

  1. HTML / Tags tasks (detailed docs)
    1. Tags.Br2Nl(text)
    2. Tags.Br2Space(text)
    3. Tags.Nl2Br(text)
    4. Tags.Strip(text)
  2. Text tasks (detailed docs)
    1. Text.Crop(string, length)
    2. Text.Ellipsis(value, length)
    3. Text.Has(value)
    4. Text.First(value, value[, moreValues, ...])
    5. Text.Zip(value)

These helper commands will make your templates easier to read and bullet proof, because you won't re-invent how-to-strip-html in each template. 

Note that we really wanted this to be bullet-proof, so Razor Blade contains 30+ automated tests to verify edge cases, and we'll add more if any surprise still pop up. 

For C#, DNN and .net Core

We built the library as a cross-platform library, so you can use it in any kind of project and also be sure that once DNN moves to .net core, Razor Blade will move with it. 

Tutorials, Blogs and Documentation

To help you get started, we created all the basics you need

  1. Github Repo containing Razor Blade and the documentation
  2. DNN Install package in the releases
  3. Tutorial App showing code for all the commands - source in Github
  4. Blogs for using this are still WIP, but will be published soon

Note that you can easily install Razor Blade on any DNN or include it with your own DNN modules. 2sxc 9.40 will also include Razor Blade by default, so any Apps you develop for 2sxc 9.40+ will be able to use the features of Razor Blade 1.0.

Future Enhancements

We're currently working on future enhancements, which will cover common challenges like

  1. Read / Write the page title and metadata from your scripts
  2. Generate e-mails using Razor e-mail templates

Love from Switzerland,

Daniel Mettler grew up in the jungles of Indonesia and is founder and CEO of 2sic internet solutions in Switzerland and Liechtenstein, an 20-head web specialist with over 800 DNN projects since 1999. He is also chief architect of 2sxc (see github), an open source module for creating attractive content and DNN Apps.

Read more posts by Daniel Mettler