scrat-swig
Advanced tools
Comparing version 0.1.8 to 0.1.9
@@ -5,3 +5,4 @@ var swig = require('swig') | ||
'pagelet', 'require', | ||
'script', 'uri', 'title' | ||
'script', 'uri', 'title', | ||
'datalet' | ||
].forEach(function(tag){ | ||
@@ -8,0 +9,0 @@ var t = require('./tags/' + tag); |
@@ -36,2 +36,3 @@ 'use strict' | ||
this._pagelets = {} | ||
this._datalets = {} | ||
this._isPageletOpen = false | ||
@@ -120,2 +121,10 @@ this._usePagelet = false | ||
Resource.prototype.normalize = function(id, ext){ | ||
ext = ext || '' | ||
if(id.indexOf('.') === -1){ | ||
id += '/' + id.split('/').pop() + ext | ||
} | ||
return id.replace(/^(?!(views|components)\/)/, PREFIX + '/') | ||
} | ||
/** | ||
@@ -128,8 +137,3 @@ * 收集资源 | ||
if(this._usePagelet && !this._isPageletOpen) return | ||
if(!/^(views|components)\//.test(id)) { | ||
id = PREFIX + '/' + id | ||
} | ||
if(id.indexOf('.') === -1){ | ||
id += '/' + id.split('/').pop() + '.js' | ||
} | ||
id = this.normalize(id, '.js') | ||
if(this._loaded.hasOwnProperty(id)) return | ||
@@ -159,3 +163,3 @@ var res = this.getResById(id) | ||
if(file.indexOf('.') === -1){ | ||
file += file.split('/').pop() + '.tpl' | ||
file = this.normalize(file, '.tpl') | ||
var res = this.getResById(file) | ||
@@ -219,2 +223,7 @@ if(res){ | ||
} | ||
if(this.combo && used.length){ | ||
for(var i = 0, len = used.length; i < len; i++){ | ||
used[i] = this.comboURI(used[i]); | ||
} | ||
} | ||
var code = 'pagelet.init(' + (this.combo ? 1 : 0) + ',"' + this.getComboPattern() + '",["' + used.join('","') + '"]);'; | ||
@@ -272,2 +281,3 @@ html += '<script>' + code + '</script>\n'; | ||
html : this._pagelets, | ||
data : this._datalets, | ||
js : js, | ||
@@ -274,0 +284,0 @@ css : css, |
{ | ||
"name": "scrat-swig", | ||
"version": "0.1.8", | ||
"version": "0.1.9", | ||
"description": "Extensions of swig for scrat", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is not supported yet
77431
26
653