Skip to content

Commit

Permalink
provide filename to intermediate_and_imports call (fixes #45) (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher Baker authored Oct 30, 2017
1 parent 47eb32f commit ff61d5e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
},
"devDependencies": {
"bit-docs": "0.0.7",
"can-test-helpers": "^1.1.0",
"can-view-nodelist": "^3.1.0",
"jshint": "^2.9.4",
"steal": "^1.5.11",
Expand Down
12 changes: 6 additions & 6 deletions steal-stache.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@ function getFilename(name) {

function translate(load) {

var intermediateAndImports = getIntermediateAndImports(load.source);
var filename;
//!steal-remove-start
filename = getFilename(load.name);
//!steal-remove-end

var intermediateAndImports = getIntermediateAndImports(filename, load.source);

var commonDependencies = Promise.all([
this.normalize("can-view-import", module.id),
Expand All @@ -56,11 +61,6 @@ function translate(load) {
intermediateAndImports.imports.unshift("can-stache");
intermediateAndImports.imports.unshift("module");

var filename;
//!steal-remove-start
filename = getFilename(load.name);
//!steal-remove-end

return template(intermediateAndImports.imports, intermediateAndImports.intermediate, filename);
});
}
Expand Down
12 changes: 7 additions & 5 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ var nodeLists = require("can-view-nodelist");
var stache = require("can-stache");
var QUnit = require("steal-qunit");
var loader = require("@loader");
var testHelpers = require("can-test-helpers");
var clone = require("steal-clone")

QUnit.module("steal-stache");
Expand Down Expand Up @@ -31,16 +32,17 @@ QUnit.test("can-import works", function(){
});
});

QUnit.test("can-import works and calls stache() with the filename", function(){
QUnit.test("can-import is provided the filename", function(){
stop();
clone({
"can-stache": {
default: function fakeStache(filename, template) {
equal(filename, "test/tests/foo.stache", "calls with filename");
"can-view-parser": {
default: function fakeStache(template, helpers) {
equal(helpers.filename, "test/tests/foo.stache", "calls with filename");
},
},
})["import"]("test/tests/foo.stache")
.then(function() {
.then(function(template) {
template();
start();
});
});

0 comments on commit ff61d5e

Please sign in to comment.