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 313fb00
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 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: 1 addition & 1 deletion tests/Remoting.Client/Main.fs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ let Display model dispatch =
}
}

[<BoleroRenderMode(BoleroRenderMode.Auto); Route "/{*path}">]
// [<BoleroRenderMode(BoleroRenderMode.Auto)>]
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 313fb00

Please sign in to comment.