The time is @DateTime.Now.
; - RenderFragmentYour pet's name is @pet.Name.
; +@timeTemplate + +@petTemplate(new Pet { Name = "Rex" }) + +@code { + private RenderFragment timeTemplate = @The time is @DateTime.Now.
; + private RenderFragmentYour pet's name is @pet.Name.
; + + private class Pet + { + public string Name { get; set; } + } } ``` -Render fragments defined using Razor templates can be passed as arguments to templated components or rendered directly. For example, the previous templates are directly rendered with the following Razor markup: +Rendered output of the preceding code: -```cshtml -@template +```html +The time is 10/04/2018 01:26:52.
-@petTemplate(new Pet { Name = "Rex" }) -``` - -Rendered output: - -``` -The time is 10/04/2018 01:26:52. - -Your pet's name is Rex. +Your pet's name is Rex.
``` ## Manual RenderTreeBuilder logic @@ -1002,7 +1002,7 @@ Consider the following `PetDetails` component, which can be manually built into @code { [Parameter] - string PetDetailsQuote { get; set; } + private string PetDetailsQuote { get; set; } } ```