doT.py - a python template engine.
Upcoming SlideShare
Loading in...5
×
 

doT.py - a python template engine.

on

  • 2,079 views

doT.py is a python implementation of a famous micro javascript template engine doT.js. It is tiny, fast and support all features for doT.js via precompile template on python based server side.

doT.py is a python implementation of a famous micro javascript template engine doT.js. It is tiny, fast and support all features for doT.js via precompile template on python based server side.

Statistics

Views

Total Views
2,079
Slideshare-icon Views on SlideShare
1,619
Embed Views
460

Actions

Likes
2
Downloads
4
Comments
0

3 Embeds 460

http://blog.tagtoo.com.tw 447
http://7411285501621282805_ebcce54410f21b23aaa33df6b7f6fb5fe52e8333.blogspot.com 11
http://131.253.14.98 2

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    doT.py - a python template engine. doT.py - a python template engine. Presentation Transcript

    • DOT.PYa python implementation of famous javascript template engineMonday, 27 May, 13
    • TemplateName: <h1>{{name}}</h1>Msg: <h2>{{msg}}</h2>Representation/TemplateResultTemplate EngineContent / DataMonday, 27 May, 13
    • TemplateName: <h1>{{name}}</h1>Msg: <h2>{{msg}}</h2>Representation/Templatename: Davidmsg: I love python!ResultTemplate EngineContent / DataMonday, 27 May, 13
    • TemplateName: <h1>{{name}}</h1>Msg: <h2>{{msg}}</h2>Representation/Templatename: Davidmsg: I love python!Name: <h1>David</h1>Msg: <h2>I love python!</h2>ResultTemplate EngineContent / DataMonday, 27 May, 13
    • TemplateName: <h1>{{name}}</h1>Msg: <h2>{{msg}}</h2>Representation/Templatename: Davidmsg: I love python!Name: <h1>David</h1>Msg: <h2>I love python!</h2>ResultTemplate Enginename: Marymsg: I hate php!Content / DataMonday, 27 May, 13
    • TemplateName: <h1>{{name}}</h1>Msg: <h2>{{msg}}</h2>Representation/Templatename: Davidmsg: I love python!Name: <h1>David</h1>Msg: <h2>I love python!</h2>ResultTemplate Enginename: Marymsg: I hate php!Name: <h1>Mary</h1>Msg: <h2>I hate php!</h2>Content / DataMonday, 27 May, 13
    • Templatefunction anonymous(it) { varout=Name:<h1>+(it.name)+</h1>Msg:<h2>+(it.msg)+</h2>;return out; }Name: <h1>{{name}}</h1>Msg: <h2>{{msg}}</h2>Representation/Templatename: Davidmsg: I love python!Name: <h1>David</h1>Msg: <h2>I love python!</h2>ResultTemplate Enginename: Marymsg: I hate php!Name: <h1>Mary</h1>Msg: <h2>I hate php!</h2>Content / DataMonday, 27 May, 13
    • Templatefunction anonymous(it) { varout=Name:<h1>+(it.name)+</h1>Msg:<h2>+(it.msg)+</h2>;return out; }Name: <h1>{{name}}</h1>Msg: <h2>{{msg}}</h2>Representation/Templatename: Davidmsg: I love python!Name: <h1>David</h1>Msg: <h2>I love python!</h2>ResultTemplate Enginename: Marymsg: I hate php!Name: <h1>Mary</h1>Msg: <h2>I hate php!</h2>Content / Data{{? it.name }}<div>Oh, I love your name, {{=it.name}}!</div>{{?? it.age === 0}}<div>Guess nobody named you yet!</div>{{??}}You are {{=it.age}} and still dont have a name?{{?}}Monday, 27 May, 13
    • TemplateName: <h1>{{name}}</h1>Msg: <h2>{{msg}}</h2>Representation/Templatename: Davidmsg: I love python!Name: <h1>David</h1>Msg: <h2>I love python!</h2>ResultTemplate Enginename: Marymsg: I hate php!Name: <h1>Mary</h1>Msg: <h2>I hate php!</h2>Content / Data{{? it.name }}<div>Oh, I love your name, {{=it.name}}!</div>{{?? it.age === 0}}<div>Guess nobody named you yet!</div>{{??}}You are {{=it.age}} and still dont have a name?{{?}}Monday, 27 May, 13
    • A lot of template Engine existshttp://garann.github.io/template-chooser/Monday, 27 May, 13
    • RequirementFor Internet Ads, we askBe the fastest template engineBe the smallest template engineDon’t need complex functionSupport both logic and logiclessMonday, 27 May, 13
    • doT.pydoT.js is the fastest javascript template enginedoT.py is its python implementationv.s. mustache1. Performance: > 200x2. Size: < 1/103. Support both logic and logicless usagehttps://github.com/lucemia/doTMonday, 27 May, 13
    • UsagePre-Compiled to javascript (Convert)<script type=”text/javascript”>var pagefn = {{ js_template("templates/ad/layout/layout_h_org.html") }};var result = pagefn(data);</script>DoT.pyMonday, 27 May, 13
    • UsagePre-Compiled to javascript (Convert)Name: <h1>{{name}}</h1>Msg: <h2>{{msg}}</h2><script type=”text/javascript”>var pagefn = {{ js_template("templates/ad/layout/layout_h_org.html") }};var result = pagefn(data);</script>DoT.pyMonday, 27 May, 13
    • UsagePre-Compiled to javascript (Convert)Name: <h1>{{name}}</h1>Msg: <h2>{{msg}}</h2><script type=”text/javascript”>var pagefn = {{ js_template("templates/ad/layout/layout_h_org.html") }};var result = pagefn(data);</script>DoT.pyMonday, 27 May, 13
    • Usagefunction anonymous(it) { varout=Name:<h1>+(it.name)+</h1>Msg:<h2>+(it.msg)+</h2>;return out; }Pre-Compiled to javascript (Convert)Name: <h1>{{name}}</h1>Msg: <h2>{{msg}}</h2><script type=”text/javascript”>var pagefn = {{ js_template("templates/ad/layout/layout_h_org.html") }};var result = pagefn(data);</script>DoT.pyMonday, 27 May, 13
    • Usagefunction anonymous(it) { varout=Name:<h1>+(it.name)+</h1>Msg:<h2>+(it.msg)+</h2>;return out; }Pre-Compiled to javascript (Convert)Name: <h1>{{name}}</h1>Msg: <h2>{{msg}}</h2><script type=”text/javascript”>var pagefn = {{ js_template("templates/ad/layout/layout_h_org.html") }};var result = pagefn(data);</script>DoT.pyMonday, 27 May, 13
    • Usagefunction anonymous(it) { varout=Name:<h1>+(it.name)+</h1>Msg:<h2>+(it.msg)+</h2>;return out; }Pre-Compiled to javascript (Convert)Name: <h1>{{name}}</h1>Msg: <h2>{{msg}}</h2><script type=”text/javascript”>var pagefn = {{ js_template("templates/ad/layout/layout_h_org.html") }};var result = pagefn(data);</script>No Template Engine in RuntimeDoT.pyMonday, 27 May, 13
    • Server Side Template EngineServerClient(browser)1. No dependency on client side2. Fast initial load3. Control over user experienceTemplateDataTemplate EngineResultResultRequestResponseMonday, 27 May, 13
    • Client Side Template Engine1. Save bandwidth (Json vs. Html)2. Reduce server load3. Single endpoint (flexible)ServerClient(browser)Template DataTemplate EngineResult DataMonday, 27 May, 13
    • doT.pyServerClient(browser)Datapreomplied templateResult DataA python implementation of doT.js, compile template to purejavascript function1. No template and template engine in runtime2. Template engine only execute once while deployTemplatepreomplied templatedoT.pyMonday, 27 May, 13
    • “to be super fast, super light-weight client side template”pre-compiledsuper fast (only execute one pure javascript function)super lightweight (no dependency, no template engine)super useful (logic or logicless, as you wish!)Monday, 27 May, 13
    • What’s next?Client side template is HOT, butTweet decided move back to server side because performanceissue. more important, usability.“To improve the twitter.com experience for everyone, wevebeen working to take back control of our front-endperformance by moving the rendering to the server. This hasallowed us to drop our initial page load times to 1/5th of whatthey were previously and reduce differences in performanceacross browsers.”http://openmymind.net/2012/5/30/Client-Side-vs-Server-Side-Rendering/http://engineering.twitter.com/2012/05/improving-performance-on-twittercom.htmlMonday, 27 May, 13