Skip to content
This repository has been archived by the owner on Mar 23, 2024. It is now read-only.

Allow defining functions in requirejs.yml #179

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

wuservices
Copy link
Contributor

Some RequireJS config options such as init need a function, however
YAML and JSON can only store data - not JavaScript. As a workaround
this detects a function and unescapes it when the config is added
to the page in the helper.

Fixes #177

Some RequireJS config options such as init need a function, however
YAML and JSON can only store data - not JavaScript. As a workaround
this detects a function and unescapes it when the config is added
to the page in the helper.
@carsomyr
Copy link
Collaborator

@wuservices Could you provide an example?

@carsomyr
Copy link
Collaborator

See #177.

@wuservices
Copy link
Contributor Author

Example:

shim:
  underscore:
    exports: _
    init: |
      function() {
        this._.templateSettings.interpolate = /\{\{(.+?)\}\}/g;
      }
  twitter/bootstrap/button:
    deps: [jquery]
    # Reverts $.fn.button to jQuery UI btn and
    # assigns Bootstrap button functionality to $.fn.btn
    init: |
      function($) {
        var btn = $.fn.button.noConflict();
        $.fn.btn = btn;
      }

@carsomyr carsomyr force-pushed the master branch 5 times, most recently from 9c7a7e6 to dd10bdb Compare September 22, 2014 02:00
@steveklebanoff
Copy link

+1

@garbles
Copy link

garbles commented May 21, 2015

+1
@carsomyr any reason why this can't be merged in? Would be nice to have!

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

Successfully merging this pull request may close these issues.

Add support for defining functions in configuration
4 participants