Skip to content

Instantly share code, notes, and snippets.

@coolya
Last active February 17, 2018 21:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coolya/52588c4605e7f83b8376fdaf3e43ce3f to your computer and use it in GitHub Desktop.
Save coolya/52588c4605e7f83b8376fdaf3e43ce3f to your computer and use it in GitHub Desktop.
A simple wrapper for Giraffe html api that mimics the Fable.React api
module Giraffe.Fable.Compat.Helper
open Giraffe.GiraffeViewEngine
let inline private domEl a b c = tag a b c
let inline private voidEl a b = voidTag a b
//todo: check value and emit attr or not
let inline private boolAttr (key: string) (value: bool) = attr key (string value)
let inline private floatAttr (key: string) (value: float) = attr key (string value)
let inline private objAttr (key: string) (value: obj) = attr key (string value)
module Props =
let inline DefaultChecked value = boolAttr "defaultChecked" value
let inline Accept value = attr "accept" value //of string
let inline AcceptCharset value = attr "accept-charset" value //of string
let inline AccessKey value = attr "accesskey" value //of string
let inline Action value = attr "action" value //of string
let inline AllowFullScreen value = boolAttr "allowfullscreen" value //of bool
let inline AllowTransparency value = boolAttr "allowtransparency" value //of bool
let inline Alt value = attr "alt" //of string
let inline AriaHasPopup value = boolAttr "aria-haspopup" value //of bool
let inline AriaExpanded value = boolAttr "aria-expanded" value //of bool
let inline Async value = boolAttr "async" value //of bool
let inline AutoComplete value = attr "autocomplete" value //of string
let inline AutoFocus value = boolAttr "autofocus" value //of bool
let inline AutoPlay value = boolAttr "autoplay" value //of bool
let inline Capture value = boolAttr "capture" value //of bool
let inline CellPadding value = objAttr "cellpadding" value //of obj
let inline CellSpacing value = objAttr "cellspacing" value //of obj
let inline CharSet value = attr "charset" value //of string
let inline Challenge value = attr "challenge" value //of string
let inline Checked value = boolAttr "checked" value //of bool
let inline ClassID value = attr "class" value //of string
let inline ClassName value = attr "class" value//of string
/// Alias value = //of ClassName
let inline Class value = attr "class" value //of string
let inline Cols value = floatAttr "cols" value //of float
let inline ColSpan value = floatAttr "colspan" value //of float
let inline Content value = attr "content" value //of string
let inline ContentEditable value = boolAttr "contenteditable" value //of bool
let inline ContextMenu value = attr "contextmenu" value //of string
let inline Controls value = boolAttr "controls" value //of bool
let inline Coords value = attr "coords" value //of string
let inline CrossOrigin value = attr "crossorigin" value //of string
// let inline Data value = //of string
let inline DataToggle value = attr "data-toggle" value //of string
let inline DateTime value = attr "datetime" value //of string
let inline Default value = boolAttr "default" value //of bool
let inline Defer value = boolAttr "defer" value //of bool
let inline Dir value = attr "dir" value //of string
let inline Disabled value = boolAttr "disabled" value //of bool
let inline Download value = objAttr "download" value //of obj
let inline Draggable value = boolAttr "draggable" value //of bool
let inline EncType value = attr "enctype" value //of string
let inline Form value = attr "form" value //of string
let inline FormAction value = attr "formaction" value //of string
let inline FormEncType value = attr "fromenctype" value //of string
let inline FormMethod value = attr "formmethod" value //of string
let inline FormNoValidate value = boolAttr "formnovalidate" value //of bool
let inline FormTarget value = attr "formtarget" value //of string
let inline FrameBorder value = objAttr "frameborder" value //of obj
let inline Headers value = attr "headers" value //of string
let inline Height value = objAttr "height" value //of obj
let inline Hidden value = boolAttr "hidden" value //of bool
let inline High value = floatAttr "high" value //of float
let inline Href value = attr "href" value //of string
let inline HrefLang value = attr "hreflang" value //of string
let inline HtmlFor value = attr "htmlfor" value //of string
let inline HttpEquiv value = attr "htmlequiv" value //of string
let inline Icon value = attr "icon" value //of string
let inline Id value = attr "id" value //of string
let inline InputMode value = attr "inputmode" value //of string
let inline Integrity value = attr "integrity" value //of string
let inline Is value = attr "is" value //of string
let inline KeyParams value = attr "keyparams" value //of string
let inline KeyType value = attr "keytype" value //of string
let inline Kind value = attr "kind" value //of string
let inline Label value = attr "label" value //of string
let inline Lang value = attr "lang" value //of string
//let inline List value = attr "list" value //of string
let inline Loop value = boolAttr "loop" value //of bool
let inline Low value = floatAttr "low" value //of float
let inline Manifest value = attr "manifest" value //of string
let inline MarginHeight value = floatAttr "marginheight" value //of float
let inline MarginWidth value = floatAttr "marginwidth" value //of float
let inline Max value = objAttr "max" value //of obj
let inline MaxLength value = floatAttr "maxlength" value //of float
let inline Media value = attr "media" value //of string
let inline MediaGroup value = attr "mediagroup" value //of string
let inline Method value = attr "method" value //of string
let inline Min value = objAttr "min" value //of obj
let inline MinLength value = floatAttr "minlength" value //of float
let inline Multiple value = boolAttr "multiple" value //of bool
let inline Muted value = boolAttr "muted" value //of bool
let inline Name value = attr "name" value //of string
let inline NoValidate value = boolAttr "novalidate" value //of bool
let inline Open value = boolAttr "open" value //of bool
let inline Optimum value = floatAttr "optimum" value //of float
let inline Pattern value = attr "pattern" value //of string
let inline Placeholder value = attr "placeholder" value //of string
let inline Poster value = attr "poster" value //of string
let inline Preload value = attr "preload" value //of string
let inline RadioGroup value = attr "radiogroup" value //of string
let inline ReadOnly value = boolAttr "readonly" value //of bool
let inline Rel value = attr "rel" value //of string
let inline Required value = boolAttr "required" value //of bool
let inline Role value = attr "role" value //of string
let inline Rows value = floatAttr "rows" value //of float
let inline RowSpan value = floatAttr "rowspan" value //of float
let inline Sandbox value = attr "sandbox" value //of string
let inline Scope value = attr "scope" value //of string
let inline Scoped value = boolAttr "scoped" value //of bool
let inline Scrolling value = attr "scrolling" value //of string
let inline Seamless value = boolAttr "seamless" value //of bool
let inline Selected value = boolAttr "selected" value //of bool
let inline Shape value = attr "shape" value //of string
let inline Size value = floatAttr "size" value //of float
let inline Sizes value = attr "sizes" value //of string
let inline Span value = floatAttr "span" value //of float
let inline SpellCheck value = boolAttr "spellcheck" value //of bool
let inline Src value = attr "src" value //of string
let inline SrcDoc value = attr "srcdoc" value //of string
let inline SrcLang value = attr "srclang" value //of string
let inline SrcSet value = attr "srcset" value //of string
let inline Start value = floatAttr "start" value //of float
let inline Step value = objAttr "step" value //of obj
let inline Summary value = attr "summary" value//of string
let inline TabIndex value = floatAttr "tabindex" value //of float
let inline Target value = attr "taget" value //of string
let inline Title value = attr "title" value//of string
let inline Type value = attr "type" value //of string
let inline UseMap value = attr "usemap" value //of string
let inline Value value = attr "value " value//of string
let inline Width value = objAttr "width" value //of obj
let inline Wmode value = attr "wmode" value //of string
let inline Wrap value = attr "wrap" value //of string
let inline About value = attr "about" value //of string
let inline Datatype value = attr "datatype" value //of string
let inline Inlist value = objAttr "inlist" value //of obj
let inline Prefix value = attr "prefix" value //of string
let inline Property value = attr "property" value //of string
let inline Resource value = attr "resource" value //of string
let inline Typeof value = attr "typeof" value //of string
let inline Vocab value = attr "vocab" value //of string
let inline AutoCapitalize value = attr "autocapitalize" value //of string
let inline AutoCorrect value = attr "autocorrect" value //of string
let inline AutoSave value = attr "autosave" value //of string
let inline ItemProp value = attr "itemprop" value //of string
let inline ItemScope value = boolAttr "itemscope" value //of bool
let inline ItemType value = attr "itemtype" value //of string
let inline ItemID value = attr "itemid" value //of string
let inline ItemRef value = attr "itemref" value //of string
let inline Results value = floatAttr "results" value //of float
let inline Security value = attr "security" value //of string
let inline Unselectable value = boolAttr "unselectable" value //of bool
let inline str s = rawText s
// Standard elements
let inline a b c = domEl "a" b c
let inline abbr b c = domEl "abbr" b c
let inline address b c = domEl "address" b c
let inline article b c = domEl "article" b c
let inline aside b c = domEl "aside" b c
let inline audio b c = domEl "audio" b c
let inline b b' c = domEl "b" b' c
let inline bdi b c = domEl "bdi" b c
let inline bdo b c = domEl "bdo" b c
let inline big b c = domEl "big" b c
let inline blockquote b c = domEl "blockquote" b c
let inline body b c = domEl "body" b c
let inline button b c = domEl "button" b c
let inline canvas b c = domEl "canvas" b c
let inline caption b c = domEl "caption" b c
let inline cite b c = domEl "cite" b c
let inline code b c = domEl "code" b c
let inline colgroup b c = domEl "colgroup" b c
let inline data b c = domEl "data" b c
let inline datalist b c = domEl "datalist" b c
let inline dd b c = domEl "dd" b c
let inline del b c = domEl "del" b c
let inline details b c = domEl "details" b c
let inline dfn b c = domEl "dfn" b c
let inline dialog b c = domEl "dialog" b c
let inline div b c = domEl "div" b c
let inline dl b c = domEl "dl" b c
let inline dt b c = domEl "dt" b c
let inline em b c = domEl "em" b c
let inline fieldset b c = domEl "fieldset" b c
let inline figcaption b c = domEl "figcaption" b c
let inline figure b c = domEl "figure" b c
let inline footer b c = domEl "footer" b c
let inline form b c = domEl "form" b c
let inline h1 b c = domEl "h1" b c
let inline h2 b c = domEl "h2" b c
let inline h3 b c = domEl "h3" b c
let inline h4 b c = domEl "h4" b c
let inline h5 b c = domEl "h5" b c
let inline h6 b c = domEl "h6" b c
let inline head b c = domEl "head" b c
let inline header b c = domEl "header" b c
let inline hgroup b c = domEl "hgroup" b c
let inline html b c = domEl "html" b c
let inline i b c = domEl "i" b c
let inline iframe b c = domEl "iframe" b c
let inline ins b c = domEl "ins" b c
let inline kbd b c = domEl "kbd" b c
let inline label b c = domEl "label" b c
let inline legend b c = domEl "legend" b c
let inline li b c = domEl "li" b c
let inline main b c = domEl "main" b c
let inline map b c = domEl "map" b c
let inline mark b c = domEl "mark" b c
let inline menu b c = domEl "menu" b c
let inline meter b c = domEl "meter" b c
let inline nav b c = domEl "nav" b c
let inline noscript b c = domEl "noscript" b c
let inline ``object`` b c = domEl "object" b c
let inline ol b c = domEl "ol" b c
let inline optgroup b c = domEl "optgroup" b c
let inline option b c = domEl "option" b c
let inline output b c = domEl "output" b c
let inline p b c = domEl "p" b c
let inline picture b c = domEl "picture" b c
let inline pre b c = domEl "pre" b c
let inline progress b c = domEl "progress" b c
let inline q b c = domEl "q" b c
let inline rp b c = domEl "rp" b c
let inline rt b c = domEl "rt" b c
let inline ruby b c = domEl "ruby" b c
let inline s b c = domEl "s" b c
let inline samp b c = domEl "samp" b c
let inline script b c = domEl "script" b c
let inline section b c = domEl "section" b c
let inline select b c = domEl "select" b c
let inline small b c = domEl "small" b c
let inline span b c = domEl "span" b c
let inline strong b c = domEl "strong" b c
let inline style b c = domEl "style" b c
let inline sub b c = domEl "sub" b c
let inline summary b c = domEl "summary" b c
let inline sup b c = domEl "sup" b c
let inline table b c = domEl "table" b c
let inline tbody b c = domEl "tbody" b c
let inline td b c = domEl "td" b c
let inline textarea b c = domEl "textarea" b c
let inline tfoot b c = domEl "tfoot" b c
let inline th b c = domEl "th" b c
let inline thead b c = domEl "thead" b c
let inline time b c = domEl "time" b c
let inline title b c = domEl "title" b c
let inline tr b c = domEl "tr" b c
let inline u b c = domEl "u" b c
let inline ul b c = domEl "ul" b c
let inline var b c = domEl "var" b c
let inline video b c = domEl "video" b c
// Void element
let inline area b = voidEl "area" b
let inline ``base`` b = voidEl "base" b
let inline br b = voidEl "br" b
let inline col b = voidEl "col" b
let inline embed b = voidEl "embed" b
let inline hr b = voidEl "hr" b
let inline img b = voidEl "img" b
let inline input b = voidEl "input" b
let inline keygen b = voidEl "keygen" b
let inline link b = voidEl "link" b
let inline menuitem b = voidEl "menuitem" b
let inline meta b = voidEl "meta" b
let inline param b = voidEl "param" b
let inline source b = voidEl "source" b
let inline track b = voidEl "track" b
let inline wbr b = voidEl "wbr" b
(*// SVG elements
let inline svg b c = svgEl "svg" b c
let inline circle b c = svgEl "circle" b c
let inline clipPath b c = svgEl "clipPath" b c
let inline defs b c = svgEl "defs" b c
let inline ellipse b c = svgEl "ellipse" b c
let inline g b c = svgEl "g" b c
let inline image b c = svgEl "image" b c
let inline line b c = svgEl "line" b c
let inline linearGradient b c = svgEl "linearGradient" b c
let inline mask b c = svgEl "mask" b c
let inline path b c = svgEl "path" b c
let inline pattern b c = svgEl "pattern" b c
let inline polygon b c = svgEl "polygon" b c
let inline polyline b c = svgEl "polyline" b c
let inline radialGradient b c = svgEl "radialGradient" b c
let inline rect b c = svgEl "rect" b c
let inline stop b c = svgEl "stop" b c
let inline text b c = svgEl "text" b c
let inline tspan b c = svgEl "tspan" b c*)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment