SlideShare une entreprise Scribd logo
1  sur  23
Télécharger pour lire hors ligne
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

Contenu connexe

Similaire à 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 AngularJSPablo 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 lesszrok
 
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 linkedinRuhaim 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 Startedguest1af57e
 
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 FilesDavid 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 reactChris 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 introductionMichael Ahearn
 
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 DeadlinesTikal Knowledge
 
Font End Development + Automation with Django
Font End Development + Automation with DjangoFont End Development + Automation with Django
Font End Development + Automation with DjangoEvan Reiser
 
Php mysql-training online-by_php2ranjan
Php mysql-training online-by_php2ranjanPhp mysql-training online-by_php2ranjan
Php mysql-training online-by_php2ranjanphp2ranjan
 
php training in hyderabad
php training in hyderabadphp training in hyderabad
php training in hyderabadphp2ranjan
 
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
 
Building Smart Workflows - Dan Diebolt
Building Smart Workflows - Dan DieboltBuilding Smart Workflows - Dan Diebolt
Building Smart Workflows - Dan DieboltQuickBase, 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 NazimMir Nazim
 

Similaire à 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
 

Plus de 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 TaiwanDavid 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 cooperationDavid 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 TuningDavid Chen
 
Final presentation for mobile strategy
Final presentation for mobile strategyFinal presentation for mobile strategy
Final presentation for mobile strategyDavid Chen
 
Gam Documentation
Gam DocumentationGam Documentation
Gam DocumentationDavid Chen
 
Gam Documentation
Gam DocumentationGam Documentation
Gam DocumentationDavid Chen
 

Plus de 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
 

Dernier

04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 

Dernier (20)

04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 

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