Skip to content

Instantly share code, notes, and snippets.

@alexeyraspopov
Created April 10, 2015 16:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexeyraspopov/3e4eb6d287e4401b94e3 to your computer and use it in GitHub Desktop.
Save alexeyraspopov/3e4eb6d287e4401b94e3 to your computer and use it in GitHub Desktop.
function View(props) {
return (
props.allow
? HelloWorld({ name: props.name })
: P(null, [Text('Not allowed')])
);
}
function HelloWorld(props) {
return (
Div({ className: 'primary-content' }, [
P(null, [
Text('Hello, ' + props.name)
])
])
);
}
function Div(props, children) {
return Element('div', props, children);
}
function P(props, children) {
return Element('p', props, children);
}
function Element(tag, props, children) {
var element = document.createElement(tag);
Object.keys(props || {}).forEach(function(key) {
element[key] = props[key];
});
children.forEach(element.appendChild, element);
return element;
// return { node, updater }
}
function Text(content) {
var node = document.createTextNode(content);
return node;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment