`.
397 |
398 | + `.templates` - This property represents the list of ``s nested within the ``. References to templates are maintained here by name.
399 |
400 | ```html
401 |
402 |
403 |
404 |
405 |
406 |
407 | ```
408 |
409 | accessing `document.templates.template1.templates.nested1` should return the first nested ``, while `document.templates.template1.templates.nested2` the second nested ``. And the nesting can go on as much as code organization requires.
410 |
411 | **For every element:**
412 |
413 | + `element.template` - This property is a reference to the `` element pointed to by an element. So if an element implements a template as in ``, then `element.template` should be a reference to the `` at the `module/temp` namespace; `element.template.partials.default` should thus return an array like the above.
414 |
415 | **For the `
19 | About Me
20 |
28 | Back to Home
29 |
16 | Welcome Home!
17 |
18 |
25 | About Me!
26 |
27 | ` logic can bind to the `removeItem()` method of the TODO application. For the *add* feature, we'd add a button to the TODO container that calls the `addItem()` method of the TODO application.
6 |
7 | We've also decided to use [the Observer API](https://docs.web-native.dev/observer) and [PlayUI's `.itemize()`](https://docs.web-native.dev/play-ui/api/dom/itemize) method that provides a simple way to keep the list container in sync with application items.
8 |
9 | [Check the live example here](https://web-native.dev/package/chtml/docs/demos/todo.html)
10 |
11 | ```html
12 |
13 |
14 |
15 |
16 |
37 |
38 |
39 |
40 | todoItems.push({desc:"New Item"})
6 |
7 |
8 |
9 |
10 |
11 | CHTML is a suite of new DOM features that brings native support for modern UI development paradigms: a component-based architecture, data binding, and reactivity. This lets us build elegant user interfaces using the web platform itself.
12 |
13 | > CHTML is being proposed as a [W3C standard at the Web Platform Incubator Community Group](https://discourse.wicg.io/t/proposal-chtml/4716) based on [this explainer](https://github.com/web-native/chtml/blob/master/explainer.md).
14 |
15 | [Check this project out on GitHub](https://github.com/web-native/chtml).
16 |
17 | ## Documentation
18 |
19 | + [Scoped HTML](https://docs.web-native.dev/chtml/scoped-html) - Structure your document as a hierarchy of *scopes* and *subscopes*.
20 | + [Scoped CSS](https://docs.web-native.dev/chtml/scoped-css) - Define styling as part of any element using scoped stylesheets.
21 | + [Scoped JS](https://docs.web-native.dev/chtml/scoped-js) - Define behaviour as part of any element using scoped scripts.
22 | + [HTML Partials](https://docs.web-native.dev/chtml/html-partials) - Define, import/export, and compose with reusable HTML snippets.
23 |
24 | ## Getting Started
25 |
26 | + [Installation](https://docs.web-native.dev/chtml/installation) - Follow the installation guide to add the CHTML polyfill to your page.
27 | + [Examples](https://docs.web-native.dev/chtml/examples) - Get a head start with these few examples.
28 |
29 | ## Issues
30 |
31 | To report bugs or request features, please submit an [issue](https://github.com/web-native/chtml/issues).
32 |
33 | ## License
34 |
35 | MIT.
36 |
--------------------------------------------------------------------------------
/docs/bundle.json:
--------------------------------------------------------------------------------
1 | {
2 | "scoped-html": {},
3 | "scoped-css": {},
4 | "scoped-js": {},
5 | "html-partials": {},
6 | "examples": {
7 | "jquery": {},
8 | "spa": {},
9 | "todo": {}
10 | },
11 | "installation": {}
12 | }
--------------------------------------------------------------------------------
/docs/installation/README.md:
--------------------------------------------------------------------------------
1 | # Installation Guide
2 |
3 | This library is a polyfill for the proposed CHTML suite.
4 |
5 | ## On this Page
6 |
7 | + [Embed As Script](#embed-as-script)
8 | + [Embed The Complete Suite](#embed-the-complete-suite)
9 | + [Embed Individual Features](#embed-individual-features)
10 | + [Install Via NPM](#install-via-npm)
11 | + [Initialize the Complete Suite](#initialize-the-complete-suite)
12 | + [Initialize Individual Features](#initialize-individual-features)
13 | + [Server-Side Initialization](#server-side-initialization)
14 | + [Next Steps](#next-steps)
15 |
16 | ## Embed As Script
17 |
18 | + **Embed The Complete Suite** - Embed the build below for everything about CHTML.
19 |
20 | ```html
21 |
22 | ```
23 |
24 | + **Embed Individual Features** - Find a build below for a specific CHTML feature.
25 |
26 | + **Scoped HTML** - ``
27 |
28 | + **Scoped CSS** - ``
29 |
30 | + **Scoped JS** - ``
31 |
32 | + **HTML Partials** - ``
33 |
34 | ## Install Via NPM
35 |
36 | ```text
37 | $ npm i -g npm
38 | $ npm i --save @web-native-js/chtml
39 | ```
40 |
41 | The installed package is designed to be *initialized* with the *window* object of the current browser or server evironment. To do this, import the `ENV` object and assign the *window* object to it, then call the initializer.
42 |
43 | + **Initialize the Complete Suite** - Initialize the module below for everything about CHTML.
44 |
45 | ```js
46 | // Import
47 | import init, { ENV } from '@web-native-js/chtml';
48 | // Initialize
49 | ENV.window = window;
50 | init();
51 | ```
52 |
53 | + **Initialize Individual Features** - Find a module below for a specific CHTML feature.
54 |
55 | + **Scoped HTML**
56 |
57 | ```js
58 | // Import
59 | import init, { ENV } from '@web-native-js/chtml/src/scoped-html/index.js';
60 | // Initialize
61 | ENV.window = window;
62 | init();
63 | ```
64 |
65 | + **Scoped CSS**
66 |
67 | ```js
68 | // Import
69 | import init, { ENV } from '@web-native-js/chtml/src/scoped-css/index.js';
70 | // Initialize
71 | ENV.window = window;
72 | init();
73 | ```
74 |
75 | + **Scoped JS**
76 |
77 | ```js
78 | // Import
79 | import init, { ENV } from '@web-native-js/chtml/src/scoped-js/index.js';
80 | // Initialize
81 | ENV.window = window;
82 | init();
83 | ```
84 |
85 | + **HTML Partials**
86 |
87 | ```js
88 | // Import
89 | import init, { ENV } from '@web-native-js/chtml/src/html-partials/index.js';
90 | // Initialize
91 | ENV.window = window;
92 | init();
93 | ```
94 |
95 | ## Server-Side Initialization
96 |
97 | Here is how CHTML could be initialized on DOM instances created on the server with a library like [jsdom](https://github.com/jsdom/jsdom) (using the `window` object from the DOM instance.)
98 |
99 |
100 | ```js
101 | // Import the class directly
102 | import init, { ENV } from '@web-native-js/chtml';
103 | // Import jsDom
104 | import jsdom from 'jsdom';
105 | // Utilities we'll need
106 | import fs from 'fs';
107 | import path from 'path';
108 |
109 | // Read the document file from the server
110 | const documentFile = fs.readFileSync(path.resolve('./index.html'));
111 | // Instantiate jsdom so we can obtain the "window" for CHTML
112 | // Detailed instruction on setting up jsdom is available in the jsdom docs
113 | const JSDOM = new jsdom.JSDOM(documentFile.toString());
114 |
115 | // Initialize CHTML...
116 | // and we'll be good to go
117 | ENV.window = JSDOM.window;
118 | init();
119 | ```
120 |
121 | ## Next Steps
122 |
123 | Let's now learn the core concepts of CHTML.
124 |
125 | + [Chtml](/chtml/)
126 |
127 |
128 |
129 |
--------------------------------------------------------------------------------
/docs/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/web-native/chtml/5b578bf8dbfb217455b130acb148f441d1c3890b/docs/logo.png
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@web-native-js/chtml",
3 | "title": "CHTML",
4 | "description": "A suite of new DOM features that brings language support for modern UI development paradigms: a component-based architecture, data binding, and reactivity.",
5 | "keywords": [
6 | "Scoped HTML",
7 | "Scoped CSS",
8 | "Scoped JS",
9 | "HTML Partials",
10 | "HTML components",
11 | "UI components",
12 | "Frontend framework"
13 | ],
14 | "homepage": "https://web-native.dev/package/chtml",
15 | "version": "1.3.2",
16 | "license": "MIT",
17 | "repository": {
18 | "type": "git",
19 | "url": "git+https://github.com/web-native/chtml.git"
20 | },
21 | "bugs": {
22 | "url": "https://github.com/web-native/chtml/issues"
23 | },
24 | "type": "module",
25 | "browser": {
26 | "fs": false
27 | },
28 | "main": "src/index.js",
29 | "scripts": {
30 | "test": "node ./tests/index.js",
31 | "build-dev": "npx projectz compile && webpack --config ./webpack.config.dev.cjs",
32 | "build": "webpack --config ./webpack.config.cjs",
33 | "docs": "cd docs && chtml bundle loaders=default:md-loader md-loader:flavor=github show_outline_numbering=FALSE ..."
34 | },
35 | "dependencies": {
36 | "@onephrase/util": "^0.6.2",
37 | "@web-native-js/jsen": "^0.6.6",
38 | "@web-native-js/observer": "^1.0.9"
39 | },
40 | "devDependencies": {
41 | "webpack": "^4.44.2",
42 | "webpack-cli": "^3.3.12"
43 | },
44 | "author": "Oxford Harrison