Skip to content

Instantly share code, notes, and snippets.

@FND
Last active February 6, 2020 06: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 FND/c75c9522e7bc33605c8b65c24574c85a to your computer and use it in GitHub Desktop.
Save FND/c75c9522e7bc33605c8b65c24574c85a to your computer and use it in GitHub Desktop.
minimal complate sample
/node_modules
/dist

minimal complate sample

  1. npm install
  2. npm start
import { createElement } from "complate-stream";
export function Card({ title }, ...children) {
return <article class="card">
<h3>{title}</h3>
{children}
</article>;
}
"use strict";
module.exports = {
js: [{
source: "./index.js",
target: "./dist/bundle.js",
jsx: { pragma: "createElement" }
}]
};
import { SampleView } from "./views.jsx";
import Renderer from "complate-stream";
import BufferedStream from "complate-stream/src/buffered-stream.js";
let { renderView } = new Renderer();
let stream = new BufferedStream();
renderView(SampleView, { title: "Hello World" }, stream, {}, () => {
let html = stream.read();
console.log(html);
});
{
"scripts": {
"start": "npm run compile && node dist/bundle.js",
"compile": "faucet"
},
"dependencies": {
"complate-stream": "^0.16.9"
},
"devDependencies": {
"faucet-pipeline-jsx": "^2.0.10"
}
}
import { Card } from "./components.jsx";
import { createElement } from "complate-stream";
export function SampleView() {
return <Card title="Hello World">
<p>lorem ipsum dolor sit amet</p>
</Card>;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment