Upgrade to Pro — share decks privately, control downloads, hide ads and more …

超変換! Hiccup data structure!!

ayato
August 31, 2017

超変換! Hiccup data structure!!

ayato

August 31, 2017
Tweet

More Decks by ayato

Other Decks in Programming

Transcript

  1. [:div.form-group [:label {:for "input-email"} "Email address"] [:input#input-email.form-control {:type :email :name

    :email :class (when (contains? errors :email) "is-invalid") :value (:email values) :placeholer "Enter email"}] [:div.invalid-feedback (:email errors)] [:small.form-text.text-muted "We'll never share your email with anyone else."]] Bootstrap4の場合
  2. [:div.form-group [:label {:for "input-email"} "Email address"] [:input#input-email.form-control {:type :email :name

    :email :class (when (contains? errors :email) "is-invalid") :value (:email values) :placeholer "Enter email"}] [:div.invalid-feedback (:email errors)] [:small.form-text.text-muted "We'll never share your email with anyone else."]] Bootstrap4の場合
  3. 変換ルールを書く-その) (defmethod growing/transform-by-tag :input [_ options tag-vector] (let [[tagkw tagopts

    contents] (tool/parse-tag-vector tag-vector)] `[~tagkw (update-input-opts ~options ~tagopts) ~@contents]))
  4. 変換ルールを書く-その* (defmethod growing/transform-by-class :form-group [_ options tag-vector] (let [[tagkw tagopts

    contents] (tool/parse-tag-vector tag-vector) contents (reduce (fn [contents' tagvec'] (let [[tk to _] (tool/parse-tag-vector tagvec') [_ t] (tool/parse-tag-keyword tk)] (cond-> (conj contents' tagvec') (= t "input") (conj `(invalid-fb ~options ~to))))) [] contents))] `[~tagkw ~tagopts ~@contents]))
  5. これを… [:div.form-group [:label {:for "input-email"} "Email address"] [:input#input-email.form-control {:type :email

    :name :email :placeholder "Enter email"}] [:small.form-text.text-muted "We'll never share your email with anyone else."]]
  6. こんな感じで展開できる [:div.form-group [:label {:for "input-email"} "Email address"] [:input#input-email.form-control {:type :email

    :name :email :class (when (contains? errors :email) "is-invalid") :value (:email values) :placeholder "Enter email"}] [:div.invalid-feedback (:email errors)] [:small.form-text.text-muted "We'll never share your email with anyone else."]] ※イメージです