Git Product home page Git Product logo

sprockets-coffee-react's Introduction

sprockets-coffee-react

Compatibility

sprockets-coffee-react 2.x is compatible with react ^0.12.0

sprockets-coffee-react 0.x is compatible with react <=0.11.0

How to use

Add this to your Gemfile:

gem 'sprockets-coffee-react'

Place a .js.coffee.cjsx or .js.cjsx file, or a .js.coffee file in your assets directory. When you require it into other JS files the CJSX markup will be transformed and compiled to Javascript.

Eg. if you have a file called my-component.js.coffee which contains some CJSX code, require it from application.js or somewhere else:

//= require my-component

How to use with a Rack application

If you’re not using rails, you’ll need to register the Sprockets preprocessor manually. Here is an adapted version of the Rack example provided by Sprockets, which additionally requires and registers the sprockets-coffee-react engine:

require 'sprockets'
require 'sprockets/coffee-react'
map '/assets' do
  environment = Sprockets::Environment.new
  environment.append_path 'app/assets/javascripts'
  environment.append_path 'app/assets/stylesheets'
  environment.register_preprocessor 'application/javascript', Sprockets::CoffeeReact
  environment.register_engine '.cjsx', Sprockets::CoffeeReactScript
  environment.register_engine '.js.cjsx', Sprockets::CoffeeReactScript
  run environment
end

map '/' do
  run YourRackApp
end

License

Released under the MIT License. See the LICENSE file for further details.

How to use with Middleman

Add the following to your config.rb file:

require 'sprockets/coffee-react'

::Sprockets.register_preprocessor 'application/javascript', ::Sprockets::CoffeeReact
::Sprockets.register_engine '.cjsx', ::Sprockets::CoffeeReactScript
::Sprockets.register_engine '.js.cjsx', ::Sprockets::CoffeeReactScript

sprockets-coffee-react's People

Contributors

jsdf avatar ibrahima avatar arjun810 avatar johnius avatar

Watchers

Michaël Hoste avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.