Skip to content

mrpmorris/Morris.Blazor.ControlFlow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Morris.Blazor.ControlFlow

Introduction

NuGet version (Morris.Blazor.ControlFlow)

ControlFlow is a Blazor library created to help reduce the amount of C# code found in markup files.

Instead of this

@if (People?.Length > 0)
{
  <ol>
    @foreach (var person in People)
    {
      <li>@person.FullName</li>
    }
  </ol>
}

You can write this

<If Condition="People?.Length > 0">
  <ol>
    <ForEach Context=person In=People>
      <li>@person.FullName</li>
    </ForEach>
  </ol>
</If>

Instead of this

@if (People?.Length > 0)
{
  <ol>
    @foreach (var person in People)
    {
      <li>@person.FullName</li>
    }
  </ol>
}
else
{
  <p>No people found</p>
}

You can write this

<If Condition="People?.Length > 0">
  <Then>
    <ol>
      <ForEach Context=person In=People>
        <li>@person.FullName</li>
      </ForEach>
    </ol>
  </Then>
  <Else>
    <p>No people found</p>
  </Else>
</If>

More information