Skip to content

Commit

Permalink
clean up and better readme
Browse files Browse the repository at this point in the history
  • Loading branch information
iJungleboy committed Jan 10, 2019
1 parent 44a0e55 commit fcbd03f
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 79 deletions.
12 changes: 0 additions & 12 deletions Blade/ConditionalOutput.cs

This file was deleted.

2 changes: 0 additions & 2 deletions Blade/RazorBlade.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,13 @@
<ItemGroup>
<Compile Include="Blade\Tags\LineBreaks.cs" />
<Compile Include="Internals\Defaults.cs" />
<Compile Include="ConditionalOutput.cs" />
<Compile Include="Blade\Dic\SafeGet.cs" />
<Compile Include="Blade\Dic\Dynamic.cs" />
<Compile Include="Blade\Tags\Remove.cs" />
<Compile Include="Blade\Text\HasText.cs" />
<Compile Include="Blade\Text\FirstText.cs" />
<Compile Include="Blade\Text\Ellipsis.cs" />
<Compile Include="Internals\Truncator.cs" />
<Compile Include="Strings.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
Expand Down
29 changes: 0 additions & 29 deletions Blade/Strings.cs

This file was deleted.

23 changes: 0 additions & 23 deletions Connect.Razor.Dnn/Connect.Razor.Dnn.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,30 +43,7 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
<Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.4.5.6\lib\net40\Newtonsoft.Json.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
<Private>False</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Runtime.Caching" />
<Reference Include="System.Web" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Web.Helpers">
<HintPath>Assemblies\System.Web.Helpers.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System.Xml" />
<Reference Include="System.Configuration" />
<Reference Include="System.Web.Services" />
<Reference Include="System.EnterpriseServices" />
<Reference Include="System.Web.DynamicData" />
<Reference Include="System.Web.Entity" />
<Reference Include="System.Web.ApplicationServices" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
Expand Down
30 changes: 17 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,15 @@

A library of common functions for Razor, to lighten Razor templates and make work easier.

The goal is to provide helpers for very common code snippets or functions, which would lighten the load. Here's an example:
The goal is to provide helpers for very common code snippets or functions, which would lighten the load. Here some common examples...

Instead of writing this:
_Sometimes you need the first 100 characters followed by an ellipsis (if truncated), but umlauts like `&uuml;` will mess up your count or might even be cut off. This is automatically handled by:_

```razor
@Text.Crop(someText, 100)
```

_Or sometimes you need a value, but if it's empty, you need another one. So instead of writing:_

```razor
@if(String.IsNullOrWhiteSpace(firstName as string)) {
Expand All @@ -17,19 +23,15 @@ Instead of writing this:
}
```

You can write this:
_You can write this, or below it the example with even more values:_

```razor
@Text.First(firstName, "nothing found");
```

Or here an example with more values:
@Text.First(firstName, "John");
```razor
@Text.First(nameFromDb, nameFromProfile, defaultNameForThisCountry, "unknown")
```

Note that HTML whitespace like `&nbsp;` will also be treated as empty, unless you add `false` as a last parameter. But RazorBlade does more than just skip empty texts, here some more examples:
_Note that HTML whitespace like `&nbsp;` will also be treated as empty, unless you add `false` as a last parameter. But RazorBlade does more than just skip empty texts, here some more examples:_

```razor
@* remove html from a wysiwyg-string *@
Expand All @@ -48,6 +50,8 @@ Note that HTML whitespace like `&nbsp;` will also be treated as empty, unless yo

## Using Razor Blade

First, install the DNN-module from the [releases on Github](https://github.com/DNN-Connect/razor-blade/releases).

In your c# code, add the following line to then have access to all the commands:

```razor
Expand Down Expand Up @@ -94,19 +98,19 @@ This is a short summary of the most used variations of the helpers. Further deta
## Commands in v0.1 to Convert Html to Text or Back

1. `Tags.Remove(htmlText)` - strips the html from an string, ensuring that all tags will cause 1 spaces between words, but only one (multiple spaces are shortened to 1 again)

1. `Tags.Br2Nl(text)` - replaces all kinds of `<br>` tags with new-line `\n`

1. `Tags.Br2Space(text)` - replaces all kinds of `<br>` with spaces

1. `Tags.Nl2Br(text)` - replaces all kinds of new-line (`\n`, `\r`) with `<br>`

## Ideas to discuss

1. `Tags.Remove(htmlText, csvListOfTagsToRemove)`
1. `Tags.Replace(htmlText, listOfTags, replacementTag)`
1. (place other wishes into issues for discussion)

### WIP

1. `ToDynamic(dictionary)` - converts a Dictionary to an expando object, so you can write obj.Property instead of obj["Property"]
1. `Dic.ToDynamic(dictionary)` - converts a Dictionary to an expando object, so you can write obj.Property instead of obj["Property"]; would return null if a property would not be found.

## Namespace Conventions

Expand Down
File renamed without changes.

0 comments on commit fcbd03f

Please sign in to comment.