#1 RazorBlade Introduction - Making real tasks easier
Learn how to use
ToSic.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 ToSic.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. 2sxc 9.40+ includes RazorBlade 1.01, 2sxc 10.06 includes 2.0 and 10.09 includes v2.02. If you see errors, you probably need to install a newer version of RazorBlade.
Your RazorBlade version is 3.14 - which is what you need for all these tutorials.
RazorBlade Examples for Text Manipulations
- RazorBlade - Text.Crop() and Text.Ellipsis() v1.00
Correctly crop text without splitting words or html-characters like &
- RazorBlade - Text.Has() tells you if something really has content v1.00
Check if strings really have something correctly, incl. spaces or even whitespaces.
- RazorBlade - Text.First() lets you pick a value from many variables v3.00
Often you have to check many variables to find the first one to use.
- 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
- 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.
tags to new-lines or spaces and back v1.00
A common challenge is showing text as HTML or the other way around
RazorBlade Fluent Html and Html5 Tag API for creating HTML using code
- Tutorials for the Html5 Tag API enhanced!v3.00
The basics of creating html directly from code - with objects for every known HTML5 tag
RazorBlade Examples for Modifying DNN Page Headers
⚠️ WARNING: These examples only work in Dnn ☢️
2sxc 12 introduces the new
which also works in Oqtane 💧.
We suggest you use that instead. 👉 See Razor Page Service
Note that to ensure this tutorial can run on all platforms, we've included some
which changes what code runs on what platform.
- Page Title, Keyword, Description v1.01
Get/Set Page Title, Keywords, Description and set meta-tags and more.
- Base tag in header v3.00
Add a base tag to the header - which works correctly in DNN. Important for SPA JS applications.
- JSON-LD Headers for SEO v1.01
Add JSON-LD (Linked Data) headers for Google
- Open-Graph headers for Social Media v1.01
Add Open-Graph data headers for Facebook, Twitter and other sharing-systems
- Page Icons for Favicon, Apple/Android v2.01
Add various combinations of icons to the page header