RazorBlade 3.0 was just released, and the git repo has been moved to RazorBlade together with some large changes. Please use that from now on.
This document is an attempt to define what should be in this library, and what not. It also tries to provide a guide on how to name functions etc.
Commands should fairly useful for people creating Razor templates. So the commands should relate to generating HTML or modifying data for use in generating HTML.
- common string/text processing actions
- common html processing actions
- common helpers for working with dynamic data
- common value-checking like null-checks
- data / sql things
- interfaces to other systems
- actions-processing code like mail-generation helpers
- Commands should say what they do, or at least suggest what it does
- Commands should be easy to read in Razor code
- Commands should be fairly short
- If someone doesn't know what a command in the code does, he should be able to guess it
- Names
We don't want to group commands into sets, so please avoid grouping or type prefixes like StringStripHtml
.
All the commands we create should be easy to use within a simple line of code, like
@StripHtml(body)
Do not create extension methods. These are methods which look like they are part of an object. The would allow you to write things like:
var x = "<h1>title</h1>";
var y = x.StripHtml();
Such methods are syntactic sugar, but often causes problems in Razor because we have many variables which are dynamic - and in these cases Razor will need manual typing - making it nasty to read. So if your helper was a static method with an object of unclear type, the user would have to cast it first, resulting in nasty code like
var y = (x as string).StripHtml();
Since these helpers are meant for less technical front-end people, forcing them into such patterns would beat the purpose. This is why we want non extensions only, as it results in consistent code.