Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
jade template
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
oted
August 22, 2014
Technology
530
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
jade template
oted
August 22, 2014
Other Decks in Technology
See All in Technology
UniFi(ユニファイ)AIカメラの現場活用
ludicmind
1
440
しろおびから始める!ログ活用の第一歩
shumei_ito
0
950
"優秀な誰か"の下位互換にならないために
yut0naga1_fa
1
1.8k
オントロジーって 結局なにもの? AI エージェントに「意味」を渡す知識設計の話
greenmidori
0
180
How to Design Configuration for Rails Applications
willnet
1
770
Temporal 最高!でも改めて「日付」について調べたら人類の負債すぎる件
riyaamemiya
0
140
遠藤な_めぐろLT #38 「社内のAI活用推進」@麻布台_20261009
endonanana
0
130
JAWS-UGグッズ職人仕事の流儀
kentapapa
0
100
AIカンパニーへの転換を支えた、エンジニアの仕事の再定義
kworkdev
PRO
2
1.2k
Claude の新機能を、 出た日に触って社内に届けるまで
rfdnxbro
1
170
SAENM ~Jupyterで残すPoCの試行錯誤、未来の自分と仲間を助ける記録!~
terapyon
0
110
二歩目のフロントエンド・ウェブアクセシビリティ
camiha
2
570
Featured
See All Featured
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
750
[Rails World 2026] Durable orchestration on Rails: from continuation to workflow
palkan
1
750
A Soul's Torment
seathinner
8
3.8k
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
6
1.2k
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
2
410
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
1
3.4k
Java REST API Framework Comparison - PWX 2021
mraible
34
9.8k
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
550
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
33
5.2k
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
56k
Ruling the World: When Life Gets Gamed
codingconduct
0
400
Transcript
© IMJ Corporation. All Rights Reserved. jadeで作るclient template
© IMJ Corporation. All Rights Reserved. 太田 智彬 TTOOMMOOAAKKII OOTTAA
テクニカルディレクター // エンジニア 22001122年1122月-- 22001133年66月 WWeebb DDeessiiggnniinngg ((jjQQuueerryy LLaabb..)) 22001133年55月1177日 現場で役立つCCSSSS33デザインパーツライブラリ
© IMJ Corporation. All Rights Reserved. client templateとは
© IMJ Corporation. All Rights Reserved. データとテンプレートを合体させ、文字列 を作る仕組みのこと。
© IMJ Corporation. All Rights Reserved. どんなものがあるのか?
© IMJ Corporation. All Rights Reserved. Mustache / Hogan.js <script
type=“text/template”> <h1>Hello {{ name }}!</h1> </script>
© IMJ Corporation. All Rights Reserved. Underscore.js / EJS <script
type=“text/template”> <h1>Hello <%= name %></h1> </script>
© IMJ Corporation. All Rights Reserved. Polymer / platform.js (HTML5
template) <template id=“greeting”> <h1>Hello {{ name }}!</h1> </template>
© IMJ Corporation. All Rights Reserved. 偉大なる先人達が作り上げたライブラリは どれも素晴らしい。
© IMJ Corporation. All Rights Reserved. だが待ってください。
© IMJ Corporation. All Rights Reserved. jadeを使うという選択肢もあります。
© IMJ Corporation. All Rights Reserved. そもそもjadeとは何なのか?
© IMJ Corporation. All Rights Reserved. HTMLのテンプレートエンジンです。
© IMJ Corporation. All Rights Reserved. jadeを使えばHTML/HTML templateどちらも jadeで書けます。 しかも、ライブラリが一切必要ない。
さらに、templateを外部ファイルで持てる ため、component管理が可能。
© IMJ Corporation. All Rights Reserved. コンパイル前 / .jade #triton.js
p= HTML5minutes! コンパイル後 / .html <div id="triton" class="js"> <p>HTML5minutes!</p> </div>
© IMJ Corporation. All Rights Reserved. jadeはコンパイルオプションを指定すれば、 JavaScriptにもコンパイル出来ます。
© IMJ Corporation. All Rights Reserved. HTMLにコンパイルする時と同様の記法で jadeファイルを作成します。 #triton.js p=
msg ※msgは変数名です。
© IMJ Corporation. All Rights Reserved. コンパイルすると、objectを引数にとって HTMLを返す関数が生成されます。 function template(object)
{ return ( "<div id=\"triton\" class=\"js\"><p>" + object.msg + "</p></div>” ); };
© IMJ Corporation. All Rights Reserved. では、このコンパイルしたjsファイルをどう使う のか?
© IMJ Corporation. All Rights Reserved. browserifyを使用します。 ※browserifyとは、node.jsのrequireと同等の機能 をclient side
JavaScriptでも提供してくれるツール です。
© IMJ Corporation. All Rights Reserved. 先ほど作ったjade templateをrequireします。 $ =
require(‘jQuery’); tmpl = require('./_template.jade');
© IMJ Corporation. All Rights Reserved. 引数にobjectを渡してappendします。 $(‘body’).append( tmpl({ msg:
'HTML5minutes!' }) );
© IMJ Corporation. All Rights Reserved. <body> <div id="triton" class="js">
<p>HTML5minutes!</p> </div> </body>
© IMJ Corporation. All Rights Reserved. データバインディング機能を持つMV*フ レームワークと組み合わせると、さらに便 利です。
© IMJ Corporation. All Rights Reserved. 今流行りのVue.jsと連携
© IMJ Corporation. All Rights Reserved. Vue.jsとは
© IMJ Corporation. All Rights Reserved. MVVMというMVCの派生を設計基盤として 構築されたJavascriptフレームワーク。 Viewに特化しており、Angular.js同様データ バインディング機能をもつ。
© IMJ Corporation. All Rights Reserved. _template.jade div p {{name}}
© IMJ Corporation. All Rights Reserved. Vue = require("vue"); tmpl
= require(“./_template.jade”); Vue.component('test', Vue.extend({ template: tmpl(), data: { name: ”うおーーーー” } })); ~ 省略 ~
© IMJ Corporation. All Rights Reserved. <div> <p>うおーーーー</p> </div>
© IMJ Corporation. All Rights Reserved. API連携やcomponent管理が必要な場合は 是非導入�を検討してみてください。 SPAなど、JavaScriptでコンテンツを丸ごと 差し替える場合は、威力を発揮します。
© IMJ Corporation. All Rights Reserved. サンプルはこちらです。 https://github.com/tk-ota/jade-template
© IMJ Corporation. All Rights Reserved. ご清聴ありがとうございました。