New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

node-react-templates

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-react-templates

transparently require() react-templates .rt file from node

latest
npmnpm
Version
0.1.4
Version published
Maintainers
1
Created
Source

node-react-templates

Build Status

Transparently require() .rt file from node with react-templates

Usage

require('node-react-templates').install()

Then you can use .rt file in the react components for server side rendering.

Example

The following is the example that using node-react-templates to render React components from node.

React Templates Code --hello.rt

<div>
  <h3>Hello World</h3>
</div>

React Components Code --hello.jsx

var React = require('react/addons');

var helloTemplate = require("./hello.rt");

var Hello = React.createClass({
  
  render: function() {
    
    return helloTemplate.apply(this);
    
  }

});

module.exports = Hello;

Server side rendering code --render.js

var React = require('react/addons');
require('node-jsx').install();
require('node-react-templates').install();

var compPath="./hello.jsx";

var component = require(compPath);
var contents = React.renderToString(React.createElement(component));

console.log(contents);

Test

You can use the following command to run mocha tests.

npm run test

the test script in under the folder test/.

Keywords

react-templates

FAQs

Package last updated on 13 Dec 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts