Skip to main content

Razor Blade Tutorials

Tutorial HomeRazor.Blade

Learn how to use Connect.Razor.Blade to do really cool stuff. For example, take a html-string, strip the html tags, truncate to 100 characters without splitting word and then show using a standard html-ellipsis. And way more. This uses Connect.Razor.Blade.

Some notes before we start

RazorBlade can be installed as a stand-alone DNN module or if you are creating your own module, you can include it in your distribution. If you're viewing this tutorial with 2sxc 9.40+, then it already includes RazorBlade 1.01, but some examples need an even newer version. If you see errors, you probably need to install a newer version of RazorBlade

RazorBlade Examples for Text Manipulations

  1. RazorBlade - Text.Crop() and Text.Ellipsis() v1.00
    Correctly crop text without splitting words or html-characters like &
  2. RazorBlade - Text.Has() tells you if something really has content v1.00
    Check if strings really have something correctly, incl. spaces or even   whitespaces.
  3. RazorBlade - Text.First() lets you pick a value from many variables v1.00
    Often you have to check many variables to find the first one to use.
  4. RazorBlade - Text.Zip() lets you shrink all spaces, tabs, enters together v1.00
    Very often you need to clean up some text before working with it.

RazorBlade Examples for Manipulating Html strings

  1. Tags.Strip() cleans out all HTML tags v1.00
    Remove all html from a string - important for teaser texts and protecting against cross-site-scripting attacks.
  2. Convert <br> tags to new-lines or spaces and back v1.00
    A common challenge is showing text as HTML or the other way around

RazorBlade Examples for Modifying DNN Page Headers

  1. Page Title, Keyword, Description v1.01
    Get/Set Page Title, Keywords, Description and set meta-tags and more.
  2. JSON-LD Headers for SEO v1.01
    Add JSON-LD (Linked Data) headers for Google
  3. Open-Graph headers for Social Media v1.01
    Add Open-Graph data headers for Facebook, Twitter and other sharing-systems
  4. Open-Graph headers for Social Media v1.01
    Add Open-Graph data headers for Facebook, Twitter and other sharing-systems
  5. Page Icons for Favicon, Apple/Android new! v2.01
    Add various combinations of icons to the page header

RazorBlade Fluent Html Tag API for creating HTML using code

  1. Tutorials for the Fluent Tag API new! v2.00
    The basics of creating html directly from code

More Information around RazorBlade

  1. RazorBlade Github Repo
  2. RazorBlade download page
  3. Blogs