I have been trying to implement external templates, but to no avail. This is the full error:
Uncaught TypeError: Invalid template! Template should be a "string" but "undefined" was given as the first argument for mustache#render(template, view, partials)
I am using browserify-shim for some other dependencies, but they work perfectly, and I am not getting errors (from that task) from the terminal. It's just the external template loading which is giving me problems.
function templateLoader(e) {
var doc = document,
event = EventUtility.getEvent(e),
target = EventUtility.getTarget(event);
$("body").load("templates/index.html #overlay", function() {
var temp1 = $('#overlay').html();
var output = Mustache.render(temp1);
$("body").html(output);
});
}
var flimFlam = document.getElementById('Container');
EventUtility.addHandler(flimFlam, 'click', templateLoader);
Thanks so much in advance!
Try to put everything in
$(document).ready(function(){
});
I had the same error and it worked for me.
because your Mustache template is probably nested in the rendering template. separate them and this error should go away.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With