From 4cc6b61ab7e5fc0149a02234e982dae51f081b1f Mon Sep 17 00:00:00 2001 From: justinbmeyer Date: Tue, 16 Jul 2019 15:03:30 -0500 Subject: [PATCH 1/7] updating for 6.0 --- package.json | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 6605113..5217059 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "steal-stache", - "version": "4.1.5", + "version": "5.0.0-pre.0", "description": "Load can-stache templates with StealJS", "homepage": "http://canjs.com", "repository": { @@ -46,17 +46,15 @@ }, "dependencies": { "can-assign": "^1.0.0", - "can-stache": "^4.0.0", + "can-stache": "canjs/can-stache#major", "can-stache-ast": "^1.0.0", - "can-stache-bindings": "^4.0.0", - "can-view-import": "^4.2.2", + "can-stache-bindings": "canjs/can-stache-bindings#major", + "can-view-import": "canjs/can-view-import#major", "steal-config-utils": "^1.0.0" }, "devDependencies": { - "bit-docs": "0.0.7", "can-test-helpers": "^1.1.0", - "can-view-callbacks": "^4.1.1", - "can-view-nodelist": "^4.0.0", + "can-view-callbacks": "canjs/can-view-callbacks#major", "jshint": "^2.9.4", "steal": "^1.7.0", "steal-qunit": "^2.0.0", From c7a718e67aeaa0ed89e70925a9e7598d04c57452 Mon Sep 17 00:00:00 2001 From: justinbmeyer Date: Tue, 16 Jul 2019 15:42:13 -0500 Subject: [PATCH 2/7] tests pass for 6.0 --- steal-stache.js | 3 ++- test/test.js | 13 ------------- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/steal-stache.js b/steal-stache.js index 06824c0..ea228f8 100644 --- a/steal-stache.js +++ b/steal-stache.js @@ -8,7 +8,8 @@ function template(imports, intermediate, filename){ imports = JSON.stringify(imports); intermediate = JSON.stringify(intermediate); - return "define("+imports+",function(module, assign, stache, mustacheCore){ \n" + + return "define("+imports+",function(module, assign, stache, mustacheCore, viewImport, bindings){ \n" + + "\tstache.addBindings(bindings);\n"+ (filename ? "\tvar renderer = stache(" + JSON.stringify(filename) + ", " + intermediate + ");\n" : "\tvar renderer = stache(" + intermediate + ");\n" diff --git a/test/test.js b/test/test.js index 395b64d..b3ce913 100644 --- a/test/test.js +++ b/test/test.js @@ -1,5 +1,4 @@ var template = require("./template.stache!"); -var nodeLists = require("can-view-nodelist"); var stache = require("can-stache"); var QUnit = require("steal-qunit"); var loader = require("@loader"); @@ -8,18 +7,6 @@ var tag = require("can-view-callbacks").tag; QUnit.module("steal-stache"); -QUnit.test("node-lists work", function(assert) { - var nl = nodeLists.register([], undefined, true); - stache.registerHelper("importTestHelper", function(options) { - assert.equal( - options.nodeList, - nl.replacements[0], - "correct node list reference" - ); - }); - template({}, {}, nl); -}); - QUnit.test("can-import works", function(assert) { var done = assert.async(); From 17469edfd873392caa3939d1b3a79f8f5c45fd64 Mon Sep 17 00:00:00 2001 From: Nils Lundquist Date: Fri, 26 Jul 2019 12:47:02 -0600 Subject: [PATCH 3/7] Syncronous import via tags (#85) pass ``ed modules to stache in scope so they can be available synchronously --- steal-stache.js | 23 +++++++++++++++++------ test/test.js | 21 +++++++++++++++++---- test/tests/baz.stache | 2 ++ 3 files changed, 36 insertions(+), 10 deletions(-) create mode 100644 test/tests/baz.stache diff --git a/steal-stache.js b/steal-stache.js index ea228f8..9ad06eb 100644 --- a/steal-stache.js +++ b/steal-stache.js @@ -5,22 +5,32 @@ var loader = require("@loader"); var addImportSpecifiers = require("steal-config-utils/import-specifiers").addImportSpecifiers; function template(imports, intermediate, filename){ + var tagImportNames = JSON.stringify(imports.slice(7)); imports = JSON.stringify(imports); intermediate = JSON.stringify(intermediate); - return "define("+imports+",function(module, assign, stache, mustacheCore, viewImport, bindings){ \n" + - "\tstache.addBindings(bindings);\n"+ + return "define("+imports+",function(module, assign, stache, mustacheCore, Scope, viewImport, bindings){ \n" + + "\tstache.addBindings(bindings);\n"+ (filename ? "\tvar renderer = stache(" + JSON.stringify(filename) + ", " + intermediate + ");\n" : "\tvar renderer = stache(" + intermediate + ");\n" ) + + "\tvar tagImports = Array.prototype.slice.call(arguments, 7);\n" + "\treturn function(scope, options, nodeList){\n" + "\t\tvar moduleOptions = assign({}, options);\n" + - "\t\tif(moduleOptions.helpers) {\n" + - "\t\t\tmoduleOptions.helpers = assign({ module: module }, moduleOptions.helpers);\n" + - "\t\t} else {\n" + - "\t\t\tmoduleOptions.module = module;\n" + + "\t\tvar tagImportMap = " + tagImportNames + ".reduce(function(map, name, index) {\n" + + "\t\t\tmap[name] = tagImports[index];\n" + + "\t\t\treturn map;\n" + + "\t\t}, {});\n" + + "\n"+ + "\t\tif (!(scope instanceof Scope)) { scope = new Scope(scope); }\n" + + "\t\tvar variableScope = scope.getScope(function(s) { return s._meta.variable === true });\n" + + "\t\tif (!variableScope) {\n" + + "\t\t\tscope = scope.addLetContext();\n" + + "\t\t\tvariableScope = scope;\n" + "\t\t}\n" + + "\t\tassign(variableScope._context, { module: module, tagImportMap: tagImportMap });\n" + + "\n" + "\t\treturn renderer(scope, moduleOptions, nodeList);\n" + "\t};\n" + "});"; @@ -75,6 +85,7 @@ function translate(load) { ast.imports, imports ); + ast.imports.unshift("can-view-scope"); ast.imports.unshift("can-stache/src/mustache_core"); ast.imports.unshift("can-stache"); ast.imports.unshift("can-assign"); diff --git a/test/test.js b/test/test.js index b3ce913..b2615aa 100644 --- a/test/test.js +++ b/test/test.js @@ -1,5 +1,3 @@ -var template = require("./template.stache!"); -var stache = require("can-stache"); var QUnit = require("steal-qunit"); var loader = require("@loader"); var clone = require("steal-clone"); @@ -25,6 +23,21 @@ QUnit.test("can-import works", function(assert) { }); }); +QUnit.test("`can-import`ed modules are available synchronously, and in a LetContext", function(assert){ + var done = assert.async(); + + loader["import"]("test/tests/baz.stache").then(function(template) { + template({ + test: function(value, scope) { + assert.equal(value, "works", "Initial render occurs with can-import already completed."); + assert.ok(scope._meta.variable, "Bottom scope is a LetContext."); + assert.equal(scope._context._data.bar, "works", "`bar` variable is in the LetContext."); + done(); + } + }); + }); +}); + QUnit.test("error messages includes the source", function(assert) { var done = assert.async(); @@ -60,7 +73,7 @@ QUnit.test("module info is set when 'options' is missing", function(assert) { var done = assert.async(2); tag("fake-import", function fakeImport(el, tagData) { - var m = tagData.scope.get("scope.helpers.module"); + var m = tagData.scope.get("module"); assert.ok(m.id.includes("test/module-meta/index")); done(); }); @@ -75,7 +88,7 @@ QUnit.test("module info is set when 'options.helpers' exists", function(assert) var done = assert.async(2); tag("fake-import", function fakeImport(el, tagData) { - var m = tagData.scope.get("scope.helpers.module"); + var m = tagData.scope.get("module"); assert.ok(m.id.includes("test/module-meta/index")); done(); }); diff --git a/test/tests/baz.stache b/test/tests/baz.stache new file mode 100644 index 0000000..9d6dd64 --- /dev/null +++ b/test/tests/baz.stache @@ -0,0 +1,2 @@ + +{{ test(bar, scope) }} \ No newline at end of file From ceef29c59ef93931cfe52edb3250a56a8c604dc4 Mon Sep 17 00:00:00 2001 From: Kevin Phillips Date: Wed, 31 Jul 2019 12:56:01 -0400 Subject: [PATCH 4/7] latest firefox --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 479ab46..1ce4b9b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: node_js node_js: node addons: - firefox: '57.0' + firefox: latest +dist: xenial services: - xvfb -dist: xenial From 13b5ceec926bf155aa424d677e6ed330081ed39b Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Fri, 2 Aug 2019 14:07:51 -0400 Subject: [PATCH 5/7] 5.0.0-pre.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5217059..5da32d2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "steal-stache", - "version": "5.0.0-pre.0", + "version": "5.0.0-pre.1", "description": "Load can-stache templates with StealJS", "homepage": "http://canjs.com", "repository": { From 4baa413a6d3a0e81fdc8a839011365c8686e52f0 Mon Sep 17 00:00:00 2001 From: Kevin Phillips Date: Wed, 7 Aug 2019 12:08:30 -0500 Subject: [PATCH 6/7] updating to use pre-releases --- package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 5da32d2..5029c86 100644 --- a/package.json +++ b/package.json @@ -46,15 +46,15 @@ }, "dependencies": { "can-assign": "^1.0.0", - "can-stache": "canjs/can-stache#major", + "can-stache": "^5.0.0-pre.3", "can-stache-ast": "^1.0.0", - "can-stache-bindings": "canjs/can-stache-bindings#major", - "can-view-import": "canjs/can-view-import#major", + "can-stache-bindings": "^5.0.0-pre.4", + "can-view-import": "^5.0.0-pre.1", "steal-config-utils": "^1.0.0" }, "devDependencies": { "can-test-helpers": "^1.1.0", - "can-view-callbacks": "canjs/can-view-callbacks#major", + "can-view-callbacks": "^5.0.0-pre.1", "jshint": "^2.9.4", "steal": "^1.7.0", "steal-qunit": "^2.0.0", From c0ef192463ddb2cf619f3b7e6b6d4186870abe49 Mon Sep 17 00:00:00 2001 From: Kevin Phillips Date: Wed, 7 Aug 2019 12:08:41 -0500 Subject: [PATCH 7/7] 5.0.0-pre.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5029c86..25855ac 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "steal-stache", - "version": "5.0.0-pre.1", + "version": "5.0.0-pre.2", "description": "Load can-stache templates with StealJS", "homepage": "http://canjs.com", "repository": {