Permalink
Browse files

Better README, moved some operators.

  • Loading branch information...
Dan Finch
Dan Finch committed Mar 10, 2013
1 parent 9121a91 commit 50fa6185f590a4910d496976e87662fde7a474ff
Showing with 76 additions and 17 deletions.
  1. +0 −14 README
  2. +73 −0 README.md
  3. +0 −2 src/FMarkup/Compact.fs
  4. +1 −1 src/FMarkup/FMarkup.fsproj
  5. +2 −0 src/FMarkup/Html.fs
View
14 README
@@ -1,14 +0,0 @@
-
-FMarkup is an HTML/CSS generation library and DSL for F#.
-
- * Write HTML and CSS in pure F#
-
-Dependencies (submodules):
-
- * Futility: https://github.com/danfinch/futility
-
-License: Public Domain
-
-Maintainers:
-
- * Dan Finch (d@nfin.ch)
View
@@ -0,0 +1,73 @@
+
+FMarkup is a tool for creating HTML/CSS documents in pure F#.
+
+## Simple Example
+
+```fsharp
+
+open FMarkup
+open FMarkup.Css
+
+let accountsPage accounts =
+ %%[
+ Doctype.html5
+ html [
+ body [
+ ul [
+ rule "li" [ // Inline rules are scoped to the parent element
+ font.weight.bold
+ ]
+ [ for a in accounts ->
+ li [
+ img [
+ src a.photo
+ width 100 // Inline styles work, too
+ height 100
+ ]
+ a.name
+ ]
+ ]
+ ]
+ ]
+ ]
+ ]
+
+let accountsStyle =
+ style [
+ rule "body" [
+ color "silver"
+ background.color "black"
+ ]
+ rule "a" [
+ text.decoration.none
+ rule ":hover" [ // Rules may be nested
+ text.decoration.underline
+ ]
+ ]
+ ]
+
+```
+
+Because your views are simple functions, composing templates/layouts/master pages is as simple as creating functions with arguments where markup holes are filled. To render the markup, create an instance of the `HtmlPrinter` record. It has two fields: `Format`, which specifies whether you want to render HTML or XHTML, and `CssUnit`, which specifies what CSS unit value (such as `px`) you would like `int` and `float` values to be rendered with.
+
+## Notes
+
+Because FMarkup works with `obj list` to avoid noise, sometimes it may be necessary to upcast symbols, so the operators `%` and `%%` are provided to cast to `obj` and `obj list`, respectively.
+
+Virtually all HTML5 and CSS3 symbols are supported. Bindings for some more obscure CSS properties which support multiple values may need to be improved, let me know if you run into any issues.
+
+## Compact Style
+
+A module called `FMarkup.Compact` is provided with succinct shortcuts to many common artifacts. It contains some experimental operators which may be included later into the main module.
+
+## License
+
+Public Domain.
+
+## Dependencies
+
+- Futility: https://github.com/danfinch/futility (submodule)
+
+## Maintainer
+
+- Dan Finch (d@nfin.ch)
View
@@ -11,8 +11,6 @@ module Compact =
open Prim
open Elem
open Attr
- let (~%%) (l : obj list) = l
- let (~%) (o : 'a) = o :> obj
let (~&) (o : 'a option) = o.IsSome // remove?
let (!) (o : 'a option) = o.Value // remove?
let (!!) (o : 'a option) = match o with | None -> null | Some(o) -> o :> obj // remove?
@@ -53,7 +53,7 @@
<Compile Include="Model.fs" />
</ItemGroup>
<ItemGroup>
- <ProjectReference Include="..\..\lib\futility\src\Futility\Futility.fsproj">
+ <ProjectReference Include="..\..\..\futility\src\Futility\Futility.fsproj">
<Project>9982C39B-74B0-4B7A-B658-905777359DAD</Project>
<Name>Futility</Name>
</ProjectReference>
View
@@ -8,6 +8,8 @@ open Microsoft.FSharp.Reflection
open Futility
module Prim =
+ let inline (~%%) (l : obj list) = l
+ let inline (~%) (o : 'a) = o :> obj
let inline elem tag (c : obj list) =
let e = {
Tag = tag

0 comments on commit 50fa618

Please sign in to comment.