SlideShare a Scribd company logo
1 of 16
JavaScript の
テンプレートエンジンについて
   2012/04/29 鹿駆動勉強会
   お だ
自己紹介
織田 信亮(おだ しんすけ)
大阪で開発者やってます
SQLWorld 代表(http://sqlworld.org/)

http://d.hatena.ne.jp/odashinsuke/
@shinsukeoda
JavaScriptの
テンプレートエンジン
といえば…
jQuery Templates!
ご存じかもしれませんが…
jQuery Templates は非推奨になりました
   beta のまま開発終了
https://github.com/jquery/jquery-tmpl
 A templating plugin for jQuery. BETA. NO LONGER
 IN ACTIVE DEVELOPMENT OR MAINTENANCE.
 Issues remain open but are not being worked.
cト       cト /^、_ノ     | 、.__ つ       (.__
 ̄ ̄ ̄ ̄       ・ ・

                      ,. -─- 、._                                ,. -─v─- 、._
_
                   ,. ‐'´         `‐、
__, ‐'´                  ヽ, ‐''´~    `´ ̄`‐、
               /                  ヽ、_/)ノ  ≦                               ヽ‐'´
`‐、
           /          / ̄~`'''‐- 、.._          ノ    ≦
≦                              ヽ
            i.       /                    ̄l 7      1      イ/l/|ヘ ヽヘ
≦       , ,ヘ 、                  i
            ,!ヘ. / ‐- 、._          u        |/         l |/ !      ! | ヾ ヾ ヽ_、l
イ/l/|/ヽlヘト、             │
.           |〃、!ミ:      -─ゝ、          __ .l            レ二ヽ、 、__∠´_ |/
| ! |    | ヾ ヾヘト、         l
            !_ヒ;       L(.:)_ `ー'"〈:)_,` /              riヽ_(:)_i         '_
(:)_/ ! ‐;-、     、__,._-─‐ヽ. ,.-'、
            /`゙i u            ´         ヽ !              !{         ,!        `
( } ' (:)〉      ´(.:)`i        |//ニ !
        _/:::::::!                        ,,..ゝ!              ゙!      ヽ
'           .゙!    7         ̄         | トy'/
_,,. -‐ヘ::::::::::::::ヽ、           r'´~`''‐、 /                      !、    ‐=ニ⊃
/! `ヽ"           u      ;-‐i´
  !      \::::::::::::::ヽ         `ー─ ' /                       ヽ        ‐-
/ ヽ      ` ̄二)            /ヽト、
  i、        \:::::::::::::::..、      ~" /                            ヽ.___,./
というわけで
今日の LT は終了!
ではなく…
JsRender
https://github.com/BorisMoore/jsrender
 jQuery 公式ページに、リンクされている
 新しいテンプレートエンジン
  http://api.jquery.com/category/plugins/tem
  plates/
 文字列ベースで、DOM や jQuery にも依
 存しない
  http://www.borismoore.com/2011/10/jquery-
  templates-and-jsviews-roadmap.html
DEMO 1
http://shikadriven.apphb.com/index.html
 Twitter から #shikadriven で検索し一
 覧表示
JsViews
https://github.com/BorisMoore/jsviews
 JsRender をテンプレートエンジンに使っ
 て「データバインディング」を実現しま
 す
DEMO 2
http://shikadriven.apphb.com/view.html
 Twitter の検索結果を書き換える
まとめ
jQuery Templates は開発止まってる
JsRender が後継?
JsViews で バインディングも可能
日本語の情報少ないので、使って発信し
よう!
デモで使ったテンプレートの紹介
テンプレートには、Object/Array が渡せる
   Array を渡した場合は、全ての要素に対してテ
   ンプレートがレンダリングされる
{{:propertyName}}
    プロパティ値をそのまま出力する
{{html:propertyName}}
   プロパティ値を組み込みの HTML エンコード
   で出力する
{{>propertyName}}
   {{html:propertyName} の代替構文
デモで使ったテンプレートの紹介
{{for Object/Array ...}}…{{/for}
   繰り返し構文というよりは、インラインの
   ネストしたテンプレート
   " "(スペース区切り)で、複数の
   Object/Array を指定出来る
   インラインテンプレートは、外出し可能
   <script id="mainTmpl" type="text/x-jsrender">
   {{for Object/Array ... tmpl="#extTmpl" /}}
   </script>
   <script id="extTmpl" type="text/x-jsrender">
     〜
   </script>
デモで使ったテンプレートの紹介
#data
   テンプレートに渡された Object
   Array が渡されていた場合は、Array の 1
   要素
   使い方
   {{:#data.query}}
   {{for #data.results}}…{{/for}}

More Related Content

More from Oda Shinsuke

Dot net+sql server tips
Dot net+sql server tipsDot net+sql server tips
Dot net+sql server tipsOda Shinsuke
 
Sql server 2019 ざっくり紹介
Sql server 2019  ざっくり紹介Sql server 2019  ざっくり紹介
Sql server 2019 ざっくり紹介Oda Shinsuke
 
Spark on sql server?
Spark on sql server?Spark on sql server?
Spark on sql server?Oda Shinsuke
 
SQL Server のロック概要
SQL Server のロック概要SQL Server のロック概要
SQL Server のロック概要Oda Shinsuke
 
Blazor 触ってみた
Blazor 触ってみたBlazor 触ってみた
Blazor 触ってみたOda Shinsuke
 
Linux + PHP でも SQL Server
Linux + PHP でも SQL ServerLinux + PHP でも SQL Server
Linux + PHP でも SQL ServerOda Shinsuke
 
グラフデータベースの話し
グラフデータベースの話しグラフデータベースの話し
グラフデータベースの話しOda Shinsuke
 
Sql server 2017 新機能のご紹介
Sql server 2017 新機能のご紹介Sql server 2017 新機能のご紹介
Sql server 2017 新機能のご紹介Oda Shinsuke
 
Sql server 2017 からはじめる graph データベース
Sql server 2017 からはじめる graph データベースSql server 2017 からはじめる graph データベース
Sql server 2017 からはじめる graph データベースOda Shinsuke
 
Transaction scopeまだダメ
Transaction scopeまだダメTransaction scopeまだダメ
Transaction scopeまだダメOda Shinsuke
 
Sql serverと他dbの違いを押さえよう!
Sql serverと他dbの違いを押さえよう!Sql serverと他dbの違いを押さえよう!
Sql serverと他dbの違いを押さえよう!Oda Shinsuke
 
2016年を振り返って
2016年を振り返って2016年を振り返って
2016年を振り返ってOda Shinsuke
 
開発者の方向けの Sql server(db) t sql 振り返り
開発者の方向けの Sql server(db) t sql 振り返り開発者の方向けの Sql server(db) t sql 振り返り
開発者の方向けの Sql server(db) t sql 振り返りOda Shinsuke
 
Ms build 触ってみよう
Ms build 触ってみようMs build 触ってみよう
Ms build 触ってみようOda Shinsuke
 
Sql server2014復習とsqlserver2016の紹介
Sql server2014復習とsqlserver2016の紹介Sql server2014復習とsqlserver2016の紹介
Sql server2014復習とsqlserver2016の紹介Oda Shinsuke
 
Sql server sql database 最新機能紹介
Sql server sql database 最新機能紹介Sql server sql database 最新機能紹介
Sql server sql database 最新機能紹介Oda Shinsuke
 
Selenium 触ってみよう
Selenium 触ってみようSelenium 触ってみよう
Selenium 触ってみようOda Shinsuke
 

More from Oda Shinsuke (20)

What's hyperscale
What's hyperscaleWhat's hyperscale
What's hyperscale
 
Dot net+sql server tips
Dot net+sql server tipsDot net+sql server tips
Dot net+sql server tips
 
Sql server 2019 ざっくり紹介
Sql server 2019  ざっくり紹介Sql server 2019  ざっくり紹介
Sql server 2019 ざっくり紹介
 
Spark on sql server?
Spark on sql server?Spark on sql server?
Spark on sql server?
 
SQL Server のロック概要
SQL Server のロック概要SQL Server のロック概要
SQL Server のロック概要
 
Blazor 触ってみた
Blazor 触ってみたBlazor 触ってみた
Blazor 触ってみた
 
Linux + PHP でも SQL Server
Linux + PHP でも SQL ServerLinux + PHP でも SQL Server
Linux + PHP でも SQL Server
 
グラフデータベースの話し
グラフデータベースの話しグラフデータベースの話し
グラフデータベースの話し
 
Sql server 2017 新機能のご紹介
Sql server 2017 新機能のご紹介Sql server 2017 新機能のご紹介
Sql server 2017 新機能のご紹介
 
Sql server 2017 からはじめる graph データベース
Sql server 2017 からはじめる graph データベースSql server 2017 からはじめる graph データベース
Sql server 2017 からはじめる graph データベース
 
Transaction scopeまだダメ
Transaction scopeまだダメTransaction scopeまだダメ
Transaction scopeまだダメ
 
Sql serverと他dbの違いを押さえよう!
Sql serverと他dbの違いを押さえよう!Sql serverと他dbの違いを押さえよう!
Sql serverと他dbの違いを押さえよう!
 
2016年を振り返って
2016年を振り返って2016年を振り返って
2016年を振り返って
 
Sql world とは
Sql world とはSql world とは
Sql world とは
 
開発者の方向けの Sql server(db) t sql 振り返り
開発者の方向けの Sql server(db) t sql 振り返り開発者の方向けの Sql server(db) t sql 振り返り
開発者の方向けの Sql server(db) t sql 振り返り
 
Sql world とは
Sql world とはSql world とは
Sql world とは
 
Ms build 触ってみよう
Ms build 触ってみようMs build 触ってみよう
Ms build 触ってみよう
 
Sql server2014復習とsqlserver2016の紹介
Sql server2014復習とsqlserver2016の紹介Sql server2014復習とsqlserver2016の紹介
Sql server2014復習とsqlserver2016の紹介
 
Sql server sql database 最新機能紹介
Sql server sql database 最新機能紹介Sql server sql database 最新機能紹介
Sql server sql database 最新機能紹介
 
Selenium 触ってみよう
Selenium 触ってみようSelenium 触ってみよう
Selenium 触ってみよう
 

Recently uploaded

論文紹介:Content-Aware Token Sharing for Efficient Semantic Segmentation With Vis...
論文紹介:Content-Aware Token Sharing for Efficient Semantic Segmentation With Vis...論文紹介:Content-Aware Token Sharing for Efficient Semantic Segmentation With Vis...
論文紹介:Content-Aware Token Sharing for Efficient Semantic Segmentation With Vis...Toru Tamaki
 
論文紹介:Semantic segmentation using Vision Transformers: A survey
論文紹介:Semantic segmentation using Vision Transformers: A survey論文紹介:Semantic segmentation using Vision Transformers: A survey
論文紹介:Semantic segmentation using Vision Transformers: A surveyToru Tamaki
 
Open Source UN-Conference 2024 Kawagoe - 独自OS「DaisyOS GB」の紹介
Open Source UN-Conference 2024 Kawagoe - 独自OS「DaisyOS GB」の紹介Open Source UN-Conference 2024 Kawagoe - 独自OS「DaisyOS GB」の紹介
Open Source UN-Conference 2024 Kawagoe - 独自OS「DaisyOS GB」の紹介Yuma Ohgami
 
論文紹介:Automated Classification of Model Errors on ImageNet
論文紹介:Automated Classification of Model Errors on ImageNet論文紹介:Automated Classification of Model Errors on ImageNet
論文紹介:Automated Classification of Model Errors on ImageNetToru Tamaki
 
スマートフォンを用いた新生児あやし動作の教示システム
スマートフォンを用いた新生児あやし動作の教示システムスマートフォンを用いた新生児あやし動作の教示システム
スマートフォンを用いた新生児あやし動作の教示システムsugiuralab
 
【早稲田AI研究会 講義資料】3DスキャンとTextTo3Dのツールを知ろう!(Vol.1)
【早稲田AI研究会 講義資料】3DスキャンとTextTo3Dのツールを知ろう!(Vol.1)【早稲田AI研究会 講義資料】3DスキャンとTextTo3Dのツールを知ろう!(Vol.1)
【早稲田AI研究会 講義資料】3DスキャンとTextTo3Dのツールを知ろう!(Vol.1)Hiroki Ichikura
 
[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略
[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略
[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略Ryo Sasaki
 
TSAL operation mechanism and circuit diagram.pdf
TSAL operation mechanism and circuit diagram.pdfTSAL operation mechanism and circuit diagram.pdf
TSAL operation mechanism and circuit diagram.pdftaisei2219
 
SOPを理解する 2024/04/19 の勉強会で発表されたものです
SOPを理解する       2024/04/19 の勉強会で発表されたものですSOPを理解する       2024/04/19 の勉強会で発表されたものです
SOPを理解する 2024/04/19 の勉強会で発表されたものですiPride Co., Ltd.
 

Recently uploaded (9)

論文紹介:Content-Aware Token Sharing for Efficient Semantic Segmentation With Vis...
論文紹介:Content-Aware Token Sharing for Efficient Semantic Segmentation With Vis...論文紹介:Content-Aware Token Sharing for Efficient Semantic Segmentation With Vis...
論文紹介:Content-Aware Token Sharing for Efficient Semantic Segmentation With Vis...
 
論文紹介:Semantic segmentation using Vision Transformers: A survey
論文紹介:Semantic segmentation using Vision Transformers: A survey論文紹介:Semantic segmentation using Vision Transformers: A survey
論文紹介:Semantic segmentation using Vision Transformers: A survey
 
Open Source UN-Conference 2024 Kawagoe - 独自OS「DaisyOS GB」の紹介
Open Source UN-Conference 2024 Kawagoe - 独自OS「DaisyOS GB」の紹介Open Source UN-Conference 2024 Kawagoe - 独自OS「DaisyOS GB」の紹介
Open Source UN-Conference 2024 Kawagoe - 独自OS「DaisyOS GB」の紹介
 
論文紹介:Automated Classification of Model Errors on ImageNet
論文紹介:Automated Classification of Model Errors on ImageNet論文紹介:Automated Classification of Model Errors on ImageNet
論文紹介:Automated Classification of Model Errors on ImageNet
 
スマートフォンを用いた新生児あやし動作の教示システム
スマートフォンを用いた新生児あやし動作の教示システムスマートフォンを用いた新生児あやし動作の教示システム
スマートフォンを用いた新生児あやし動作の教示システム
 
【早稲田AI研究会 講義資料】3DスキャンとTextTo3Dのツールを知ろう!(Vol.1)
【早稲田AI研究会 講義資料】3DスキャンとTextTo3Dのツールを知ろう!(Vol.1)【早稲田AI研究会 講義資料】3DスキャンとTextTo3Dのツールを知ろう!(Vol.1)
【早稲田AI研究会 講義資料】3DスキャンとTextTo3Dのツールを知ろう!(Vol.1)
 
[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略
[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略
[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略
 
TSAL operation mechanism and circuit diagram.pdf
TSAL operation mechanism and circuit diagram.pdfTSAL operation mechanism and circuit diagram.pdf
TSAL operation mechanism and circuit diagram.pdf
 
SOPを理解する 2024/04/19 の勉強会で発表されたものです
SOPを理解する       2024/04/19 の勉強会で発表されたものですSOPを理解する       2024/04/19 の勉強会で発表されたものです
SOPを理解する 2024/04/19 の勉強会で発表されたものです
 

Java scriptのテンプレートエンジンについて