Fable bindings for Seview the S-Expression View, a wrapper for html/VDOM builder DSLs.
seview currently supports:
seview
exports a single function, sv
, that you use to obtain a function which you can name as you wish; in the examples, I name this function h
. Calling h(view)
, where view is the view expressed as arrays as we have seen above, produces the final result suitable for your virtual DOM library.
When you call sv
, you pass it a function that gets called for every node in the view.
Each node has the following structure:
{
tag: "button",
attrs: { id: "save", className: "btn btn-default", ... }
children: [ ... ]
}
Perhaps try:
type ChildTree =
| Child
| Composite of ChildTree list
We will have to add a full DSL similar to how Fable does it for fable-react
open Seview
let txt = Some "hello"
h1 (Some "hello") None
h1 txt None
txt1 "hello world"
Seview can be used with the excellent Meiosis pattern as a building block for next gen elmish like architecture.
WIP: Not yet tested
The bindings in Seview.fs
were created using seview.d.ts
, created from the seview module using dts CLI.
More resources:
- dotnet SDK 2.1 or higher
- Paket to manage F# dependencies
- node.js with npm
- An F# editor like Visual Studio, Visual Studio Code with Ionide or JetBrains Rider.
yarn install
- Windows:
.paket/paket.exe install
oryarn run paket
- Non-Windows:
mono .paket/paket.exe install
oryarn run paket:mono
Alternatively install paket as a global .NET tool
$ dotnet tool install --tool-path ".paket" Paket --add-source https://api.nuget.org/v3/index.json --framework netcoreapp2.1
With defaults, try simply: $ dotnet tool install Paket
In this case, make sure that the install location of paket
is in your system PATH
, see: dotnet-tool-install
npm start
to compile and watch with fable-splitter.
Alternatively:
npm run build
- same but outputs javascript to/out
.
While fable-splitter is watching with one of above npm
commands:
- Add
nuget ModuleName
to paket.dependencies and run paket install command above. - Add
ModuleName
to src/paket.references
App.fsporj
- add source paths here. Notepaket.references
is referenced here.App.fs
- starting point.Util/File.fs
- sample lib file.