Skip to content

Commit

Permalink
Use global installations of dependencies
Browse files Browse the repository at this point in the history
Projects where handlebars, underscore and json2 are dependencies of
modules others than require-handlebars may prefer using their existing
libraries installation and require.js paths setup.

The current patch uses common global module IDs for these dependencies,
instead of relying on the shipped ones.
  • Loading branch information
aitorciki committed Feb 11, 2014
1 parent e6ebb61 commit f1f83b9
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions hbs.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
define: false, process: false, window: false */
define([
//>>excludeStart('excludeHbs', pragmas.excludeHbs)
'hbs/handlebars', 'hbs/underscore', 'hbs/i18nprecompile', 'hbs/json2'
'handlebars', 'underscore', 'hbs/i18nprecompile', 'json2'
//>>excludeEnd('excludeHbs')
], function (
//>>excludeStart('excludeHbs', pragmas.excludeHbs)
Expand Down Expand Up @@ -89,7 +89,7 @@ define([
};

fetchText = function (url, callback) {
var xdm = false;
var xdm = false;
// If url is a fully qualified URL, it might be a cross domain request. Check for that.
// IF url is a relative url, it cannot be cross domain.
if (url.indexOf('http') != 0 ){
Expand All @@ -101,7 +101,7 @@ define([
var msie = getIEVersion();
xdm = ( dom != window.location.href.substr(hidx).split('/').shift() ) && (msie >= 7);
}

if ( xdm ) {
var xdr = getXhr(true);
xdr.open('GET', url);
Expand Down Expand Up @@ -418,7 +418,7 @@ define([
var path;
if(partialReference.match(/^(\.|\/)+/)) {
// relative path
path = cleanPath(baseDir + partialReference)
path = cleanPath(baseDir + partialReference)
}
else {
// absolute path relative to config.hbs.partialsUrl if defined
Expand Down Expand Up @@ -524,12 +524,12 @@ define([

if(depStr) depStr = ", '"+depStr+"'";

var partialReferences = [];
var partialReferences = [];
if(require.config.hbs._partials[name])
partialReferences = require.config.hbs._partials[name].references;
partialReferences = require.config.hbs._partials[name].references;

text = '/* START_TEMPLATE */\n' +
'define('+tmplName+"['hbs','hbs/handlebars'"+depStr+helpDepStr+'], function( hbs, Handlebars ){ \n' +
'define('+tmplName+"['hbs','handlebars'"+depStr+helpDepStr+'], function( hbs, Handlebars ){ \n' +
'var t = Handlebars.template(' + prec + ');\n';

for(var i=0; i<partialReferences.length;i++)
Expand Down

0 comments on commit f1f83b9

Please sign in to comment.