scrat-swig
Advanced tools
Comparing version 0.1.2 to 0.1.3
@@ -5,2 +5,3 @@ 'use strict' | ||
var fs = require('fs') | ||
var DEFAULT_COMBO_PATTERN = '/co??%s' | ||
@@ -77,3 +78,3 @@ /** | ||
this.combo = options.combo | ||
this.comboPattern = options.comboPattern || '/co??' | ||
this.comboPattern = options.comboPattern | ||
} | ||
@@ -186,3 +187,3 @@ | ||
Resource.prototype.makeComboURI = function(collect){ | ||
var url = this.comboPattern || '/co??' | ||
var url = this.getComboPattern() | ||
var self = this, combo = '' | ||
@@ -192,5 +193,9 @@ collect.forEach(function(uri){ | ||
}) | ||
return url + combo.substring(1) | ||
return url.replace('%s', combo.substring(1)) | ||
} | ||
Resource.prototype.getComboPattern = function(){ | ||
return this.comboPattern || DEFAULT_COMBO_PATTERN | ||
} | ||
/** | ||
@@ -216,5 +221,4 @@ * | ||
} | ||
if(used.length){ | ||
html += '<script>pagelet.used(["' + used.join('","') + '"])</script>\n'; | ||
} | ||
var code = 'pagelet.init(' + (this.combo ? 1 : 0) + ',"' + this.getComboPattern() + '",["' + used.join('","') + '"]);'; | ||
html += '<script>' + code + '</script>\n'; | ||
if(this._script.length){ | ||
@@ -255,6 +259,19 @@ if(this.combo){ | ||
if(this._usePagelet){ | ||
var js = this._collect.js || [] | ||
var css = this._collect.css || [] | ||
var self = this | ||
if(this.combo && js.length){ | ||
js.forEach(function(uri, index){ | ||
js[index] = self.comboURI(uri) | ||
}) | ||
} | ||
if(this.combo && css.length){ | ||
css.forEach(function(uri, index){ | ||
css[index] = self.comboURI(uri) | ||
}) | ||
} | ||
out = JSON.stringify({ | ||
html : this._pagelets, | ||
js : this._collect.js || [], | ||
css : this._collect.css || [], | ||
js : js, | ||
css : css, | ||
title : this._title, | ||
@@ -261,0 +278,0 @@ script: this._script |
{ | ||
"name": "scrat-swig", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "Extensions of swig for scrat", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
15108
551