dojo/text¶
dojo/text is an AMD plugin that loads arbitrary string data from a file and returns it. It is the replacement for
dojo/cache() from earlier versions of Dojo. Essentially the loader will
load a text resource and return it as an argument to the callback function of a define()
or require()
.
Usage¶
Usage require supplying the resource URL to load after the !
. This URL can be expressed in relative terms and
will assume a root of the Dojo base by default:
require(["dojo/text!something.html"], function(something){
// something = contents of something.html
});
In particular, dojo/text
is used to load Dijit templates, for example:
define(["dojo/_base/declare", "dijit/_Widget", "dojo/text!dijit/templates/Dialog.html"],
function(declare, _Widget, template){
return declare(_Widget, {
templateString: template
});
});