curb_razor_format_code_blocks

Experimental. Format the C# in @code and @functions blocks of .razor and .cshtml files, and nothing else in them. Read only from a section that names those files.

Value Notes
true
false

Default: false

Experimental. It has to be set in a section whose glob names Razor files, and [*], [**] and [*.*] do not count, so a catch-all section cannot turn it on by accident:

Ini
[*.{razor,cshtml}]
curb_razor_format_code_blocks = true

Without it, Curb never reads a .razor or .cshtml file. With it, only the C# inside @code and @functions blocks changes: markup, @{ } blocks and expressions are never touched, and a block that holds Razor markup is left as written. See Razor.

Ini
curb_razor_format_code_blocks = true
HTML
@page "/counter"

<h1>Counter</h1>
<p role="status">Current count:   @currentCount</p>
<button class="btn" @onclick="IncrementCount">Click me</button>

@code {
  private int currentCount=0;

      private void IncrementCount()
  {
    currentCount+=1;
  }
}
HTML
@page "/counter"

<h1>Counter</h1>
<p role="status">Current count:   @currentCount</p>
<button class="btn" @onclick="IncrementCount">Click me</button>

@code {
    private int currentCount = 0;

    private void IncrementCount()
    {
        currentCount += 1;
    }
}
Ini
curb_razor_format_code_blocks = false
HTML
@page "/counter"

<h1>Counter</h1>
<p role="status">Current count:   @currentCount</p>
<button class="btn" @onclick="IncrementCount">Click me</button>

@code {
  private int currentCount=0;

      private void IncrementCount()
  {
    currentCount+=1;
  }
}
HTML
@page "/counter"

<h1>Counter</h1>
<p role="status">Current count:   @currentCount</p>
<button class="btn" @onclick="IncrementCount">Click me</button>

@code {
  private int currentCount=0;

      private void IncrementCount()
  {
    currentCount+=1;
  }
}