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
jade template
Search
oted
August 22, 2014
Technology
0
520
jade template
oted
August 22, 2014
Tweet
Share
Other Decks in Technology
See All in Technology
なぜ今、コスト最適化(倹約)が必要なのか? ~AWSでのコスト最適化の進め方「目的編」~
htan
1
110
Embedded SREの終わりを設計する 「なんとなく」から計画的な自立支援へ
sansantech
PRO
3
2.1k
顧客との商談議事録をみんなで読んで顧客解像度を上げよう
shibayu36
0
160
学生・新卒・ジュニアから目指すSRE
hiroyaonoe
2
550
Tebiki Engineering Team Deck
tebiki
0
24k
クレジットカード決済基盤を支えるSRE - 厳格な監査とSRE運用の両立 (SRE Kaigi 2026)
capytan
6
2.6k
OCI Database Management サービス詳細
oracle4engineer
PRO
1
7.3k
SREのプラクティスを用いた3領域同時 マネジメントへの挑戦 〜SRE・情シス・セキュリティを統合した チーム運営術〜
coconala_engineer
2
590
(金融庁共催)第4回金融データ活用チャレンジ勉強会資料
takumimukaiyama
0
120
ファインディの横断SREがTakumi byGMOと取り組む、セキュリティと開発スピードの両立
rvirus0817
1
1.1k
Ruby版 JSXのRuxが気になる
sansantech
PRO
0
100
日本の85%が使う公共SaaSは、どう育ったのか
taketakekaho
1
140
Featured
See All Featured
Paper Plane (Part 1)
katiecoart
PRO
0
4k
Joys of Absence: A Defence of Solitary Play
codingconduct
1
290
Java REST API Framework Comparison - PWX 2021
mraible
34
9.1k
[RailsConf 2023] Rails as a piece of cake
palkan
59
6.3k
Testing 201, or: Great Expectations
jmmastey
46
8k
Optimizing for Happiness
mojombo
379
71k
Large-scale JavaScript Application Architecture
addyosmani
515
110k
Build your cross-platform service in a week with App Engine
jlugia
234
18k
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
300
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
60
42k
GraphQLの誤解/rethinking-graphql
sonatard
74
11k
The Power of CSS Pseudo Elements
geoffreycrofte
80
6.1k
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. ご清聴ありがとうございました。