0

I used brunch-with-marionette skeleton available at: https://github.com/SimbCo/brunch-with-marionette Everything works fine for me but I don't know the necessary configuration in this skeleton to add requirejs-text plugin. I tried:

npm install requirejs-text

and it installed the plugin in node-modules folder but then when I tried to load a template like this:

items = require 'text!views/sub-menu/templates/panel'

the browser gives error about being unable to load file 'text!views/....'. It considers the whole thing a file name. Removing the "text!" part works but then it doesn't return the html text rather, it gives a function which is not what I need.

I even checked the installed plugin with "npm ls" command from the app folder but when it lists the node-modules, it says the following for requirejs-text:

npm ERR! extraneous: requirejs-text@2.0.12

I am working on this stuff for the first time. Kindly help me with the configuration to add requirejs-text plugin. Many thanks!

EDITED:

I am using coffeescript. Adding some code from search-menu-view.coffee file for reference:

SubMenuView = require 'views/sub-menu/sub-menu-view'
favorites = require 'models/favorites'
navTemplate = require 'text!views/sub-menu/templates/menu-panel'

module.exports = class SearchMenuView extends SubMenuView
    template: 'views/sub-menu/templates/menu-search'
    events:
        'click .menu-search-btn-group': 'onSearchInputClick'

The first two files load fine. The third one which has text! in it, doesn't.

user1344502
  • 75
  • 1
  • 1
  • 8
  • @Louis Actually I didn't have to configure RequireJS. I downloaded the skeleton code from [link](https://github.com/SimbCo/brunch-with-marionette) and it had everything configured and worked for me. I don't know the configurations yet but the skeleton code contain files like: bower.json ; config.coffee ; package.json and they all have some kind of configurations. I have edited the question to include the context of require call you asked. – user1344502 Jun 10 '15 at 17:36
  • It looks like your `require 'text!...` call is processed as a CommonJS call and that it is not processed by RequireJS. (RequireJS does accept a CommonJS form of the `require` call but it does not produce the error you got.) That's about as much as I can tell because from what I can see Brunch is what should take care of your `require` calls but I've never used it. – Louis Jun 10 '15 at 17:44

0 Answers0