diff --git a/IHP/ViewSupport.hs b/IHP/ViewSupport.hs index 56ed865c1..e902e3a06 100644 --- a/IHP/ViewSupport.hs +++ b/IHP/ViewSupport.hs @@ -55,7 +55,7 @@ import qualified IHP.View.CSSFramework as CSSFramework () import IHP.View.Types import qualified IHP.FrameworkConfig as FrameworkConfig import IHP.Controller.Context - +import qualified IHP.HSX.Attribute as HSX class View theView where -- | Hook which is called before the render is called @@ -262,3 +262,6 @@ liveReloadWebsocketUrl :: (?context :: ControllerContext) => Text liveReloadWebsocketUrl = ?context.frameworkConfig.ideBaseUrl |> Text.replace "http://" "ws://" |> Text.replace "https://" "wss://" + +instance InputValue (PrimaryKey table) => HSX.ApplyAttribute (Id' table) where + applyAttribute attr attr' value h = HSX.applyAttribute attr attr' (inputValue value) h \ No newline at end of file diff --git a/Test/ViewSupportSpec.hs b/Test/ViewSupportSpec.hs index cea38e686..f0f54e7bf 100644 --- a/Test/ViewSupportSpec.hs +++ b/Test/ViewSupportSpec.hs @@ -126,4 +126,14 @@ tests = beforeAll (mockContextNoDatabase WebApplication config) do runSession (testGet "test/TestWithParam?param=foo") application >>= assertTextExists "isActiveController TestController: True" it "should return False on a different route" $ withContext do application <- makeApplication - runSession (testGet "test/TestWithParam?param=foo") application >>= assertTextExists "isActiveController AnotherTestAction: False" \ No newline at end of file + runSession (testGet "test/TestWithParam?param=foo") application >>= assertTextExists "isActiveController AnotherTestAction: False" + + describe "HSX" $ do + it "allow using Id's in HSX attributes without explicitly calling inputValue" $ withContext do + let + id :: Id' "users" + id = Id ("70a10b53-a776-470a-91a8-900cdda06aa2" :: UUID) + + (ClassyPrelude.tshow [hsx||]) `shouldBe` "" + +type instance PrimaryKey "users" = UUID \ No newline at end of file