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

Meta Template Engine

ayato
October 02, 2017

Meta Template Engine

ayato

October 02, 2017
Tweet

More Decks by ayato

Other Decks in Programming

Transcript

  1. HTMLフォーム面倒 <div class="form-group"> <label for="input-email">Email Address</label> <input id="input-email" class="form-control" type="email"

    name="email" th:classappend= "${errors.containsKey('email')} ? 'is-invalid'" th:value="${values.email}" placeholder="Enter email" /> <div class="invalid-feedback" th:text="${errors.email}"> </div> <small class="form-text text-muted"> We'll never share your email with anyone else. </small> </div>
  2. HTMLフォーム面倒 [: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."]]
  3. HTMLフォーム面倒 [: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."]] ここが決まれば…
  4. HTMLフォーム面倒 [: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."]] ここが決まるはず
  5. 変換ルール( (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]))
  6. 変換ルール) (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]))
  7. これを… (ultimate/transform opts [: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."]])
  8. こんな感じで展開できる [: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."]] ※イメージです
  9. [: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."]] ここが消えた! こんな感じで展開できる