SlideShare a Scribd company logo
1 of 71
Download to read offline
Whats next in templating
Filip Bech-Larsen
@IMPACTdigitaldk
@filipbech
#weAreHiring #Aarhus #Cph
https://developers.google.com/experts/people/filip-bruun-bech-larsen
https://www.facebook.com/groups/ngAarhus/
Whats next in templating
Filip Bech-Larsen
@IMPACTdigitaldk
templating…
• Building user interface using a declarative format (kinda looks like html)
• Some parts are static - some are dynamic
UI = f(state)
React really taught this to the world…
a trip down memory lane…
whats next?
lets take a step back…
the job of a templating system
• balance between
• developer experience
• fast boot
• fast update
What does the platform provide?
• template element
• (tagged) template literals
The template element
• holds “inert” DOM
• scripts don’t run
• styles don’t apply
• easily cloned
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/template
Template literals
• instead of quotes uses backticks - `
• can span multiple lines
• can embed expressions
• can be tagged…
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals
tagged template literals
• a tag is a function that processes the template literal - both the literal and the
expressive parts. Can return anything
tagged template literals
• a tag is a function that processes the template literal - both the literal and the
expressive parts. Can return anything.
• the literal parts-array will be the same (===) in consecutive calls
can we use this for creating a cool
templating system?
the job of a templating system
• balance between
• developer experience
• fast boot
• fast update
a solution?
• template in js means tools
• create template to stamp out clone
• identity of staticParts as caching-key
• We know what changed…
introducing lit-html
lit-html
• A tag-function (called html) that returns templating instructions (called
TemplateResult)
• A render method to produce and maintain dom from TemplateResult
• <2kb gzipped and super fast
https://github.com/Polymer/lit-html
what can lit handle
Text content
expressions
expressions
attributes
TemplateResult
for composition
Arrays
Arrays
for composition
DOM nodes
Async via promises
extending lit-html
directives
remember this?
directives
directives
or use await, or simply just setValue(promise)
lit-extended is sugar
• properties instead of attributes by default
• declarative event-listening syntax
• only 540b gzipped extra…
lit-extended
so you say its fast?
Performance
• 2 aproaches to rendering/updating
• Be smart (Polymer) - scales with complexity (no of changes)
• Be fast (React) - scales with number of nodes (but very fast because of
vdom)
Performance
• 2 aproaches to rendering/updating
• Be smart (Polymer) - scales with complexity (no of changes)
• Be fast (React) - scales with number of nodes (but very fast because of
vdom)
• Lit-html tries to sit in the middle (scales with expressions)
that all good…
how do I make a component?
lit only handles templates
bring your own component
encapsulation, data-flow, events
if only the platform had that…
Web-Components
WebComponents
• custom-elements
• shadow-DOM
• template-element
• html-imports
Lit-html and webcomponents
• Lit is build to be a great fit with web-components
• make a render-method that returns a TemplateResult
• use property setters to invalidate
• re-render when invalidated
• dispatch native DOM-events
there are helpers already
Like LitElement (lit-html-element on npm)
• superpowers properties
• change => invalidation
• types (for conversion), attributes reflection, default value
• computed properties
• batching rendering
• lifecycle hooks
• easy id element-queries
LitElement
https://github.com/kenchris/lit-element
with decorators…
one more thing…
element-router
• native web-component router (no dependencies)
• syntax/api almost like Preact-router
• <1 kb
https://github.com/filipbech/element-router
templating with lit
is pretty sweet
thats it… questions?

More Related Content

What's hot

What's hot (20)

Metaprogramming Go
Metaprogramming GoMetaprogramming Go
Metaprogramming Go
 
Migrate PHP E-Commerce Site to Go
Migrate PHP E-Commerce Site to GoMigrate PHP E-Commerce Site to Go
Migrate PHP E-Commerce Site to Go
 
Making CLI app in ruby
Making CLI app in rubyMaking CLI app in ruby
Making CLI app in ruby
 
Merged Automation Talk - Pete Carapetyan - Feb 2016
Merged Automation Talk - Pete Carapetyan - Feb 2016 Merged Automation Talk - Pete Carapetyan - Feb 2016
Merged Automation Talk - Pete Carapetyan - Feb 2016
 
RubyConf Taiwan 2016 - Large scale Rails applications
RubyConf Taiwan 2016 - Large scale Rails applicationsRubyConf Taiwan 2016 - Large scale Rails applications
RubyConf Taiwan 2016 - Large scale Rails applications
 
MWLUG - Universal Java
MWLUG  -  Universal JavaMWLUG  -  Universal Java
MWLUG - Universal Java
 
Kotlin REST & GraphQL API
Kotlin REST & GraphQL APIKotlin REST & GraphQL API
Kotlin REST & GraphQL API
 
Front-end tower of Babylon
Front-end tower of BabylonFront-end tower of Babylon
Front-end tower of Babylon
 
Why Kotlin?
Why Kotlin?Why Kotlin?
Why Kotlin?
 
RubyConf China 2015 - Rails off assets pipeline
RubyConf China 2015 - Rails off assets pipelineRubyConf China 2015 - Rails off assets pipeline
RubyConf China 2015 - Rails off assets pipeline
 
Web development post io2016
Web development post io2016Web development post io2016
Web development post io2016
 
Functional Programming in PHP
Functional Programming in PHPFunctional Programming in PHP
Functional Programming in PHP
 
Performance and Abstractions
Performance and AbstractionsPerformance and Abstractions
Performance and Abstractions
 
Introduction to Ruby on Rails
Introduction to Ruby on RailsIntroduction to Ruby on Rails
Introduction to Ruby on Rails
 
Ruby an overall approach
Ruby an overall approachRuby an overall approach
Ruby an overall approach
 
Craft Beer & Clojure
Craft Beer & ClojureCraft Beer & Clojure
Craft Beer & Clojure
 
Mixing Plone and Django for explosive results
Mixing Plone and Django for explosive resultsMixing Plone and Django for explosive results
Mixing Plone and Django for explosive results
 
Polyglot
PolyglotPolyglot
Polyglot
 
Stockholm JAM September 2018
Stockholm JAM September 2018Stockholm JAM September 2018
Stockholm JAM September 2018
 
Top 10 php frameworks in 2021
Top 10 php frameworks in 2021Top 10 php frameworks in 2021
Top 10 php frameworks in 2021
 

Similar to Whats next in templating

Similar to Whats next in templating (20)

Building a dynamic SPA website with Angular
Building a dynamic SPA website with AngularBuilding a dynamic SPA website with Angular
Building a dynamic SPA website with Angular
 
Angular ❤️ CMS from #AngularUp
Angular ❤️ CMS from #AngularUpAngular ❤️ CMS from #AngularUp
Angular ❤️ CMS from #AngularUp
 
Dynamic content with Angular
Dynamic content with AngularDynamic content with Angular
Dynamic content with Angular
 
Code for Startup MVP (Ruby on Rails) Session 1
Code for Startup MVP (Ruby on Rails) Session 1Code for Startup MVP (Ruby on Rails) Session 1
Code for Startup MVP (Ruby on Rails) Session 1
 
Angular ❤️CMS
Angular ❤️CMSAngular ❤️CMS
Angular ❤️CMS
 
They why behind php frameworks
They why behind php frameworksThey why behind php frameworks
They why behind php frameworks
 
Killing the Angle Bracket
Killing the Angle BracketKilling the Angle Bracket
Killing the Angle Bracket
 
Dev Ops for systems of record - Talk at Agile Australia 2015
Dev Ops for systems of record - Talk at Agile Australia 2015Dev Ops for systems of record - Talk at Agile Australia 2015
Dev Ops for systems of record - Talk at Agile Australia 2015
 
Webcomponents are your frameworks best friend
Webcomponents are your frameworks best friendWebcomponents are your frameworks best friend
Webcomponents are your frameworks best friend
 
O365 Developer Bootcamp NJ 2018 - Material
O365 Developer Bootcamp NJ 2018 - MaterialO365 Developer Bootcamp NJ 2018 - Material
O365 Developer Bootcamp NJ 2018 - Material
 
PostgREST Design Philosophy
PostgREST Design PhilosophyPostgREST Design Philosophy
PostgREST Design Philosophy
 
Stackato v5
Stackato v5Stackato v5
Stackato v5
 
HTML literals, the JSX of the platform
HTML literals, the JSX of the platformHTML literals, the JSX of the platform
HTML literals, the JSX of the platform
 
Building an MLOps Stack for Companies at Reasonable Scale
Building an MLOps Stack for Companies at Reasonable ScaleBuilding an MLOps Stack for Companies at Reasonable Scale
Building an MLOps Stack for Companies at Reasonable Scale
 
Learn from my Mistakes - Building Better Solutions in SPFx
Learn from my  Mistakes - Building Better Solutions in SPFxLearn from my  Mistakes - Building Better Solutions in SPFx
Learn from my Mistakes - Building Better Solutions in SPFx
 
DIWD 2011
DIWD 2011DIWD 2011
DIWD 2011
 
Stackato v3
Stackato v3Stackato v3
Stackato v3
 
gRPC, GraphQL, REST - Which API Tech to use - API Conference Berlin oct 20
gRPC, GraphQL, REST - Which API Tech to use - API Conference Berlin oct 20gRPC, GraphQL, REST - Which API Tech to use - API Conference Berlin oct 20
gRPC, GraphQL, REST - Which API Tech to use - API Conference Berlin oct 20
 
Cloud Orchestration is Broken
Cloud Orchestration is BrokenCloud Orchestration is Broken
Cloud Orchestration is Broken
 
Rails Vs CakePHP
Rails Vs CakePHPRails Vs CakePHP
Rails Vs CakePHP
 

More from Filip Bruun Bech-Larsen

More from Filip Bruun Bech-Larsen (18)

Webcomponents from 0-100 - with Google's Lit
Webcomponents from 0-100 - with Google's LitWebcomponents from 0-100 - with Google's Lit
Webcomponents from 0-100 - with Google's Lit
 
Content as a Service with Umbraco Headless
Content as a Service with Umbraco HeadlessContent as a Service with Umbraco Headless
Content as a Service with Umbraco Headless
 
Frameworks and webcomponents
Frameworks and webcomponentsFrameworks and webcomponents
Frameworks and webcomponents
 
Future of the Web
Future of the WebFuture of the Web
Future of the Web
 
Diversity at impact
Diversity at impactDiversity at impact
Diversity at impact
 
The Future of the web
The Future of the webThe Future of the web
The Future of the web
 
Frontend development of the (current) future
Frontend development of the (current) futureFrontend development of the (current) future
Frontend development of the (current) future
 
Commerce and the browser in 2017
Commerce and the browser in 2017Commerce and the browser in 2017
Commerce and the browser in 2017
 
Frontend State of the union
Frontend State of the unionFrontend State of the union
Frontend State of the union
 
AngularJS best practices
AngularJS best practicesAngularJS best practices
AngularJS best practices
 
Frontend development of the (current) future
Frontend development of the (current) futureFrontend development of the (current) future
Frontend development of the (current) future
 
Observables - the why, what & how
Observables - the why, what & howObservables - the why, what & how
Observables - the why, what & how
 
Angular2 workshop
Angular2 workshopAngular2 workshop
Angular2 workshop
 
Progressive Web Apps og Payment Request
Progressive Web Apps og Payment RequestProgressive Web Apps og Payment Request
Progressive Web Apps og Payment Request
 
Spangulumbraco
SpangulumbracoSpangulumbraco
Spangulumbraco
 
Observables in angular2
Observables in angular2Observables in angular2
Observables in angular2
 
Frontender in-2016
Frontender in-2016Frontender in-2016
Frontender in-2016
 
[DK] SPA med angular
[DK] SPA med angular[DK] SPA med angular
[DK] SPA med angular
 

Recently uploaded

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Recently uploaded (20)

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by Anitaraj
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 

Whats next in templating