Skip to content

Instantly share code, notes, and snippets.

@FND
Created September 11, 2018 10:26
Show Gist options
  • Save FND/29305de381761b30496c0a16634f1d96 to your computer and use it in GitHub Desktop.
Save FND/29305de381761b30496c0a16634f1d96 to your computer and use it in GitHub Desktop.
complate string rendering
/node_modules
/dist
"use strict";
module.exports = {
js: [{
source: "./index.js",
target: "./dist/bundle.js",
jsx: { pragma: "createElement" }
}]
};
import { MyMacro } from "./macros";
import { createElement } from "complate-stream";
import BufferedStream from "complate-stream/src/buffered-stream";
let stream = new BufferedStream();
let el = createElement(MyMacro, { title: "Hello World" });
el(stream, { nonBlocking: true }, () => {
let html = stream.read();
console.log(html);
});
import { createElement } from "complate-stream"
export function MyMacro({ title }, ...children) {
return <article class="sample">
<h2>{title}</h2>
{children}
</article>;
}
{
"scripts": {
"start": "npm run compile && node ./dist/bundle.js",
"compile": "faucet"
},
"dependencies": {},
"devDependencies": {
"complate-stream": "^0.16.4",
"faucet-pipeline-jsx": "^1.0.0-rc.11"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment