About using Polymer (http://polymer-project.org/) to achieve better structure of the frontend code than with other tools.
Part of the Dublin GDG Dev Fest.
13. I don't always
structure my frontend code,
but when I do,
I use web components.
@polymer #itshackademic
https://imgflip.com/memegenerator/
The-Most-Interesting-Man-In-The-World
16. <paper-tabs selected=“1”>
<paper-tab>Tab 1</paper-tab>
<paper-tab>Tab 2</paper-tab>
<paper-tab>Tab 3</paper-tab>
</paper-tabs>
@polymer #itshackademic
Custom Elements
define new HTML
declarative, readable
meaningful HTML
extensible → reusable
17. @polymer #itshackademic
Custom Elements
define new HTML
declarative, readable
meaningful HTML
extensible → reusable
var tabs = document.querySelector('paper-tabs');
tabs.addEventListener('core-activate', function() {
console.log(this.selected);
});
19. @polymer #itshackademic
<template>
<div class=“comment”>
<img src=“image.png”>
</div>
<script>…</script>
</template>
HTML Templates
native client-side templates
use DOM to scaffold DOM → no XSS
parsed, not rendered
content is inert until cloned/used
doc fragment → not part of the page
50. <paper-input floatinglabel
label="Type only numbers... (floating)"
validate="^[0-9]*$"
error="Input is not a number!">
</paper-input>
@polymer #itshackademic