How to use the inferno-server.renderToString function in inferno-server

To help you get started, we’ve selected a few inferno-server examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github infernojs / inferno-website / src / server / middleware / render.js View on Github external
export default async(ctx, next) => {

  const context = {};
  const content = renderToString(
    
      
        {routes}
      
    
  );

  // This will contain the URL to redirect to if  was used
  if (context.url) {
    return ctx.redirect(context.url);
  }

  ctx.type = 'text/html';
  ctx.body = '\n' + content;
  await next();
};
github joe-sky / nornj / test / htmlTemplateUseInfernoSpec.js View on Github external
var data = {
            name: 'joe_sky',
            id: 100,
            test0: true,
            list: [{ no: 1, b: 1 }, { no: 2, b: 0 }, { no: 3, b: 1 }],
            styles: { color: 'blue', fontSize: '15px' },
            //testcom: TestComponent
          };

          //nj.registerComponent('TestComponent', TestComponent);

          var templateT = nj.compileTagComponent(window.document.querySelector('div'), 'testT1');
          //console.log(JSON.stringify(nj.templates['testT1']));
          //console.log(templateT(data));

          var html = InfernoServer.renderToString(templateT(data));

          console.log(html);
          expect(html).toBeTruthy();
          done();
        }
      );
github davidgilbertson / know-it-all / app / server / appHtml.js View on Github external
export default ({ dataFileName = `data.json`, scriptFileName, mode }) => {
  let scriptSrc;
  let styleTag = ``;

  if (mode === `production`) {
    scriptSrc = scriptFileName;

    const stylesPath = path.resolve(__dirname, `../../public/styles.css`);
    const styles = fs.readFileSync(stylesPath, `utf8`);

    styleTag = `<style>${styles}</style>`;
  } else {
    scriptSrc = `http://localhost:8081/${WEBPACK_BUNDLE}`;
  }

  const appHtml = renderToString();

  return `
  
    
      <title>Know it all</title>
      
      
      
      
      
      
      
      
      ${styleTag}
      
github robinweser / fela / examples / example-inferno / server.js View on Github external
app.get('/', (req, res) =&gt; {
  const renderer = createRenderer()

  const indexHTML = fs.readFileSync(`${__dirname}/index.html`).toString()
  const appHtml = renderToString(
    
      
    
  )
  const appCSS = renderToMarkup(renderer)

  res.write(
    indexHTML
      .replace('', appHtml)
      .replace('', appCSS)
  )
  res.end()
})
github marko-js / isomorphic-ui-benchmarks / benchmarks / search-results / inferno / util / serverRender.jsx View on Github external
module.exports = function infernoRender(App, searchResultsData) {
  return InfernoServer.renderToString(
    
  );
};
github Financial-Times / x-dash / private / ssr-benchmark / controllers / inferno / index.js View on Github external
module.exports = (req, res) => {
    res.type('text/html').code(200);

    res.send(
        renderToString(render())
    );
};
github rtsao / hokusai / generator / server-render.js View on Github external
function render(pathname, Markup, App, props) {
  const styletron = new StyletronServer();
  const appContent = InfernoServer.renderToString(createElement(App, {pathname, styletron}));
  const styletronSheets = styletron.getStylesheets();
  const markupProps = Object.assign({}, props, {appContent, styletronSheets});
  return '' + InfernoServer.renderToStaticMarkup(createElement(Markup, markupProps));
}
github raxjs / server-side-rendering-comparison / benchmarks / renderToString.js View on Github external
.add(`Inferno(${infernoPkg.version})#renderToString`, function() {
    InfernoServer.renderToString(infernoCreateElement.createElement(InfernoApp, data));
  })
  .add(`Preact(${preactPkg.version})#renderToString`, function() {
github jaredpalmer / razzle / examples / with-inferno / src / server.js View on Github external
.get('/*', (req, res) =&gt; {
    const markup = InfernoServer.renderToString();

    res.status(200).send(
      `
    
    
        
        
        <title>Welcome to Razzle</title>
        
        ${assets.client.css
          ? ``
          : ''}
        ${process.env.NODE_ENV === 'production'
          ? ``
          : ``}
github iotexproject / iotex-explorer / src / lib / middleware / iso-render-middleware.js View on Github external
function html(ctx, renderProps, reducer, clientScript): string {
  initServerI18n(ctx);
  initServerConsent(ctx);
  const state = ctx.getState();
  const jsonGlobals = JsonGlobals({state});
  initAssetURL(state.base.siteURL, state.base.routePrefix, state.base.manifest);
  const store = configureStore(state, reducer);
  const styletron = new StyletronServer({prefix: '_'});

  const reactMarkup = renderToString(
    
  );
  return rootHtml({styletron, jsonGlobals, reactMarkup, clientScript, nonce: ctx.state.nonce});
}

inferno-server

Provides methods to render HTML strings from Inferno elements

MIT
Latest version published 1 year ago

Package Health Score

71 / 100
Full package analysis