Last active
March 7, 2019 11:54
-
-
Save FND/7b262ba743ebb5afdc2ae2a2f6be08a0 to your computer and use it in GitHub Desktop.
universal complate
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/node_modules | |
/dist |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
module.exports = { | |
js: [{ | |
source: "./index.js", | |
target: "./dist/bundle.js", | |
jsx: { pragma: "COMPLATE" } | |
}] | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if(typeof global === "undefined" && typeof window !== "undefined") { | |
window.global = window; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>universal complate</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
</head> | |
<body> | |
<h1>universal complate</h1> | |
<p>generating both HTML and DOM nodes from the same template</p> | |
<script src="dist/bundle.js"></script> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import "./global_shim"; | |
import render from "./template"; | |
import { default as dom } from "complate-dom"; | |
import { createElement as html } from "complate-stream"; | |
import BufferedStream from "complate-stream/src/buffered-stream"; | |
global.COMPLATE = html; | |
let stream = new BufferedStream(); | |
let element = render("Hello World", "lorem ipsum"); | |
element(stream, { nonBlocking: true }, () => { | |
let container = document.createElement("pre"); | |
container.textContent = stream.read(); | |
insert(container); | |
}); | |
global.COMPLATE = dom; | |
let node = render("Hello World", "lorem ipsum"); | |
insert(node); | |
function insert(node) { | |
document.body.appendChild(node); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"scripts": { | |
"start": "faucet" | |
}, | |
"dependencies": {}, | |
"devDependencies": { | |
"complate-dom": "^1.2.0", | |
"complate-stream": "^0.16.5", | |
"faucet-pipeline-jsx": "^2.0.0" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default (title, summary) => ( | |
<article> | |
<h3>{title}</h3> | |
<p>{summary}</p> | |
</article> | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment