From 7c9fbf26c232acd31e8a47c49b309bc5e64c9aca Mon Sep 17 00:00:00 2001 From: Christopher Baker Date: Mon, 12 Feb 2018 17:11:34 -0800 Subject: [PATCH 1/3] Use const/let in sample code --- docs/boolean-to-inList.md | 12 ++++++------ docs/either-or.md | 8 ++++---- docs/equal.md | 20 ++++++++++---------- docs/input-radio.md | 10 +++++----- docs/not.md | 18 +++++++++--------- docs/string-to-any.md | 10 +++++----- 6 files changed, 39 insertions(+), 39 deletions(-) diff --git a/docs/boolean-to-inList.md b/docs/boolean-to-inList.md index bdc49d3..5310f67 100644 --- a/docs/boolean-to-inList.md +++ b/docs/boolean-to-inList.md @@ -22,17 +22,17 @@ When the setter is called, if the new value is truthy then the item will be adde Use this converter when two-way binding to an element with a boolean attribute, such as a checkbox. -```js -var map = new DefineMap({ - item: 5, - list: [1, 2, 3, 4, 5] +```javascript +const map = new DefineMap({ + item: 5, + list: [1, 2, 3, 4, 5] }); -var template = stache(''); +const template = stache(''); document.body.appendChild(template(map)); -var input = document.querySelector('input[type=checkbox]'); +const input = document.querySelector('input[type=checkbox]'); console.log(input.checked); // -> true diff --git a/docs/either-or.md b/docs/either-or.md index ec0afeb..81e666f 100644 --- a/docs/either-or.md +++ b/docs/either-or.md @@ -40,11 +40,11 @@ You pass 3 arguments to this [can-stache.registerConverter converter]. The first

Your fandom: {{pref}}

``` -```js -var template = stache.from("demo-template"); +```javascript +const template = stache.from("demo-template"); -var fan = new DefineMap({ - pref: "Star Trek" +const fan = new DefineMap({ + pref: "Star Trek" }); document.body.appendChild(template(fan)); diff --git a/docs/equal.md b/docs/equal.md index 3e15900..c840cc1 100644 --- a/docs/equal.md +++ b/docs/equal.md @@ -51,19 +51,19 @@ In this example we are using objects, to select a captain from one of three play {{/each}} ``` -```js -var template = stache.from("demo"); -var vm = new DefineMap({ - captain: null, - players: [ - { name: "Matthew" }, - { name: "Wilbur" }, - { name: "Anne" } - ] +```javascript +const template = stache.from("demo"); +const vm = new DefineMap({ + captain: null, + players: [ + { name: "Matthew" }, + { name: "Wilbur" }, + { name: "Anne" } + ] }); vm.captain = vm.players[0]; -var frag = template(vm); +const frag = template(vm); document.body.appendChild(frag); ``` diff --git a/docs/input-radio.md b/docs/input-radio.md index 182d54e..33ad33b 100644 --- a/docs/input-radio.md +++ b/docs/input-radio.md @@ -14,11 +14,11 @@ To bind to a radio input, if you have a set of boolean values you can bind to th Two ``` -```js -var template = stache.from("demo"); -var map = new DefineMap({ - one: true, - two: false +```javascript +const template = stache.from("demo"); +const map = new DefineMap({ + one: true, + two: false }); document.body.appendChild(template(map)); diff --git a/docs/not.md b/docs/not.md index 51ce442..a218b7e 100644 --- a/docs/not.md +++ b/docs/not.md @@ -27,14 +27,14 @@ Use this converter to two-way bind to the negation of some value. For example: ``` -```js -var map = new DefineMap({ - val: true +```javascript +const map = new DefineMap({ + val: true }); document.body.appendChild(template(map)); -var input = document.querySelector('input'); +const input = document.querySelector('input'); input.checked; // -> false @@ -54,14 +54,14 @@ map.val === true; // because the checkbox is now false. ``` -```js -var map = new DefineMap({ - item: 2, - list: new DefineList([ 1, 2, 3 ]) +```javascript +const map = new DefineMap({ + item: 2, + list: new DefineList([ 1, 2, 3 ]) }); document.body.appendChild(template(map)); -var input = document.querySelector('input'); +const input = document.querySelector('input'); input.checked; // -> false diff --git a/docs/string-to-any.md b/docs/string-to-any.md index cefb704..c298c0a 100644 --- a/docs/string-to-any.md +++ b/docs/string-to-any.md @@ -35,12 +35,12 @@ This is usually used with ` ``` -```js -var str = document.getElementById('select-template').innerHTML; -var template = stache(str); +```javascript +const str = document.getElementById('select-template').innerHTML; +const template = stache(str); -var map = new DefineMap({ - someValue: "foo" +const map = new DefineMap({ + someValue: "foo" }); document.body.appendChild(template(map)); From eb755ce1b4ec86d63cae9826506f0d4598396af5 Mon Sep 17 00:00:00 2001 From: Christopher Baker Date: Tue, 13 Feb 2018 15:30:20 -0800 Subject: [PATCH 2/3] run eslint on markdown code --- docs/boolean-to-inList.md | 6 +++--- docs/either-or.md | 4 ++-- docs/equal.md | 14 +++++++------- docs/input-radio.md | 6 +++--- docs/not.md | 10 +++++----- docs/string-to-any.md | 4 ++-- 6 files changed, 22 insertions(+), 22 deletions(-) diff --git a/docs/boolean-to-inList.md b/docs/boolean-to-inList.md index 5310f67..722fa46 100644 --- a/docs/boolean-to-inList.md +++ b/docs/boolean-to-inList.md @@ -22,10 +22,10 @@ When the setter is called, if the new value is truthy then the item will be adde Use this converter when two-way binding to an element with a boolean attribute, such as a checkbox. -```javascript +```js const map = new DefineMap({ - item: 5, - list: [1, 2, 3, 4, 5] + item: 5, + list: [1, 2, 3, 4, 5] }); const template = stache(''); diff --git a/docs/either-or.md b/docs/either-or.md index 81e666f..cd55dbe 100644 --- a/docs/either-or.md +++ b/docs/either-or.md @@ -40,11 +40,11 @@ You pass 3 arguments to this [can-stache.registerConverter converter]. The first

Your fandom: {{pref}}

``` -```javascript +```js const template = stache.from("demo-template"); const fan = new DefineMap({ - pref: "Star Trek" + pref: "Star Trek" }); document.body.appendChild(template(fan)); diff --git a/docs/equal.md b/docs/equal.md index c840cc1..5b6d9df 100644 --- a/docs/equal.md +++ b/docs/equal.md @@ -51,15 +51,15 @@ In this example we are using objects, to select a captain from one of three play {{/each}} ``` -```javascript +```js const template = stache.from("demo"); const vm = new DefineMap({ - captain: null, - players: [ - { name: "Matthew" }, - { name: "Wilbur" }, - { name: "Anne" } - ] + captain: null, + players: [ + { name: "Matthew" }, + { name: "Wilbur" }, + { name: "Anne" } + ] }); vm.captain = vm.players[0]; diff --git a/docs/input-radio.md b/docs/input-radio.md index 33ad33b..db489ac 100644 --- a/docs/input-radio.md +++ b/docs/input-radio.md @@ -14,11 +14,11 @@ To bind to a radio input, if you have a set of boolean values you can bind to th Two ``` -```javascript +```js const template = stache.from("demo"); const map = new DefineMap({ - one: true, - two: false + one: true, + two: false }); document.body.appendChild(template(map)); diff --git a/docs/not.md b/docs/not.md index a218b7e..bcb7915 100644 --- a/docs/not.md +++ b/docs/not.md @@ -27,9 +27,9 @@ Use this converter to two-way bind to the negation of some value. For example: ``` -```javascript +```js const map = new DefineMap({ - val: true + val: true }); document.body.appendChild(template(map)); @@ -54,10 +54,10 @@ map.val === true; // because the checkbox is now false. ``` -```javascript +```js const map = new DefineMap({ - item: 2, - list: new DefineList([ 1, 2, 3 ]) + item: 2, + list: new DefineList([ 1, 2, 3 ]) }); document.body.appendChild(template(map)); diff --git a/docs/string-to-any.md b/docs/string-to-any.md index c298c0a..c40ef11 100644 --- a/docs/string-to-any.md +++ b/docs/string-to-any.md @@ -35,12 +35,12 @@ This is usually used with ` ``` -```javascript +```js const str = document.getElementById('select-template').innerHTML; const template = stache(str); const map = new DefineMap({ - someValue: "foo" + someValue: "foo" }); document.body.appendChild(template(map)); From 1fad16c1cfaa6539372984adbde8a31a82b42bb6 Mon Sep 17 00:00:00 2001 From: Christopher Baker Date: Tue, 13 Feb 2018 16:57:58 -0800 Subject: [PATCH 3/3] run eslint on markdown code --- docs/boolean-to-inList.md | 22 ++++++++++++---------- docs/either-or.md | 8 ++++---- docs/equal.md | 12 ++++++------ docs/input-radio.md | 8 ++++---- docs/not.md | 22 +++++++++++----------- docs/string-to-any.md | 10 +++++----- 6 files changed, 42 insertions(+), 40 deletions(-) diff --git a/docs/boolean-to-inList.md b/docs/boolean-to-inList.md index 722fa46..3327e50 100644 --- a/docs/boolean-to-inList.md +++ b/docs/boolean-to-inList.md @@ -23,26 +23,28 @@ When the setter is called, if the new value is truthy then the item will be adde Use this converter when two-way binding to an element with a boolean attribute, such as a checkbox. ```js -const map = new DefineMap({ +const map = new DefineMap( { item: 5, - list: [1, 2, 3, 4, 5] -}); + list: [ 1, 2, 3, 4, 5 ] +} ); -const template = stache(''); +const template = stache( + "" +); -document.body.appendChild(template(map)); +document.body.appendChild( template( map ) ); -const input = document.querySelector('input[type=checkbox]'); +const input = document.querySelector( "input[type=checkbox]" ); -console.log(input.checked); // -> true +console.log( input.checked ); // -> true map.item = 6; -console.log(input.checked); // -> false +console.log( input.checked ); // -> false -map.list.push(6); +map.list.push( 6 ); -console.log(input.checked); // -> true +console.log( input.checked ); // -> true ``` @demo demos/can-stache-converters/input-checkbox.html diff --git a/docs/either-or.md b/docs/either-or.md index cd55dbe..a759c0d 100644 --- a/docs/either-or.md +++ b/docs/either-or.md @@ -41,13 +41,13 @@ You pass 3 arguments to this [can-stache.registerConverter converter]. The first ``` ```js -const template = stache.from("demo-template"); +const template = stache.from( "demo-template" ); -const fan = new DefineMap({ +const fan = new DefineMap( { pref: "Star Trek" -}); +} ); -document.body.appendChild(template(fan)); +document.body.appendChild( template( fan ) ); // User unchecks the checkbox fan.pref === "Star Wars"; diff --git a/docs/equal.md b/docs/equal.md index 5b6d9df..2a963ed 100644 --- a/docs/equal.md +++ b/docs/equal.md @@ -52,19 +52,19 @@ In this example we are using objects, to select a captain from one of three play ``` ```js -const template = stache.from("demo"); -const vm = new DefineMap({ +const template = stache.from( "demo" ); +const vm = new DefineMap( { captain: null, players: [ { name: "Matthew" }, { name: "Wilbur" }, { name: "Anne" } ] -}); -vm.captain = vm.players[0]; +} ); +vm.captain = vm.players[ 0 ]; -const frag = template(vm); -document.body.appendChild(frag); +const frag = template( vm ); +document.body.appendChild( frag ); ``` @demo demos/can-stache-converters/input-radio.html diff --git a/docs/input-radio.md b/docs/input-radio.md index db489ac..d53a866 100644 --- a/docs/input-radio.md +++ b/docs/input-radio.md @@ -15,13 +15,13 @@ To bind to a radio input, if you have a set of boolean values you can bind to th ``` ```js -const template = stache.from("demo"); -const map = new DefineMap({ +const template = stache.from( "demo" ); +const map = new DefineMap( { one: true, two: false -}); +} ); -document.body.appendChild(template(map)); +document.body.appendChild( template( map ) ); ``` ## Binding to a selected value diff --git a/docs/not.md b/docs/not.md index bcb7915..f485d14 100644 --- a/docs/not.md +++ b/docs/not.md @@ -28,13 +28,13 @@ Use this converter to two-way bind to the negation of some value. For example: ``` ```js -const map = new DefineMap({ +const map = new DefineMap( { val: true -}); +} ); -document.body.appendChild(template(map)); +document.body.appendChild( template( map ) ); -const input = document.querySelector('input'); +const input = document.querySelector( "input" ); input.checked; // -> false @@ -55,13 +55,13 @@ map.val === true; // because the checkbox is now false. ``` ```js -const map = new DefineMap({ +const map = new DefineMap( { item: 2, - list: new DefineList([ 1, 2, 3 ]) -}); + list: new DefineList( [ 1, 2, 3 ] ) +} ); -document.body.appendChild(template(map)); -const input = document.querySelector('input'); +document.body.appendChild( template( map ) ); +const input = document.querySelector( "input" ); input.checked; // -> false @@ -74,10 +74,10 @@ input.checked; // -> true // Check the input, whick will set its value to `false` // This will be converted to `true` by not() and pushed into the list -map.list.indexOf(4); // -> 3 +map.list.indexOf( 4 ); // -> 3 // Remove it from the list, which will be converted to true by not() -map.list.splice(3, 1); +map.list.splice( 3, 1 ); input.checked; // -> true ``` diff --git a/docs/string-to-any.md b/docs/string-to-any.md index c40ef11..c0a80f7 100644 --- a/docs/string-to-any.md +++ b/docs/string-to-any.md @@ -36,14 +36,14 @@ This is usually used with `