SlideShare a Scribd company logo
DOT.PY
a python implementation of famous javascript template engine
Monday, 27 May, 13
Template
Name: <h1>{{name}}</h1>
Msg: <h2>{{msg}}</h2>
Representation/Template
ResultTemplate Engine
Content / Data
Monday, 27 May, 13
Template
Name: <h1>{{name}}</h1>
Msg: <h2>{{msg}}</h2>
Representation/Template
name: David
msg: I love python!
ResultTemplate Engine
Content / Data
Monday, 27 May, 13
Template
Name: <h1>{{name}}</h1>
Msg: <h2>{{msg}}</h2>
Representation/Template
name: David
msg: I love python!
Name: <h1>David</h1>
Msg: <h2>I love python!</h2>
ResultTemplate Engine
Content / Data
Monday, 27 May, 13
Template
Name: <h1>{{name}}</h1>
Msg: <h2>{{msg}}</h2>
Representation/Template
name: David
msg: I love python!
Name: <h1>David</h1>
Msg: <h2>I love python!</h2>
ResultTemplate Engine
name: Mary
msg: I hate php!
Content / Data
Monday, 27 May, 13
Template
Name: <h1>{{name}}</h1>
Msg: <h2>{{msg}}</h2>
Representation/Template
name: David
msg: I love python!
Name: <h1>David</h1>
Msg: <h2>I love python!</h2>
ResultTemplate Engine
name: Mary
msg: I hate php!
Name: <h1>Mary</h1>
Msg: <h2>I hate php!</h2>
Content / Data
Monday, 27 May, 13
Template
function anonymous(it) { var
out='Name:<h1>'+(it.name)+'</
h1>Msg:<h2>'+(it.msg)+'</h2>';return out; }
Name: <h1>{{name}}</h1>
Msg: <h2>{{msg}}</h2>
Representation/Template
name: David
msg: I love python!
Name: <h1>David</h1>
Msg: <h2>I love python!</h2>
ResultTemplate Engine
name: Mary
msg: I hate php!
Name: <h1>Mary</h1>
Msg: <h2>I hate php!</h2>
Content / Data
Monday, 27 May, 13
Template
function anonymous(it) { var
out='Name:<h1>'+(it.name)+'</
h1>Msg:<h2>'+(it.msg)+'</h2>';return out; }
Name: <h1>{{name}}</h1>
Msg: <h2>{{msg}}</h2>
Representation/Template
name: David
msg: I love python!
Name: <h1>David</h1>
Msg: <h2>I love python!</h2>
ResultTemplate Engine
name: Mary
msg: 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 don't have a name?
{{?}}
Monday, 27 May, 13
Template
Name: <h1>{{name}}</h1>
Msg: <h2>{{msg}}</h2>
Representation/Template
name: David
msg: I love python!
Name: <h1>David</h1>
Msg: <h2>I love python!</h2>
ResultTemplate Engine
name: Mary
msg: 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 don't have a name?
{{?}}
Monday, 27 May, 13
A lot of template Engine exists
http://garann.github.io/template-chooser/
Monday, 27 May, 13
Requirement
For Internet Ads, we ask
Be the fastest template engine
Be the smallest template engine
Don’t need complex function
Support both logic and logicless
Monday, 27 May, 13
doT.py
doT.js is the fastest javascript template engine
doT.py is its python implementation
v.s. mustache
1. Performance: > 200x
2. Size: < 1/10
3. Support both logic and logicless usage
https://github.com/lucemia/doT
Monday, 27 May, 13
Usage
Pre-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.py
Monday, 27 May, 13
Usage
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.py
Monday, 27 May, 13
Usage
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.py
Monday, 27 May, 13
Usage
function anonymous(it) { var
out='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.py
Monday, 27 May, 13
Usage
function anonymous(it) { var
out='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.py
Monday, 27 May, 13
Usage
function anonymous(it) { var
out='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 Runtime
DoT.py
Monday, 27 May, 13
Server Side Template Engine
Server
Client
(browser)
1. No dependency on client side
2. Fast initial load
3. Control over user experience
Template
Data
Template Engine
Result
Result
Request
Response
Monday, 27 May, 13
Client Side Template Engine
1. Save bandwidth (Json vs. Html)
2. Reduce server load
3. Single endpoint (flexible)
Server
Client
(browser)
Template Data
Template Engine
Result Data
Monday, 27 May, 13
doT.py
Server
Client
(browser)
Data
preomplied template
Result Data
A python implementation of doT.js, compile template to pure
javascript function
1. No template and template engine in runtime
2. Template engine only execute once while deploy
Template
preomplied template
doT.py
Monday, 27 May, 13
“to be super fast, super light-
weight client side template”
pre-compiled
super 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, but
Tweet decided move back to server side because performance
issue. more important, usability.
“To improve the twitter.com experience for everyone, we've
been working to take back control of our front-end
performance by moving the rendering to the server. This has
allowed us to drop our initial page load times to 1/5th of what
they were previously and reduce differences in performance
across browsers.”
http://openmymind.net/2012/5/30/Client-Side-vs-Server-Side-Rendering/
http://engineering.twitter.com/2012/05/improving-performance-on-twittercom.html
Monday, 27 May, 13

More Related Content

Similar to doT.py - a python template engine.

Tek 2013 - Building Web Apps from a New Angle with AngularJS
Tek 2013 - Building Web Apps from a New Angle with AngularJSTek 2013 - Building Web Apps from a New Angle with AngularJS
Tek 2013 - Building Web Apps from a New Angle with AngularJS
Pablo Godel
 
Get up and running with google app engine in 60 minutes or less
Get up and running with google app engine in 60 minutes or lessGet up and running with google app engine in 60 minutes or less
Get up and running with google app engine in 60 minutes or less
zrok
 
Data presentation with dust js technologies backing linkedin
Data presentation with dust js   technologies backing linkedinData presentation with dust js   technologies backing linkedin
Data presentation with dust js technologies backing linkedin
Ruhaim Izmeth
 
The Big Picture and How to Get Started
The Big Picture and How to Get StartedThe Big Picture and How to Get Started
The Big Picture and How to Get Started
guest1af57e
 
A (very) opinionated guide to MSBuild and Project Files
A (very) opinionated guide to MSBuild and Project FilesA (very) opinionated guide to MSBuild and Project Files
A (very) opinionated guide to MSBuild and Project Files
David Wengier
 
Web components: A simpler and faster react
Web components:  A simpler and faster reactWeb components:  A simpler and faster react
Web components: A simpler and faster react
Chris Lorenzo
 
State of modern web technologies: an introduction
State of modern web technologies: an introductionState of modern web technologies: an introduction
State of modern web technologies: an introduction
Michael Ahearn
 
WordCamp Denmark Keynote
WordCamp Denmark KeynoteWordCamp Denmark Keynote
WordCamp Denmark Keynote
Frederick Townes
 
Seo
SeoSeo
JBUG 11 - Django-The Web Framework For Perfectionists With Deadlines
JBUG 11 - Django-The Web Framework For Perfectionists With DeadlinesJBUG 11 - Django-The Web Framework For Perfectionists With Deadlines
JBUG 11 - Django-The Web Framework For Perfectionists With Deadlines
Tikal Knowledge
 
High-Speed HTML5
High-Speed HTML5High-Speed HTML5
High-Speed HTML5
Peter Lubbers
 
Font End Development + Automation with Django
Font End Development + Automation with DjangoFont End Development + Automation with Django
Font End Development + Automation with Django
Evan Reiser
 
Php mysql-training online-by_php2ranjan
Php mysql-training online-by_php2ranjanPhp mysql-training online-by_php2ranjan
Php mysql-training online-by_php2ranjan
php2ranjan
 
php training in hyderabad
php training in hyderabadphp training in hyderabad
php training in hyderabad
php2ranjan
 
Web Components: Web back to future.
Web Components: Web back to future.Web Components: Web back to future.
Web Components: Web back to future.
GlobalLogic Ukraine
 
Web matrix part 2
Web matrix part 2Web matrix part 2
Web matrix part 2yuvaraj72
 
Google Gears
Google GearsGoogle Gears
Google Gears
silenceIT Inc.
 
Building Smart Workflows - Dan Diebolt
Building Smart Workflows - Dan DieboltBuilding Smart Workflows - Dan Diebolt
Building Smart Workflows - Dan Diebolt
QuickBase, Inc.
 
Django Introduction Osscamp Delhi September 08 09 2007 Mir Nazim
Django Introduction Osscamp Delhi September 08 09 2007 Mir NazimDjango Introduction Osscamp Delhi September 08 09 2007 Mir Nazim
Django Introduction Osscamp Delhi September 08 09 2007 Mir Nazim
Mir Nazim
 

Similar to doT.py - a python template engine. (20)

Tek 2013 - Building Web Apps from a New Angle with AngularJS
Tek 2013 - Building Web Apps from a New Angle with AngularJSTek 2013 - Building Web Apps from a New Angle with AngularJS
Tek 2013 - Building Web Apps from a New Angle with AngularJS
 
Get up and running with google app engine in 60 minutes or less
Get up and running with google app engine in 60 minutes or lessGet up and running with google app engine in 60 minutes or less
Get up and running with google app engine in 60 minutes or less
 
Data presentation with dust js technologies backing linkedin
Data presentation with dust js   technologies backing linkedinData presentation with dust js   technologies backing linkedin
Data presentation with dust js technologies backing linkedin
 
The Big Picture and How to Get Started
The Big Picture and How to Get StartedThe Big Picture and How to Get Started
The Big Picture and How to Get Started
 
A (very) opinionated guide to MSBuild and Project Files
A (very) opinionated guide to MSBuild and Project FilesA (very) opinionated guide to MSBuild and Project Files
A (very) opinionated guide to MSBuild and Project Files
 
Web components: A simpler and faster react
Web components:  A simpler and faster reactWeb components:  A simpler and faster react
Web components: A simpler and faster react
 
State of modern web technologies: an introduction
State of modern web technologies: an introductionState of modern web technologies: an introduction
State of modern web technologies: an introduction
 
WordCamp Denmark Keynote
WordCamp Denmark KeynoteWordCamp Denmark Keynote
WordCamp Denmark Keynote
 
Seo
SeoSeo
Seo
 
JBUG 11 - Django-The Web Framework For Perfectionists With Deadlines
JBUG 11 - Django-The Web Framework For Perfectionists With DeadlinesJBUG 11 - Django-The Web Framework For Perfectionists With Deadlines
JBUG 11 - Django-The Web Framework For Perfectionists With Deadlines
 
High-Speed HTML5
High-Speed HTML5High-Speed HTML5
High-Speed HTML5
 
Font End Development + Automation with Django
Font End Development + Automation with DjangoFont End Development + Automation with Django
Font End Development + Automation with Django
 
Php mysql-training online-by_php2ranjan
Php mysql-training online-by_php2ranjanPhp mysql-training online-by_php2ranjan
Php mysql-training online-by_php2ranjan
 
php training in hyderabad
php training in hyderabadphp training in hyderabad
php training in hyderabad
 
The Devil and HTML5
The Devil and HTML5The Devil and HTML5
The Devil and HTML5
 
Web Components: Web back to future.
Web Components: Web back to future.Web Components: Web back to future.
Web Components: Web back to future.
 
Web matrix part 2
Web matrix part 2Web matrix part 2
Web matrix part 2
 
Google Gears
Google GearsGoogle Gears
Google Gears
 
Building Smart Workflows - Dan Diebolt
Building Smart Workflows - Dan DieboltBuilding Smart Workflows - Dan Diebolt
Building Smart Workflows - Dan Diebolt
 
Django Introduction Osscamp Delhi September 08 09 2007 Mir Nazim
Django Introduction Osscamp Delhi September 08 09 2007 Mir NazimDjango Introduction Osscamp Delhi September 08 09 2007 Mir Nazim
Django Introduction Osscamp Delhi September 08 09 2007 Mir Nazim
 

More from David Chen

Build Smart Service on GCP - Google DevFest 2018 Taiwan
Build Smart Service on GCP - Google DevFest 2018 TaiwanBuild Smart Service on GCP - Google DevFest 2018 Taiwan
Build Smart Service on GCP - Google DevFest 2018 Taiwan
David Chen
 
python small tools for CI and team cooperation
python small tools for CI and team cooperationpython small tools for CI and team cooperation
python small tools for CI and team cooperation
David Chen
 
Tops for Lean Startup
Tops for Lean StartupTops for Lean Startup
Tops for Lean StartupDavid Chen
 
Talk in Google fest 2013
Talk in Google fest 2013Talk in Google fest 2013
Talk in Google fest 2013David Chen
 
AppEngine Performance Tuning
AppEngine Performance TuningAppEngine Performance Tuning
AppEngine Performance Tuning
David Chen
 
Final presentation for mobile strategy
Final presentation for mobile strategyFinal presentation for mobile strategy
Final presentation for mobile strategyDavid Chen
 
GAM Slide
GAM SlideGAM Slide
GAM Slide
David Chen
 
Gam Documentation
Gam DocumentationGam Documentation
Gam Documentation
David Chen
 
Gam Documentation
Gam DocumentationGam Documentation
Gam DocumentationDavid Chen
 

More from David Chen (11)

Build Smart Service on GCP - Google DevFest 2018 Taiwan
Build Smart Service on GCP - Google DevFest 2018 TaiwanBuild Smart Service on GCP - Google DevFest 2018 Taiwan
Build Smart Service on GCP - Google DevFest 2018 Taiwan
 
python small tools for CI and team cooperation
python small tools for CI and team cooperationpython small tools for CI and team cooperation
python small tools for CI and team cooperation
 
Big datalab
Big datalabBig datalab
Big datalab
 
Tops for Lean Startup
Tops for Lean StartupTops for Lean Startup
Tops for Lean Startup
 
Talk in Google fest 2013
Talk in Google fest 2013Talk in Google fest 2013
Talk in Google fest 2013
 
AppEngine Performance Tuning
AppEngine Performance TuningAppEngine Performance Tuning
AppEngine Performance Tuning
 
Final presentation for mobile strategy
Final presentation for mobile strategyFinal presentation for mobile strategy
Final presentation for mobile strategy
 
長庚大學
長庚大學長庚大學
長庚大學
 
GAM Slide
GAM SlideGAM Slide
GAM Slide
 
Gam Documentation
Gam DocumentationGam Documentation
Gam Documentation
 
Gam Documentation
Gam DocumentationGam Documentation
Gam Documentation
 

Recently uploaded

Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
g2nightmarescribd
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 

Recently uploaded (20)

Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 

doT.py - a python template engine.

  • 1. DOT.PY a python implementation of famous javascript template engine Monday, 27 May, 13
  • 3. Template Name: <h1>{{name}}</h1> Msg: <h2>{{msg}}</h2> Representation/Template name: David msg: I love python! ResultTemplate Engine Content / Data Monday, 27 May, 13
  • 4. Template Name: <h1>{{name}}</h1> Msg: <h2>{{msg}}</h2> Representation/Template name: David msg: I love python! Name: <h1>David</h1> Msg: <h2>I love python!</h2> ResultTemplate Engine Content / Data Monday, 27 May, 13
  • 5. Template Name: <h1>{{name}}</h1> Msg: <h2>{{msg}}</h2> Representation/Template name: David msg: I love python! Name: <h1>David</h1> Msg: <h2>I love python!</h2> ResultTemplate Engine name: Mary msg: I hate php! Content / Data Monday, 27 May, 13
  • 6. Template Name: <h1>{{name}}</h1> Msg: <h2>{{msg}}</h2> Representation/Template name: David msg: I love python! Name: <h1>David</h1> Msg: <h2>I love python!</h2> ResultTemplate Engine name: Mary msg: I hate php! Name: <h1>Mary</h1> Msg: <h2>I hate php!</h2> Content / Data Monday, 27 May, 13
  • 7. Template function anonymous(it) { var out='Name:<h1>'+(it.name)+'</ h1>Msg:<h2>'+(it.msg)+'</h2>';return out; } Name: <h1>{{name}}</h1> Msg: <h2>{{msg}}</h2> Representation/Template name: David msg: I love python! Name: <h1>David</h1> Msg: <h2>I love python!</h2> ResultTemplate Engine name: Mary msg: I hate php! Name: <h1>Mary</h1> Msg: <h2>I hate php!</h2> Content / Data Monday, 27 May, 13
  • 8. Template function anonymous(it) { var out='Name:<h1>'+(it.name)+'</ h1>Msg:<h2>'+(it.msg)+'</h2>';return out; } Name: <h1>{{name}}</h1> Msg: <h2>{{msg}}</h2> Representation/Template name: David msg: I love python! Name: <h1>David</h1> Msg: <h2>I love python!</h2> ResultTemplate Engine name: Mary msg: 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 don't have a name? {{?}} Monday, 27 May, 13
  • 9. Template Name: <h1>{{name}}</h1> Msg: <h2>{{msg}}</h2> Representation/Template name: David msg: I love python! Name: <h1>David</h1> Msg: <h2>I love python!</h2> ResultTemplate Engine name: Mary msg: 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 don't have a name? {{?}} Monday, 27 May, 13
  • 10. A lot of template Engine exists http://garann.github.io/template-chooser/ Monday, 27 May, 13
  • 11. Requirement For Internet Ads, we ask Be the fastest template engine Be the smallest template engine Don’t need complex function Support both logic and logicless Monday, 27 May, 13
  • 12. doT.py doT.js is the fastest javascript template engine doT.py is its python implementation v.s. mustache 1. Performance: > 200x 2. Size: < 1/10 3. Support both logic and logicless usage https://github.com/lucemia/doT Monday, 27 May, 13
  • 13. Usage Pre-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.py Monday, 27 May, 13
  • 14. Usage 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.py Monday, 27 May, 13
  • 15. Usage 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.py Monday, 27 May, 13
  • 16. Usage function anonymous(it) { var out='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.py Monday, 27 May, 13
  • 17. Usage function anonymous(it) { var out='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.py Monday, 27 May, 13
  • 18. Usage function anonymous(it) { var out='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 Runtime DoT.py Monday, 27 May, 13
  • 19. Server Side Template Engine Server Client (browser) 1. No dependency on client side 2. Fast initial load 3. Control over user experience Template Data Template Engine Result Result Request Response Monday, 27 May, 13
  • 20. Client Side Template Engine 1. Save bandwidth (Json vs. Html) 2. Reduce server load 3. Single endpoint (flexible) Server Client (browser) Template Data Template Engine Result Data Monday, 27 May, 13
  • 21. doT.py Server Client (browser) Data preomplied template Result Data A python implementation of doT.js, compile template to pure javascript function 1. No template and template engine in runtime 2. Template engine only execute once while deploy Template preomplied template doT.py Monday, 27 May, 13
  • 22. “to be super fast, super light- weight client side template” pre-compiled super 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
  • 23. What’s next? Client side template is HOT, but Tweet decided move back to server side because performance issue. more important, usability. “To improve the twitter.com experience for everyone, we've been working to take back control of our front-end performance by moving the rendering to the server. This has allowed us to drop our initial page load times to 1/5th of what they were previously and reduce differences in performance across browsers.” http://openmymind.net/2012/5/30/Client-Side-vs-Server-Side-Rendering/ http://engineering.twitter.com/2012/05/improving-performance-on-twittercom.html Monday, 27 May, 13