snippets
load templates from a url
-
Templates can be loaded from external files with
b.getTemplates(url). -
HTML content fore template is stored in
<script>tags that havetype="text/html"anddata-template="NAME".This approach is used instead of using
<template>tags because some browsers will attempt to load<img>tags inside of<template>tags even if the template is never used. -
(NOTE: The
/versions/8/0/0/snippets/get-remote-templates/templates/file thatconst urlpoints to is shown under thetemplates.htmlheading below. The name difference is a result of the build process, but it's the same file.)
html
javascript
;
const url = `/versions/8/0/0/snippets/get-remote-templates/templates/`;
templates.html
This is content from the external template.