Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Meta Template Engine
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
ayato
October 02, 2017
Programming
1.2k
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Meta Template Engine
ayato
October 02, 2017
More Decks by ayato
See All by ayato
マイクロサービス内で動くAPIをF#で書いている
ayato0211
1
1.6k
Clojureという言語が私逹にもたらしたもの
ayato0211
6
3.2k
3年間考え続けてきたWebアプリケーションにおけるテストの話
ayato0211
3
300
Re:REPL-Driven Development
ayato0211
3
1.4k
超変換! Hiccup data structure!!
ayato0211
2
670
About Integrant
ayato0211
0
600
Muscle Assert
ayato0211
0
320
Clojureを用いたWebアプリケーション開発
ayato0211
2
3.2k
翻訳にまつわるエトセトラ
ayato0211
6
1.3k
Other Decks in Programming
See All in Programming
エンジニア向け会社紹介/Findy Company Profile
findyinc
6
350k
エージェンティックRAGにAWSで入門しよう!
har1101
9
1.8k
Observability in Practice:Grafana 與 Edge Device SRE 的那些事
blueswen
0
180
LLM本来の能力を解き放つサンドボックス技術とAI民主化への適用
yukukotani
3
4.6k
Spring Security 実践 ─ GraphQL APIで実務に役立つ 認証・認可 を学ぶ
wagyu
0
260
The ROI of Quarkus for Spring Boot Applications
hollycummins
0
140
ECSアプリログをFireLensでコスト削減しようとしたけど諦めた話 in Fargate×Node.js
akihisaikeda
2
4.2k
技術的負債解消で開発者の未来を開く- AIの力でコード刷新
kmd2kmd
0
120
不変条件と整合性境界—ビジネスが決める設計判断と実現パターン / Invariants and Consistency Boundaries
nrslib
14
5.9k
Vue × Nuxt × Oxc どこまで使える?実運用の現在地
andpad
0
300
なぜ型を書くのか? TSKaigi2026で改めて考える #tskaigi_smarthr
kajitack
0
160
LLMによるContent Moderationの本番運用の裏側と品質担保への挑戦
suikabar
3
780
Featured
See All Featured
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
The Limits of Empathy - UXLibs8
cassininazir
1
370
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
260
[SF Ruby Conf 2025] Rails X
palkan
2
1.1k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
123
22k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.5k
Facilitating Awesome Meetings
lara
57
7k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.2k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
640
Why You Should Never Use an ORM
jnunemaker
PRO
61
9.9k
Transcript
メタテンプレートエンジンの話 市ヶ谷Geek★Night#14 市ヶ谷java 〜JVM言語の玉手箱〜
メタテンプレートエンジンの話 市ヶ谷Geek★Night#14 市ヶ谷clojure 〜JVM言語の玉手箱〜
あやぴー •ayato-p@github •Cybozu Startups, Inc. •Clojure書いてる •Webアプリ書いてる
TL;DR
というわけで…
Clojureの話をします
事の発端
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>
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."]]
面倒なこと •_methodみたいなやつ •formのmethod属性に直接putとかdelete書きたい •__csrf_tokenみたいなやつ •いちいち書くのは面倒 •エラー表示のために書く条件分岐 •前回表示していた値を表示するための式 •たいていの場合name属性に依存している
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."]] ここが決まれば…
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."]] ここが決まるはず
考えた
テンプレートエンジンが HTMLに変換する前に 求める形に変換できれば いいんじゃない
つまり… メタテンプレートエンジン…
Kuuga https://github.com/ayato-p/kuuga
“こんなやつらのために、 これ以上誰かの涙は⾒たくない! 皆に笑顔でいて欲しいんです! だから⾒ててください!俺の…変⾝!! ”
“HTML Formのために、 これ以上誰かの涙は⾒たくない! Hiccupユーザーに笑顔でいて欲しいんです! だから⾒ててください!俺の…変換!! ”
変換ルール( (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]))
変換ルール) (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]))
そうすると
これを… (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."]])
こんな感じで展開できる [: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."]] ※イメージです
[: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."]] ここが消えた! こんな感じで展開できる
まとめ •Kuugaは超便利 •Clojureはいいぞ •9/25(月) Lisp Meetup •10/4(水) 教養としてのClojure
Enjoy Clojure