The HTML was created for this
13,4 kB of documented, not minified code.
Unlike the common Javascript UI frameworks, W3View is not based on any templates, does not define its own markup language or rule definition language, and does not drive you into the solid frames of unnatural concepts.
Completely based on HTML, Javascript and DOM API, W3View offers a new look at the capabilities of long-known and widespread technologies. Like React, it is just a library for building user interfaces. But unlike it W3View is closer to JavaFX, SWING or Qt.
W3View generates reusable UI components from HTML based declarative definitions.
W3View allows you to build reach interfaces and combine powerful frontend. Popup windows, data grid and color chooser are just small examples and can be used as parts of your great UI.
Each instance of W3View contains its own namespace and independent set of components. Therefore the number of independent applications can be mounted on the page. Also one W3View app can use the number of mounting points on the page, and it can run the number of W3View apps inside one W3View app. This is the real power of Javascript.
The main conception of W3View is - NO NEW CONCEPTIONS and the second conception is - NO NEW WORDS.
Component definition - is the markup of one sample HTMLElement. Just write some HTML markup and embedded constructor script, like this:
//"hello-world" definition
<div as="hello-world">
<input ref="input" placeholder="type your name here">
<h1>Hello <span ref="name">Anonimous</span>!</h1>
<script>
var me=this;
this.ref.input.onkeydown=this.ref.input.onkeyup = function(e){
me.setData(me.ref.input.value);
};
this.onSetData = function(data){
me.ref.name.innerText = data || 'Anonimous';
};
</script>
</div>
//Here:
//"this" - is the reference to DIV, that is instance of "hello-world".
//attribute "ref" - is some one like *id*, inside the component.
//"this.ref" - is the table of references to corresponded elements.
Looks like web page, when web was young, is not it? Yes, but it is reusable component. It can be used as simple application, and it can be used as part of more complex app inside another component, for example:
<div as="double-hello-world">
<hello-world></hello-world>
<hr>
<hello-world></hello-world>
</div>
Okay, lets combine these examples, make complete HTML page and run "double-hello-world" app:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>Double Hello</title>
<head>
<script src="w3view.js"></script>
<script type="text/w3view" id="components">
//any text can be placed between components definitions,
//except HTML markup.
//hello-world component
<div as="hello-world">
<h1 ref="content"></h1>
<input ref="input" placeholder="type your name here">
<h2>Hello <span ref="name">Anonimous</span>!</h2>
<constructor>
//CONSTRUCTOR tag should be used inside SCRIPT tag
var me=this;
this.ref.input.onkeydown=this.ref.input.onkeyup = function(e){
me.setData(me.ref.input.value);
};
this.onSetData = function(data){
me.ref.name.innerText = data || 'Anonimous';
};
</constructor>
</div>
//root of app
<div as="double-hello-world">
<hello-world>Hello first</hello-world>
<hr>
<hello-world>Hello second</hello-world>
</div>
</script>
<body style="margin:50px;">
<script defer="defer">
var w3view = new W3View();
w3view.parse(components.textContent);
w3view.create('double-hello-world').mount(document.body);
</script>
</body>
</html>
You can find this example in ./examples folder of this repo. or click here
You can use W3View as View layer of any kind of MVC. W3View is ready to Flux, reactive programming, and event driven programming. All what You can do with HTML and Javascript, You can do with W3View components.
You need just w3view.js file, text editor and browser. Any browser, including IE9.
You need to know HTML and Javascript. You also need to know basics of DOM API.