Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Add support for require.js text plugin #919

Closed
mikechambers opened this issue May 22, 2012 · 2 comments
Closed

Add support for require.js text plugin #919

mikechambers opened this issue May 22, 2012 · 2 comments

Comments

@mikechambers
Copy link
Contributor

We should include the require.js text plugin with Brackets. This plugin allows developers to load text files in the same way that they load other JavaScript modules.

http://requirejs.org/docs/download.html#text

Currently, if you want to use this as an extension developer, you have to include the plugin with your extension:

For example:
https://github.com/mikechambers/StringConvert

Notice that text.js is included in the project. You can then use the plugin like so:

var menuTemplate = require("text!menu.template");

Ideally, this will be included in Brackets so every extension developer doesn't have to include it.

I did a quick test and placed text.js in the brackets directory, and then tried to use it like so:

var menuTemplate = brackets.getModule("text!extensions/user/StringConvert/menu.template");

However, this generated the following error:

Uncaught Error: Module name 'text!extensions/user/StringConvert/menu.template' has not been loaded yet for context: _
http://requirejs.org/docs/errors.html#notloaded

Which I believe has something to do with the text plugin / module not being loaded yet. See the comment for the getModule definition in brackets.js

// Also store our current require.js context (the one that loads brackets core modules) so that extensions can use it
// Note: we change the name to "getModule" because this won't do exactly the same thing as 'require' in AMD-wrapped
// modules. The extension will only be able to load modules that have already been loaded once.
brackets.getModule = require;
@gruehle
Copy link
Member

gruehle commented May 22, 2012

In Issue #258, @idflood proposes adding the text plugin for dialog templates. I agree this is a good idea.

We should be able to work around the AMD issue by explicitly loading text content in brackets.js

@pthiess
Copy link
Contributor

pthiess commented May 29, 2012

Moved to the backlog: https://trello.com/c/BKQnEDRa

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants