javascript - Using a string as a parameter in requirejs text plugin -
i wanted use string within require , load handlebar template file.
"invalid require call : notloaded",'module name "'+i+'" has not been loaded yet context:"
define(function( require) { var gettemplatefile = function(templatename) { return require(['text!../html/templates/header.tpl']); /* works */ } }); //string concatenated define(function( require) { var gettemplatefile = function(templatename) { return require(['text!../html/templates/'+templatename+'.tpl']); /* not work */ } }); i followed workaround given here ( requirejs text plugin , variable concatenated string ) still got same error. in getting working.
you misusing require function. see here spec. you'll want use require(string) (along array version) or require(array, function) depending on want achieve. answer linked uses array variation.
Comments
Post a Comment