You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+12-4Lines changed: 12 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,16 +1,18 @@
1
1
# superviews.js
2
2
3
-
Template engine for google [incremental-dom](http://google.github.io/incremental-dom)
3
+
On the server `superviews.js` is used as a template engine for google's[incremental-dom](http://google.github.io/incremental-dom).
4
4
5
-
Try it out [live in your browser](http://davidjamesstone.github.io/superviews.js/playground/index.html)</a>
5
+
It can also now be used [in the browser](#client) to help build web applications based on [Custom Elements V1](https://www.w3.org/TR/custom-elements/)
6
+
7
+
Try it out [live in your browser](http://davidjamesstone.github.io/superviews.js/playground/index.html)
6
8
7
9
`npm install superviews.js --save`
8
10
9
11
## API
10
12
11
13
`tmplstr` (required) - The template string.
12
-
`name` - The output function name (will be overridden with a <template> element).
13
-
`argstr` - The output function arguments (will be overridden with a <template> element).
14
+
`name` - The output function name (will be overridden with a `<template>` element).
15
+
`argstr` - The output function arguments (will be overridden with a `<template>` element).
14
16
`mode` - The output format. Can be one of ['es6', 'cjs', 'browser', 'amd'], if any other value is passed the function is exported as a variable with that name.
15
17
16
18
`superviews(tmplstr, name, argstr, mode)`
@@ -19,6 +21,12 @@ Try it out [live in your browser](http://davidjamesstone.github.io/superviews.js
NEW! superviews can now be [used in the browser](docs/client.md).
27
+
28
+
Use it as a clientside library with a set of helpful classes and methods for building web applications based on the Web Components spec, specifically [Custom Elements V1](https://www.w3.org/TR/custom-elements/).
Copy file name to clipboardExpand all lines: docs/client.md
+8-5Lines changed: 8 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,7 +29,7 @@ This can then be used in HTML like so:
29
29
30
30
`superviews.js` provides a thin wrapper around this pattern that includes events, event delegation and property and attribute validation.
31
31
32
-
The idea is that by describing what your components inputs (property/attributes) and outputs (events) are, you document the component and can also use this information to validate the state of the component.
32
+
The idea is that by describing what your components inputs (property/attributes) and outputs (events) are, you document the component and can also use the information to validate the state of the component.
33
33
34
34
JSON Schema is used to describe the properties and attributes.
35
35
@@ -42,11 +42,14 @@ All the examples are CJS/browserify.
42
42
Say you want to build a Todo List Web Component.
43
43
44
44
It's to have a `theme` that can be either `light` or `dark` but defaults to `dark`.
45
-
It also needs to be supplied a list of items called `todos`. Both these inputs are required. The list of `todo` items should be an array of objects with a required integer `id`, required `text` string and a boolean flag to indicate if the task `isCompleted`.
45
+
It also needs to be supplied a list of items called `todos`.
46
+
Both these inputs are required.
47
+
48
+
The list of `todo` items should be an array of objects with a required integer `id`, required `text` string and a boolean flag to indicate if the task `isCompleted`.
46
49
47
50
A third optional input is a `title` for the todo list and has a max length of 10.
48
51
49
-
The Todos component should emit 3 events - `change`, `add` and `remove`.
52
+
The Todos component can emit 3 events - `change`, `add` and `remove`.
50
53
51
54
Using `superviews.js`, it looks like this:
52
55
@@ -110,7 +113,7 @@ class Todos extends superviews(options) {
110
113
window.customElements.define('x-todos', Todos)
111
114
```
112
115
113
-
This could then be used like:
116
+
This can then be used in HTML like this:
114
117
115
118
```html
116
119
<x-todostheme="light"title="My Todos">
@@ -253,4 +256,4 @@ You can use it via `superviews.js` if you like:
253
256
require('superviews.js/dre')
254
257
```
255
258
256
-
For more info see the [examples](../examples) folder or open [todos](../examples/client/x-todos/index.html) or [widget](../examples/client/x-widget/test.html)
259
+
For more info see the [examples](../examples) folder or open [todos](../examples/client/x-todos/test.html) or [widget](../examples/client/x-widget/test.html)
0 commit comments