From 72641682440ba1e69ab7742ab1364f9256e4eabd Mon Sep 17 00:00:00 2001 From: Nick Craver Date: Fri, 19 Jul 2019 13:47:42 -0400 Subject: [PATCH 1/8] Codeblocks: highlighting This uses the new-ish ```razor Linguist style in code fences where appropriate. Also normalizes the various languages used in codeblock fences, e.g. C#, cs, csharp all to csharp. --- docs/01-components-and-layout.md | 16 ++++----- docs/02-customize-a-pizza.md | 24 ++++++------- docs/03-show-order-status.md | 30 ++++++++-------- docs/04-refactor-state-management.md | 10 +++--- docs/05-checkout-with-validation.md | 31 ++++++++--------- docs/06-authentication-and-authorization.md | 30 ++++++++-------- docs/07-javascript-interop.md | 18 +++++----- docs/08-templated-components.md | 38 ++++++++++----------- 8 files changed, 98 insertions(+), 99 deletions(-) diff --git a/docs/01-components-and-layout.md b/docs/01-components-and-layout.md index a10db867..326d0b4c 100644 --- a/docs/01-components-and-layout.md +++ b/docs/01-components-and-layout.md @@ -23,7 +23,7 @@ When you run the app, you'll see that it currently only contains a simple home p Open *Pages/Index.razor* in the **BlazingPizza.Client** project to see the code for the home page. -``` +```razor @page "/"

Blazing Pizzas

@@ -37,7 +37,7 @@ First we'll update the home page to display the list of available pizza specials Add a `@functions` block to *Index.razor* with a list field to keep track of the available specials: -```csharp +```razor @functions { List specials; } @@ -47,7 +47,7 @@ The code in the `@functions` block is added to the generated class for the compo To get the available list of specials we need to call an API on the backend. Blazor provides a preconfigured `HttpClient` through dependency injection that is already setup with the correct base address. Use the `@inject` directive to inject an `HttpClient` into the `Index` component. -``` +```razor @page "/" @inject HttpClient HttpClient ``` @@ -56,7 +56,7 @@ The `@inject` directive essentially defines a new property on the component wher Override the `OnInitAsync` method in the `@functions` block to retrieve the list of pizza specials. This method is part of the component lifecycle and is called when the component is initialized. Use the `GetJsonAsync()` method to handle deserializing the response JSON: -```csharp +```razor @functions { List specials; @@ -71,7 +71,7 @@ The `/specials` API is defined by the `SpecialsController` in the Server project Once the component is initialized it will render its markup. Replace the markup in the `Index` component with the following to list the pizza specials: -```html +```razor
    @if (specials != null) @@ -101,7 +101,7 @@ Next we'll setup the layout for app. Layouts in Blazor are also components. They inherit from `LayoutComponentBase`, which defines a `Body` property that can be used to specify where the body of the layout should be rendered. The layout component for our pizza store app is defined in *Shared/MainLayout.razor*. -```html +```razor @inherits LayoutComponentBase
    @@ -112,13 +112,13 @@ Layouts in Blazor are also components. They inherit from `LayoutComponentBase`, To apply a layout use the `@layout` directive. Typically this is done in a `_Imports.razor` file, which then gets inherited hierarchically. See *Pages/_Imports.razor*. -``` +```razor @layout MainLayout ``` Update the `MainLayout` component to define a top bar with a branding logo and a nav link for the home page: -```html +```razor @inherits LayoutComponentBase
    diff --git a/docs/02-customize-a-pizza.md b/docs/02-customize-a-pizza.md index 72cf5f7d..f60a6a6d 100644 --- a/docs/02-customize-a-pizza.md +++ b/docs/02-customize-a-pizza.md @@ -8,7 +8,7 @@ When the user clicks a pizza special a pizza customization dialog should pop up In *Pages/Index.razor* add the following `@onclick` handler to the list item for each pizza special: -```html +```razor @foreach (var special in specials) {
  • @@ -54,7 +54,7 @@ void ShowConfigurePizzaDialog(PizzaSpecial special) Update the `@onclick` handler to call the `ShowConfigurePizzaDialog` method instead of `Console.WriteLine`. -```html +```razor
  • ``` @@ -99,7 +99,7 @@ Add the following basic markup for the `ConfigurePizzaDialog`: Update *Pages/Index.razor* to show the `ConfigurePizzaDialog` when a pizza special has been selected. The `ConfigurePizzaDialog` is styled to overlay the current page, so it doesn't really matter where you put this code block. -```html +```razor @if (showingConfigureDialog) { @@ -116,7 +116,7 @@ Unfortunately at this point there's no functionality in place to close the dialo The user should be able to specify the size of their pizza. Add markup to the body of `ConfigurePizzaDialog` for a slider that lets the user specify the pizza size. This should replace the existing `
    ` element. -```html +```razor
    @@ -136,7 +136,7 @@ We want to make it so the value of the `Pizza.Size` will reflect the value of th If you wanted to implement two-way binding manually, you could do so by combining value and @onchange, as in the following code (which you don't actually need to put in your application, because there's an easier solution): -```html +```razor ``` @@ -158,7 +158,7 @@ But if we use `@bind` with no further changes, the behavior isn't exactly what w We'd prefer to see updates as the slider is moved. Data binding in Blazor allows for this by letting you specify what event triggers a change using the syntax `@bind:`. So, to bind using the `oninput` event instead do this: -```html +```razor ``` @@ -170,7 +170,7 @@ The pizza size should now update as you move the slider. The user should also be able to select additional toppings on `ConfigurePizzaDialog`. Add a list property for storing the available toppings. Initialize the list of available toppings by making an HTTP GET request to the `/toppings` API. -```csharp +```razor @inject HttpClient HttpClient
    @@ -191,7 +191,7 @@ The user should also be able to select additional toppings on `ConfigurePizzaDia Add the following markup in the dialog body for displaying a drop down list with the list of available toppings followed by the set of selected toppings. Put this inside the ``, below the existing `
    `." -```html +```razor
    @if (toppings == null) @@ -271,7 +271,7 @@ Add two parameters to the `ConfigurePizzaDialog` component: `OnCancel` and `OnCo Add `@onclick` event handlers to the `ConfigurePizzaDialog` that trigger the `OnCancel` and `OnConfirm` events. -```html +```razor
    @@ -339,7 +339,7 @@ Next we need to display the configured pizzas in the current order, calculate th Create a new `ConfiguredPizzaItem` component for displaying a configured pizza. It takes two parameters: the configured pizza, and an event for when the pizza was removed. -```html +```razor
    x
    @(Pizza.Size)" @Pizza.Special.Name
    @@ -362,7 +362,7 @@ Create a new `ConfiguredPizzaItem` component for displaying a configured pizza. Add the following markup to the `Index` component just below the main `div` to add a right side pane for displaying the configured pizzas in the current order. -```html +```razor