Skip to content

Commit

Permalink
Second round of updates to remove mustache/ejs
Browse files Browse the repository at this point in the history
  • Loading branch information
DesignByOnyx committed Feb 1, 2016
1 parent 4266d67 commit b397db0
Show file tree
Hide file tree
Showing 21 changed files with 45 additions and 476 deletions.
7 changes: 6 additions & 1 deletion component/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ steal("can/util", "can/view/callbacks","can/view/elements.js","can/view/bindings
return can.view.frag(temp.apply(null, arguments));
};
} else {
this.renderer = can.view.mustache(this.prototype.template);
this.renderer = can.view.stache(this.prototype.template);
}
}

Expand Down Expand Up @@ -437,6 +437,11 @@ steal("can/util", "can/view/callbacks","can/view/elements.js","can/view/bindings
}
});

// This was moved from the legacy view/scanner.js to here in prep for 3.0.0
can.view.tag("content", function (el, tagData) {
return tagData.scope;
});

/**
* @description Read and write a component element's viewModel.
*
Expand Down
16 changes: 2 additions & 14 deletions component/component_bindings_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ steal("can", "can/map/define", "can/component", "can/view/stache" ,"can/route",
panel.attr("active", true);

},
// this is viewModel, not mustache
// this is viewModel, not stache
// consider removing viewModel as arg
isActive: function (panel) {
return this.attr('active') === panel;
Expand Down Expand Up @@ -1241,7 +1241,7 @@ steal("can", "can/map/define", "can/component", "can/view/stache" ,"can/route",


test("stache conditionally nested components calls inserted once (#967)", function(){
expect(2);
expect(1);

can.Component.extend({
tag: "can-parent-stache",
Expand All @@ -1250,13 +1250,6 @@ steal("can", "can/map/define", "can/component", "can/view/stache" ,"can/route",
},
template: can.stache("{{#if shown}}<can-child></can-child>{{/if}}")
});
can.Component.extend({
tag: "can-parent-mustache",
viewModel: {
shown: true
},
template: can.stache("{{#if shown}}<can-child></can-child>{{/if}}")
});
can.Component.extend({
tag: "can-child",
events: {
Expand All @@ -1270,11 +1263,6 @@ steal("can", "can/map/define", "can/component", "can/view/stache" ,"can/route",
var template = can.stache("<can-parent-stache></can-parent-stache>");

can.append(this.$fixture, template());

var template2 = can.stache("<can-parent-mustache></can-parent-mustache>");

can.append(this.$fixture, template2());

});

test("hyphen-less tag names", function () {
Expand Down
36 changes: 5 additions & 31 deletions component/component_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ steal("can/util/vdom/document", "can/util/vdom/build_fragment","can", "can/map/d
panel.attr("active", true);

},
// this is viewModel, not mustache
// this is viewModel, not stache
// consider removing viewModel as arg
isActive: function (panel) {
return this.attr('active') === panel;
Expand Down Expand Up @@ -1256,7 +1256,7 @@ steal("can/util/vdom/document", "can/util/vdom/build_fragment","can", "can/map/d
//!steal-remove-end

test("stache conditionally nested components calls inserted once (#967)", function(){
expect(2);
expect(1);

can.Component.extend({
tag: "can-parent-stache",
Expand All @@ -1265,13 +1265,6 @@ steal("can/util/vdom/document", "can/util/vdom/build_fragment","can", "can/map/d
},
template: can.stache("{{#if shown}}<can-child></can-child>{{/if}}")
});
can.Component.extend({
tag: "can-parent-mustache",
viewModel: {
shown: true
},
template: can.stache("{{#if shown}}<can-child></can-child>{{/if}}")
});
can.Component.extend({
tag: "can-child",
events: {
Expand All @@ -1286,10 +1279,6 @@ steal("can/util/vdom/document", "can/util/vdom/build_fragment","can", "can/map/d

can.append(this.$fixture, template());

var template2 = can.stache("<can-parent-mustache></can-parent-mustache>");

can.append(this.$fixture, template2());

});

test("hyphen-less tag names", function () {
Expand Down Expand Up @@ -1585,18 +1574,17 @@ steal("can/util/vdom/document", "can/util/vdom/build_fragment","can", "can/map/d



QUnit.module("can/component mustache");
QUnit.module("can/component stache");


asyncTest('(mu)stache integration', function(){
asyncTest('stache integration', function(){

can.Component.extend({
tag: 'my-tagged',
template: '{{p1}},{{p2.val}},{{p3}},{{p4}}'
});

var stache = can.stache("<my-tagged p1='v1' p2='{v2}' p3='{{v3}}'></my-tagged>");
var mustache = can.mustache("<my-tagged p1='v1' p2='{v2}' p3='{{v3}}'></my-tagged>");

var data = new can.Map({
v1: "value1",
Expand All @@ -1609,39 +1597,25 @@ steal("can/util/vdom/document", "can/util/vdom/build_fragment","can", "can/map/d
var stacheFrag = stache(data),
stacheResult = stacheFrag.childNodes[0].innerHTML.split(",");

var mustacheFrag = mustache(data),
mustacheResult = mustacheFrag.childNodes[0].innerHTML.split(",");

equal(stacheResult[0], "v1", "stache uses attribute values");
equal(stacheResult[1], "value2", "stache single {} cross binds value");
equal(stacheResult[2], "value3", "stache {{}} cross binds attribute");

equal(mustacheResult[0], "value1", "mustache looks up attribute values");
equal(mustacheResult[1], "value2", "mustache single {} cross binds value");
equal(mustacheResult[2], "value 3", "mustache {{}} cross binds string value");

data.attr("v1","VALUE1");
data.attr("v2",new can.Map({val: "VALUE 2"}));
data.attr("v3","VALUE3");
can.attr.set( stacheFrag.childNodes[0],"p4","value4");

stacheResult = stacheFrag.childNodes[0].innerHTML.split(",");
mustacheResult = mustacheFrag.childNodes[0].innerHTML.split(",");

equal(stacheResult[0], "v1", "stache uses attribute values so it should not change");
equal(mustacheResult[0], "VALUE1", "mustache looks up attribute values and updates immediately");
equal(stacheResult[1], "VALUE 2", "stache single {} cross binds value and updates immediately");
equal(mustacheResult[1], "VALUE 2", "mustache single {} cross binds value and updates immediately");

equal(stacheResult[2], "value3", "stache {{}} cross binds attribute changes so it wont be updated immediately");

setTimeout(function(){

stacheResult = stacheFrag.childNodes[0].innerHTML.split(",");
mustacheResult = mustacheFrag.childNodes[0].innerHTML.split(",");
equal(stacheResult[2], "VALUE3", "stache {{}} cross binds attribute");

equal(mustacheResult[2], "VALUE 3", "mustache sticks with old value even though property has changed");

equal(stacheResult[3], "value4", "stache sees new attributes");

Expand Down Expand Up @@ -1827,7 +1801,7 @@ steal("can/util/vdom/document", "can/util/vdom/build_fragment","can", "can/map/d
can.remove(can.$("#qunit-fixture>*"));
});

// PUT NEW TESTS THAT NEED TO TEST AGAINST MUSTACHE JUST ABOVE THIS LINE
// PUT NEW TESTS THAT NEED TO TEST AGAINST STACHE JUST ABOVE THIS LINE
}

test('component simpleHelpers', function() {
Expand Down
6 changes: 3 additions & 3 deletions list/doc/reverse.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
<button id="reverse">Reverse!</button>
</script>

<script src="../node_modules/steal/steal.js" main="@empty"></script>
<script src="../../node_modules/steal/steal.js" main="@empty"></script>
<script type="text/javascript">
steal('can/list', 'can/view/mustache', function() {
steal('can/list', 'can/view/stache', function() {

var people = new can.List(['Alexis', 'Justin', 'David']);

Expand Down Expand Up @@ -52,4 +52,4 @@
});
</script>
</body>
</html>
</html>
2 changes: 1 addition & 1 deletion list/sort/sort.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
'<tr>' +
'{{#each rows.0}}' +
'<th>' +
'<button comparator-index="{{@index}}" can-click="changeComparator">' +
'<button comparator-index="{{%index}}" can-click="changeComparator">' +
'&#9660;' +
'</button>' +
'</th>' +
Expand Down
8 changes: 4 additions & 4 deletions list/sort/sort_test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
steal("can/list/sort", "can/test", "can/view/mustache", "can/view/stache", "can/model", "steal-qunit", function () {
steal("can/list/sort", "can/test", "can/view/stache", "can/view/stache", "can/model", "steal-qunit", function () {
QUnit.module('can/list/sort');

test('List events', (4*3), function () {
Expand Down Expand Up @@ -656,12 +656,12 @@ steal("can/list/sort", "can/test", "can/view/mustache", "can/view/stache", "can/
]);
});

test('{{@index}} is updated for "move" events (#1962)', function () {
test('{{%index}} is updated for "move" events (#1962)', function () {
var list = new can.List([100, 200, 300]);
list.attr('comparator', function (a, b) { return a < b ? -1 : 1; });

var template = can.stache('<ul>{{#each list}}<li>' +
'<span class="index">{{@index}}</span> - ' +
'<span class="index">{{%index}}</span> - ' +
'<span class="value">{{.}}</span>' +
'</li>{{/each}}</ul>');

Expand All @@ -676,7 +676,7 @@ steal("can/list/sort", "can/test", "can/view/mustache", "can/view/stache", "can/
var index = li.querySelectorAll('.index')[0].innerHTML;
var value = li.querySelectorAll('.value')[0].innerHTML;

equal(index, ''+i, '{{@index}} rendered correct value');
equal(index, ''+i, '{{%index}} rendered correct value');
equal(value, ''+expected[i], '{{.}} rendered correct value');
}
};
Expand Down
9 changes: 4 additions & 5 deletions map/validations/doc/validations.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ <h1>Observe Validations Demo</h1>
<script type='text/javascript'
src='../../../node_modules/steal/steal.js' main="@empty">
</script>
<script type='text/ejs' id='personEJS'>
<h3>Person <%= person.attr('name') %> is <%= person.ageThisYear() %> years old.</h3>
<script type='text/stache' id='personStache'>
<h3>Person {{person.name}} is {{person.ageThisYear}} years old.</h3>
</script>
<script type='text/javascript' id="demo-source">
steal('can/map/validations',
'can/map/attributes',
'can/control',
'can/view/ejs',function(){
'can/view/stache',function(){

// Create a Person Observe Constructor
// that converts dates
Expand Down Expand Up @@ -109,8 +109,7 @@ <h3>Person <%= person.attr('name') %> is <%= person.ageThisYear() %> years old.<

new Updater("#updater",{person: justin})

// use EJS to bind to the name
$("#person").html(can.view("personEJS", {person: justin}))
$("#person").html(can.view("personStache", {person: justin}))

})
</script>
Expand Down
4 changes: 2 additions & 2 deletions route/demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ <h2>Events</h2>
<script type='text/javascript'>
steal('can/route',
'can/map',
'can/view/ejs',
'can/view/stache',
'can/view/modifiers',
'can/route',
'can/util/demos/observer.js',
Expand Down Expand Up @@ -249,4 +249,4 @@ <h2>Events</h2>
})
</script>
</body>
</html>
</html>
2 changes: 1 addition & 1 deletion route/docs/map.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ <h2>Products</h2>
{{/appState.products}}
</script>
<script>
steal("can/route", "can/map/define", "can/view/mustache", "can/view/bindings", "can/model", "can/util/fixture",function(){
steal("can/route", "can/map/define", "can/view/stache", "can/view/bindings", "can/model", "can/util/fixture",function(){

can.fixture("GET /locations", function(){
return [
Expand Down
4 changes: 2 additions & 2 deletions route/pushstate/demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ <h2>Events</h2>
<script type='text/javascript'>
steal('can/route/pushstate',
'can/map',
'can/view/ejs',
'can/view/stache',
'can/view/modifiers',
'can/route',
'can/util/demos/observer.js',
Expand Down Expand Up @@ -247,7 +247,7 @@ <h2>Events</h2>
})
</script>
<script type='text/ejs' id='linksEJS'>
<pre>can.route.link("recipe 5",{type: "recipe", id: 5}) = </code><%= can.route.link("click me",{type: "recipe", id: 5}) %>
<pre>can.route.link("recipe 5",{type: "recipe", id: 5}) = </pre><%= can.route.link("click me",{type: "recipe", id: 5}) %>
</script>
</body>
</html>
2 changes: 0 additions & 2 deletions test/all-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@ steal("can/test/test.js",
"can/observe/observe_test.js",
"can/compute/compute_test.js",
"can/model/model_test.js", "can/view/view_test.js",
"can/view/ejs/ejs_test.js",
"can/view/stache/stache_test.js",
"can/control/control_test.js",
"can/route/route_test.js",
"can/control/route/route_test.js",
"can/view/mustache/mustache_test.js",
"can/route/pushstate/pushstate_test.js",
"can/model/queue/queue_test.js",
"can/construct/super/super_test.js",
Expand Down
6 changes: 1 addition & 5 deletions test/builders/steal-tools/bundle/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,13 @@
map: {
"jquery/jquery": "jquery",
"can/util/util": "can/util/jquery/jquery",
"stache": "can/view/stache/system",
"ejs": "can/view/ejs/system",
"mustache" : "can/view/mustache/system"
"stache": "can/view/stache/system"
},
paths: {
"jquery": "../../../../node_modules/jquery/dist/jquery.js",
"can/*": "../../../../*.js"
},
ext: {
ejs: "can/view/ejs/system",
mustache: "can/view/mustache/system",
stache: "can/view/stache/system"
},
bundle: [ "components/one/one" ]
Expand Down
6 changes: 1 addition & 5 deletions test/builders/steal-tools/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,13 @@
map: {
"jquery/jquery": "jquery",
"can/util/util": "can/util/jquery/jquery",
"stache": "can/view/stache/system",
"ejs": "can/view/ejs/system",
"mustache" : "can/view/mustache/system"
"stache": "can/view/stache/system"
},
paths: {
"jquery": "../../../node_modules/jquery/dist/jquery.js",
"can/*": "../../../*.js"
},
ext: {
ejs: "view/ejs/ejs.js",
mustache: "view/mustache/mustache.js",
stache: "view/stache/stache.js"
}
});
Expand Down
14 changes: 2 additions & 12 deletions test/demos_and_tests.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,6 @@ <h3>pushstate</h3>
<h2>view</h2>
<iframe src="../view/test.html"></iframe>


<h2>Mustache</h2>
<iframe src="../view/mustache/test.html"></iframe>
<iframe src="../view/mustache/mustache.html"></iframe>

<h2>EJS</h2>
<iframe src="../view/ejs/test.html"></iframe>
<iframe src="../view/ejs/ejs.html"></iframe>
<iframe src="../view/ejs/demo.html"></iframe>


<!-- TODO: Stache -->
</body>
</html>
</html>
Loading

0 comments on commit b397db0

Please sign in to comment.