Skip to content

Latest commit

 

History

History

render-client

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Orbito Render Client

npm (scoped) Github actions Build MIT license Typed

HTTP client to use with Orbito Render.

npm i --save @orbito/render-client
import { RenderClient } from '@orbito/render-client/RenderClient'

const renderClient = new RenderClient(
    {
        default: 'http://localhost:4264',
    }, {
        html: RenderClient.optimizeForHtml,
        email: RenderClient.optimizeForEmail,
    },
)

const styleId = 'main'

const res = await renderClient.render(
    'default', 'en', styleId,
    renderClient.tplRef('my-tpl', 'pages/default'),// the template reference
    renderClient.optimize('html'),// the optimization settings
    {},// data, available in template under `doc.*`
    {},// styleVars, configure Scss vars just in time
)
console.log('   > rendered template in ' + res.renderTime + 'ms')
const html = res.rendered

const resStyle = await renderClient.style(
    'default', styleId, 'my-tpl',
    {nanoCss: true, cssAutoPrefix: true},
    {},// styleVars, configure Scss vars just in time
)
console.log('   > generated style in ' + resStyle.styleTime + 'ms')

const style = resStyle.style

ESM only package

License

MIT License

© 2022 bemit