Skip to content

Commit

Permalink
Initial htmx commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Lanayx committed Feb 14, 2024
1 parent 30a72bf commit dd59e18
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Oxpecker.sln
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "PerfTest", "tests\PerfTest\
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Basic", "examples\Basic\Basic.fsproj", "{B6DBDACA-E694-4B9F-95A0-0902C7B21555}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Oxpecker.Htmx", "src\Oxpecker.Htmx\Oxpecker.Htmx.fsproj", "{48D48FCE-2530-4DD4-B9A7-437E9F4886F1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -54,6 +56,10 @@ Global
{B6DBDACA-E694-4B9F-95A0-0902C7B21555}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B6DBDACA-E694-4B9F-95A0-0902C7B21555}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B6DBDACA-E694-4B9F-95A0-0902C7B21555}.Release|Any CPU.Build.0 = Release|Any CPU
{48D48FCE-2530-4DD4-B9A7-437E9F4886F1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{48D48FCE-2530-4DD4-B9A7-437E9F4886F1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{48D48FCE-2530-4DD4-B9A7-437E9F4886F1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{48D48FCE-2530-4DD4-B9A7-437E9F4886F1}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{625D9E19-8077-40D5-B208-23AFAC2B5F75} = {9EDF9D3C-DA11-44A2-A20C-4B466FEB7E06}
Expand All @@ -63,5 +69,6 @@ Global
{0FD9D105-2EE3-4BB0-B7A3-86084040F925} = {40C4900E-D46D-450F-9A93-A2CE2E4EF5CA}
{E0F1FCEC-CAA2-4FCA-9452-D8551F188B88} = {40C4900E-D46D-450F-9A93-A2CE2E4EF5CA}
{B6DBDACA-E694-4B9F-95A0-0902C7B21555} = {A1BC9EB1-C6D9-470C-B0F6-323814A0D0AC}
{48D48FCE-2530-4DD4-B9A7-437E9F4886F1} = {9EDF9D3C-DA11-44A2-A20C-4B466FEB7E06}
EndGlobalSection
EndGlobal
60 changes: 60 additions & 0 deletions src/Oxpecker.Htmx/Library.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
namespace Oxpecker.Htmx

open System.Runtime.CompilerServices
open Oxpecker.ViewEngine

module Extension =

[<Extension>]
type CoreHtmxExtensions =
[<Extension>]
static member hxBoost(el: HtmlElement, value: bool) =
el.attr("hx-boost", if value then "true" else "false")
[<Extension>]
static member hxGet(el: HtmlElement, value) =
el.attr("hx-get", value)
[<Extension>]
static member hxPost(el: HtmlElement, value) =
el.attr("hx-post", value)
[<Extension>]
static member hxOn(el: HtmlElement, event, value) =
el.attr("hx-on:"+event, value)
[<Extension>]
static member hxPushUrl(el: HtmlElement, value) =
el.attr("hx-push-url", value)
[<Extension>]
static member hxSelect(el: HtmlElement, value) =
el.attr("hx-select", value)
[<Extension>]
static member hxSelectOob(el: HtmlElement, value) =
el.attr("hx-select-oob", value)
[<Extension>]
static member hxSwap(el: HtmlElement, value) =
el.attr("hx-swap", value)
[<Extension>]
static member hxSwapOob(el: HtmlElement, value) =
el.attr("hx-swap-oob", value)
[<Extension>]
static member hxTarget(el: HtmlElement, value) =
el.attr("hx-target", value)
[<Extension>]
static member hxTrigger(el: HtmlElement, value) =
el.attr("hx-trigger", value)
[<Extension>]
static member hxVals(el: HtmlElement, value) =
el.attr("hx-vals", value)



module Test =

open Extension

let test () =

let z =
div().hxGet("").hxOn("clicked", "alert!")
.hxTrigger("click[ctrlKey&&shiftKey]"){
"sdf"
}
z
16 changes: 16 additions & 0 deletions src/Oxpecker.Htmx/Oxpecker.Htmx.fsproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

<ItemGroup>
<Compile Include="Library.fs"/>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Oxpecker.ViewEngine\Oxpecker.ViewEngine.fsproj" />
</ItemGroup>

</Project>

0 comments on commit dd59e18

Please sign in to comment.