kea-rails-loader
This is an experimental module. Do not use with anything serious.
Given a rails controller that includes Kea::Controller
from kea-on-rails
like this:
# at /app/scenes/search/result/controller.rb include Kea::Controller @user = User.find(params[:id]) render json: { id: @user.id, name: @user.full_name, reputation: @user.reputation } endend
Import and use it through webpack like this:
// at /app/scenes/search/result/reputation.js controller
In your webpack config:
module: loaders: test: /\.rb$/ loader: 'kea-rails-loader'
Optional arguments for loader with defaults: ?camelize=true&engine=$&endpoint=/_kea.json
camelize
- should the function names be camelized? endpoint.add_favourite()
gets turned into endpoint.addFavourite()
engine
- what to use to do the request. Currently only $
and jQuery
are supported. $
is the default. The engine must be globally exposed to the loader.
endpoint
- where does the kea-on-rails
counterpart live?