Add phx-track-static

This commit is contained in:
Paul-Henri Froidmont 2025-09-17 00:52:41 +02:00
parent 6f012b6796
commit 38655142b0
Signed by: phfroidmont
GPG key ID: BE948AFD7E7873BE
2 changed files with 8 additions and 2 deletions

View file

@ -26,6 +26,7 @@ package object scalive extends HtmlTags with HtmlAttrs with ComplexHtmlKeys:
private[scalive] lazy val linkState = dataPhxAttr("link-state") private[scalive] lazy val linkState = dataPhxAttr("link-state")
lazy val click = phxAttrJson("click") lazy val click = phxAttrJson("click")
def value(key: String) = phxAttr(s"value-$key") def value(key: String) = phxAttr(s"value-$key")
lazy val trackStatic = htmlAttr("phx-track-static", BooleanAsAttrPresenceCodec)
implicit def stringToMod(v: String): Mod = Mod.Content.Text(v) implicit def stringToMod(v: String): Mod = Mod.Content.Text(v)
implicit def htmlElementToMod(el: HtmlElement): Mod = Mod.Content.Tag(el) implicit def htmlElementToMod(el: HtmlElement): Mod = Mod.Content.Tag(el)

View file

@ -7,8 +7,13 @@ object RootLayout:
headTag( headTag(
metaTag(charset := "utf-8"), metaTag(charset := "utf-8"),
metaTag(nameAttr := "viewport", contentAttr := "width=device-width, initial-scale=1"), metaTag(nameAttr := "viewport", contentAttr := "width=device-width, initial-scale=1"),
scriptTag(defer := true, typ := "text/javascript", src := "/static/app.js"), scriptTag(
linkTag(rel := "stylesheet", href := "/static/app.css"), defer := true,
phx.trackStatic := true,
typ := "text/javascript",
src := "/static/app.js"
),
linkTag(phx.trackStatic := true, rel := "stylesheet", href := "/static/app.css"),
titleTag("Scalive Example") titleTag("Scalive Example")
), ),
bodyTag( bodyTag(