Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/can-compile-proxy.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

205 changes: 205 additions & 0 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ module.exports = function(options, callback) {
return callback(new Error('A specific CanJS version number must be passed to compile views.'));
}

visit(options.version, resolveScripts(options.version, options.paths), function(error, win) {
visit(options.version, resolveScripts(options.version, options.paths, options.proxy), function(error, win) {
if (typeof options.log === 'function') {
options.log('Compiling ' + filename);
}
Expand Down
3 changes: 2 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ module.exports = function(files, configuration, callback, log) {
extensions: configuration.extensions,
viewAttributes: configuration.viewAttributes,
version: configuration.version,
paths: configuration.paths
paths: configuration.paths,
proxy: configuration.proxy
}, function(error, compiled, id) {
if (error) {
return callback(error);
Expand Down
33 changes: 27 additions & 6 deletions lib/resolveScripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,41 @@ var getScript = function(canVersion, script, paths) {
}
};

var getPlugins = function(canVersion, paths) {
var getPlugins = function(canVersion, paths, proxy) {
var plugins = [];
for(var plugin in versionMap.plugins) {
if(semver.satisfies(canVersion, versionMap.plugins[plugin])){
plugins.push(getScript(canVersion, plugin, paths));
plugins.push(proxyUrl(getScript(canVersion, plugin, paths), proxy));
}
}
return plugins;
};

module.exports = function(version, paths) {
var proxyUrl = function(url, proxy){
if (!proxy) {
return url;
}
return {
host: proxy.host,
port: proxy.port,
path: url,
headers: {
Host: url
},

// fake function for doc-helpers
match : function(){
return true;
}
};
}

module.exports = function(version, paths, proxy) {
var scripts = [];
scripts.push(getjQuery(version, paths));
scripts.push(getScript(version, 'can', paths));
scripts = scripts.concat(getPlugins(version, paths));

scripts.push(proxyUrl(getjQuery(version, paths),proxy));
scripts.push(proxyUrl(getScript(version, 'can', paths),proxy));
scripts = scripts.concat(getPlugins(version, paths, proxy));

return scripts;
};
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ The options object allows the following configuration options:
- `extensions` {Object}: An object to map custom file extensions to the standard extension (e.g. `{ 'mst' : 'mustache' }`)
- `viewAttributes` {Array}: A list of attribute names (RegExp or String), used for additional behavior for an attribute in a view (can.view.attr)
- `paths` an object with `ejs`, `mustache` or `stache` and a `jquery` property pointing to files of existing versions or CanJS and jQuery instead of the CDN links.
- `proxy` an object with `host` {String} and `port` {Number} properties

```javascript
compiler.compile({
Expand Down