I've recently started using the <template>
tag for HTML that I process afterwards using a template library, e.g.
<template id="tmpl">
<div class="something">
<a href="/pages/{{link}}">{{title}}</a>
</div>
</template>
...
<script>
var output = Mustache.render($('#tmpl').html(), {
link: 'abc',
title: 'abc'
});
</script>
However, I've come to realise this means I have a broken link (example.com/pages/{{link}}) in my HTML. This is a concern, as various crawlers might consider it invalid (in fact, the Google Search Console reports my homepage as having a broken link).
Is it valid to use
<template>
this way?Is it better to put it in something like
<script type="text/template">
instead (as seen on the handlebars.js website)?