Skip to content

xelaok/node-stream-string

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

node-stream-string

Streamed ES6 template literal function.

Motivation

Written for using renderToNodeStream React SSR function with ES6 template literals.

Install

npm i --save node-stream-string

Usage

const streamString = require('node-stream-string')

// ...

app.get("/", (req, res) => {
    const stream = streamString`
        <!DOCTYPE html>
        <html>
        <head>
            <title>${ getTitle(req) }</title>
            <style>${ getStyle(req) }</style>
        </head>
        <body>    
            <div id='root'>
                ${ renderToNodeStream(<App/>) }
            </div>
        </body>
        </html>
    `
    stream.pipe(res)
})

License

MIT

About

Streamed ES6 template literal function

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published