Skip to content

Commit

Permalink
feat: Add attr.renderMode as alternative to using an attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
Tarmil committed Jan 3, 2024
1 parent 5ba8ae0 commit d4836e9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
9 changes: 9 additions & 0 deletions src/Bolero.Server/Html.fs
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,12 @@ module Html =
/// preceded by the standard "html" doctype declaration.
/// </summary>
let doctypeHtml = DoctypeHtmlBuilder()

#if NET8_0_OR_GREATER
module attr =

let renderMode (mode: IComponentRenderMode) =
Attr(fun _ b i ->
b.AddComponentRenderMode(mode)
i)
#endif
2 changes: 0 additions & 2 deletions tests/Remoting.Client/Main.fs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
module Bolero.Tests.Remoting.Client

open System.Collections.Generic
open Microsoft.AspNetCore.Components
open Microsoft.AspNetCore.Components.Authorization
open Bolero
open Bolero.Html
Expand Down Expand Up @@ -221,7 +220,6 @@ let Display model dispatch =
}
}

[<BoleroRenderMode(BoleroRenderMode.Auto); Route "/{*path}">]
type MyApp() =
inherit ProgramComponent<Model, Message>()

Expand Down
5 changes: 4 additions & 1 deletion tests/Remoting.Server/Startup.fs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ open Bolero.Server
open FSharp.SystemTextJson.Swagger

module Page =
open Microsoft.AspNetCore.Components
open Microsoft.AspNetCore.Components.Web
open Bolero.Html
open Bolero.Server.Html

Expand All @@ -45,12 +47,13 @@ module Page =
``base`` { attr.href "/" }
}
body {
div { attr.id "main"; comp<MyApp> }
div { attr.id "main"; comp<MyApp> { attr.renderMode RenderMode.InteractiveAuto } }
script { attr.src "_content/Microsoft.AspNetCore.Components.WebAssembly.Authentication/AuthenticationService.js" }
boleroScript
}
}

[<Route "/{*path}">]
type Page() =
inherit Bolero.Component()
override _.Render() = index
Expand Down

0 comments on commit d4836e9

Please sign in to comment.