Skip to content

Using curl.js with underscore

unscriptable edited this page Feb 6, 2012 · 10 revisions

Using curl.js with underscore

The creators of underscore are still deciding whether to incorporate full AMD support or not. In the meantime, you can use an AMD-aware version at the amdjs maintained fork.

You must map the path to underscore.js when configuring curl.js.

underscore registers itself as an absolutely named module. curl.js (as well other AMD loaders) ensures that the correct module got loaded by comparing the id of the requested module with the module that was actually loaded. Since underscore registers itself with the name, "underscore", all modules that list underscore as a dependency must also refer to it by the exact same name. Trying to refer to underscore as any of the following module ids will fail:

  • "js/documentcloud/underscore/underscore" (BAD: path is included)
  • "Underscore" (BAD: capitalization is different)
  • "underscore.1.3.1.min" (BAD: extra filename bits)

The best way to ensure all code can correctly refer to it as "underscore", you should add the following path mapping to curl.js's config:

paths: {
	"underscore": "js/documentcloud/underscore/underscore.1.3.1.min"
}

For more information about paths, see Understanding Paths.

For more hints about using underscore, check out the Using curl.js with jQuery page. Much of the information on that page applies to underscore, as well.

## ### 1.

Clone this wiki locally