cortex-handlebars-compiler
Advanced tools
Comparing version 1.0.3 to 1.0.4
33
index.js
@@ -15,3 +15,3 @@ 'use strict'; | ||
// @param {Object} options basic information of the template, not userdata. | ||
// @param {Object} options basic information of the template, not userdata. | ||
// Including: | ||
@@ -43,2 +43,5 @@ // - information of the template | ||
this.href_root = options.href_root; | ||
this.hosts = options.hosts; | ||
this.mod_root = options.mod_root; | ||
this.html_root = options.html_root; | ||
@@ -97,3 +100,3 @@ if (this.href_root) { | ||
// `handlebars` is a singleton, | ||
// we need to override helpers whenever we execute `handlebars.compile` | ||
// we need to override helpers whenever we execute `handlebars.compile` | ||
Object.keys(this.helpers).forEach(function (helper) { | ||
@@ -145,3 +148,18 @@ var handler = this.helpers[helper]; | ||
Compiler.prototype._resolve_path = function(path){ | ||
var root = this.mod_root + this.html_root; | ||
var hosts = this.hosts; | ||
var absolute_path = node_path.join(root, path); | ||
if(root && hosts){ | ||
path = "//" + hosts[ absolute_path.length % hosts.length ] + absolute_path; | ||
}else{ | ||
path = path; | ||
} | ||
return this._to_url_path(path); | ||
} | ||
Compiler.prototype._static_handler = function(title, options) { | ||
@@ -154,3 +172,6 @@ var ext = node_path.extname(title); | ||
var changed_ext = this.ext[ext_name] || ext; | ||
return dir + '/' + base + changed_ext; | ||
var absolute = this._resolve_path(dir + '/' + base + changed_ext); | ||
return absolute; | ||
}; | ||
@@ -284,3 +305,3 @@ | ||
Compiler.prototype._to_url_path = function(path){ | ||
return path.replace(/\\/g,'\/') | ||
return path.replace(/\\/g,'\/'); | ||
} | ||
@@ -293,3 +314,3 @@ | ||
'graph:' + JSON.stringify(this.graph) + ',', | ||
'path:"' + this._to_url_path(this.relative_cwd) + '"' + ',', | ||
'path:"' + this._resolve_path(this.relative_cwd) + '"' + ',', | ||
'});', | ||
@@ -303,3 +324,3 @@ '</script>' | ||
var path = node_path.join(this.relative_cwd, name, version, name + this.ext.js) | ||
return this._to_url_path(path); | ||
return this._resolve_path(path); | ||
}; |
{ | ||
"name": "cortex-handlebars-compiler", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "Handlebar helpers for cortex template.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
17349
384
0