summaryrefslogtreecommitdiff
path: root/config/kak/ocaml-snippets.kak
blob: 0d48bee5c355c207c568b6882b09e62f7158d9d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
set buffer snippets %opt{snippets} # keep global snippets (if any)
set -add buffer snippets 'Import Html libs' 'html-imp' %{ snippets-insert %{let open Dream_html in
let open HTML in
  }
  }
set -add buffer snippets 'Create form' 'letform-' \
        %{ phantom-selection-clear ; snippets-insert %{let form ~csrf req =
  match%lwt Dream.form ~csrf req with
  | `Ok [ ("${}", ${}); ] ->
    Lwt_result.return (${})
  | e -> Lwt_result.fail (`Form e)
  ${}
}; phantom-selection-add-selection ; phantom-selection-iterate-next }

set -add buffer snippets 'Create user form (base)' 'form-b' \
        %{ snippets-insert %{null 
  [ h2 [] [txt "${}"] 
  ; form
          [ id "${}"; action "/${}"; method_ `POST ]
          [ csrf_tag req
          ; br []
          ]
  ]
};  }

set -add buffer snippets 'Create user form (text field)' 'form-tf' \
        %{ snippets-insert %{; label [ for_ "${}" ] [ txt "${}" ]
  ; input [ id "${}"; name "${}"; type_ "text" ]
  ; br []
};  }

set -add buffer snippets 'Create user form (submit)' 'form-s' \
        %{ snippets-insert %{; button [type_ "submit"] [ txt "${}" ]
};  }