-
Notifications
You must be signed in to change notification settings - Fork 4
Merged partials
Tomek Wytrębowicz edited this page Feb 18, 2015
·
1 revision
To increase networking performance it's very useful to merge partials together, so you can import only one file and stamp partials all together.
Consider, two partials: partial1.html
<!-- Partail 1 -->
<script>console.log("prepare something for partial 1")</script>
<!-- Stampable-->
<template>
<script>console.log("partial 1 stamped")</script>
<h1>Hello {{name}}!</h1>
</template>
partial2.html
<!-- Partail 2 -->
<link rel="import" href="user-profile.html">
<!-- Stampable-->
<template>
<user-profile userData="{{profile}}"></user-profile>
</template>
To reduce networking overhead, those are concatenated to partial.html
<!-- Partail 1 -->
<script>console.log("prepare something for partial 1")</script>
<!-- Stampable-->
<template>
<script>console.log("partial 1 stamped")</script>
<h1>Hello {{name}}!</h1>
</template>
<!-- Partail 2 -->
<link rel="import" href="user-profile.html">
<!-- Stampable-->
<template>
<user-profile userData="{{profileDetails}}"></user-profile>
</template>
You can import it easily with:
<template is="imported-template" content="partial.html" id="mergedTempl"></template>
document.getElementById("mergedTempl").model={
name: "Tomek",
profileDetails: {something: "here"}
}