Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup markdown sample code #80

Merged
merged 3 commits into from
Feb 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions docs/boolean-to-inList.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
var map = new DefineMap({
const map = new DefineMap( {
item: 5,
list: [1, 2, 3, 4, 5]
});
list: [ 1, 2, 3, 4, 5 ]
} );

var template = stache('<input type="checkbox" checked:bind="boolean-to-inList(item, list)" />');
const template = stache(
"<input type=\"checkbox\" checked:bind=\"boolean-to-inList(item, list)\" />"
);

document.body.appendChild(template(map));
document.body.appendChild( template( map ) );

var 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
8 changes: 4 additions & 4 deletions docs/either-or.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ You pass 3 arguments to this [can-stache.registerConverter converter]. The first
```

```js
var template = stache.from("demo-template");
const template = stache.from( "demo-template" );

var 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";
Expand Down
12 changes: 6 additions & 6 deletions docs/equal.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,19 @@ In this example we are using objects, to select a captain from one of three play
```

```js
var template = stache.from("demo");
var 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 ];

var frag = template(vm);
document.body.appendChild(frag);
const frag = template( vm );
document.body.appendChild( frag );
```

@demo demos/can-stache-converters/input-radio.html
Expand Down
8 changes: 4 additions & 4 deletions docs/input-radio.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ To bind to a radio input, if you have a set of boolean values you can bind to th
```

```js
var template = stache.from("demo");
var 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
Expand Down
22 changes: 11 additions & 11 deletions docs/not.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ Use this converter to two-way bind to the negation of some value. For example:
```

```js
var map = new DefineMap({
const map = new DefineMap( {
val: true
});
} );

document.body.appendChild(template(map));
document.body.appendChild( template( map ) );

var input = document.querySelector('input');
const input = document.querySelector( "input" );

input.checked; // -> false

Expand All @@ -55,13 +55,13 @@ map.val === true; // because the checkbox is now false.
```

```js
var 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));
var input = document.querySelector('input');
document.body.appendChild( template( map ) );
const input = document.querySelector( "input" );


input.checked; // -> false
Expand All @@ -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
```
10 changes: 5 additions & 5 deletions docs/string-to-any.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ This is usually used with `<select>`s where you would like to two-way bind a str
```

```js
var str = document.getElementById('select-template').innerHTML;
var template = stache(str);
const str = document.getElementById( "select-template" ).innerHTML;
const template = stache( str );

var map = new DefineMap({
const map = new DefineMap( {
someValue: "foo"
});
} );

document.body.appendChild(template(map));
document.body.appendChild( template( map ) );

map.item = NaN; // select.value becomes "NaN"

Expand Down