项目作者: darkleaf

项目描述 :
Form builder for reagent library
高级语言: Clojure
项目地址: git://github.com/darkleaf/form.git
创建时间: 2017-05-15T19:56:58Z
项目社区:https://github.com/darkleaf/form

开源协议:

下载


Build Status
Coverage Status
Clojars Project

Features

  • twitter bootstrap4
  • nested forms support
  • interface for i18n engines
  • interface for validation engines
  • clojure.spec integration
  • complete test coverage

Demo

Installation

  1. [reagent "0.7.0"]
  2. [darkleaf/form "0.1.0"]

Usage example

  1. <!doctype html>
  2. <html>
  3. <head>
  4. <title>Form</title>
  5. <meta charset="utf-8" />
  6. <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
  7. <!-- add bootstrap styles -->
  8. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous" />
  9. </head>
  10. <body>
  11. <div class="container">
  12. <div id="point">app mount point</div>
  13. </div>
  14. <script type="text/javascript" src="build/dev/main.js"></script>
  15. </body>
  16. </html>
  1. (ns app
  2. (:require
  3. [reagent.core :as r]
  4. [darkleaf.form.context :as ctx]
  5. [darkleaf.form.bootstrap4 :as bootstrap]))
  6. (defn i18n-error [path error]
  7. "some logic")
  8. (defn i18n-label [path]
  9. "some logic")
  10. (defn form [data errors]
  11. ;; i18n is optional
  12. (let [f (ctx/build data errors update {:error i18n-error, :label i18n-label})]
  13. [:form
  14. [bootstrap/text f :some-attribute-name]]))
  15. (def data {:some-attrubte-name "foo bar"})
  16. (def errors {})
  17. (r/render [form data errors]
  18. (.getElementById js/document "point"))

Please see demo or tests for more examples.