All Projects → falm → js-namespace-rails

falm / js-namespace-rails

Licence: other
js-namespace-rails let you choose which javascript snippet can execute in rails assets pipeline

Programming Languages

ruby
36898 projects - #4 most used programming language
HTML
75241 projects
javascript
184084 projects - #8 most used programming language
CSS
56736 projects
shell
77523 projects

Projects that are alternatives of or similar to js-namespace-rails

furatto-rails
Furatto CSS Framework for Rails Asset Pipeline
Stars: ✭ 36 (-36.84%)
Mutual labels:  assets, rails-asset-pipeline
opendev
OpenDev is a non-profit project that tries to collect as many resources (assets) of free use for the development of video games and applications.
Stars: ✭ 34 (-40.35%)
Mutual labels:  assets
laravel-assets
Laravel Assets manager
Stars: ✭ 13 (-77.19%)
Mutual labels:  assets
Unity-delayed-asset
**DEPRECATED** Plugin for Unity that allows to assign assets in the inspector while preventing Unity from automatically loading the assets in memory when a scene is loaded
Stars: ✭ 19 (-66.67%)
Mutual labels:  assets
assets
Assets management
Stars: ✭ 17 (-70.18%)
Mutual labels:  assets
Unity NormalVisualizerWithGizmo
Visualize normal on vertex or surface with Gizmo.
Stars: ✭ 38 (-33.33%)
Mutual labels:  assets
Unity TransparentWindowManager
Make Unity's window transparent and overlay on desktop.
Stars: ✭ 91 (+59.65%)
Mutual labels:  assets
core
🔥 Antares Core Implemenation. Most important project layer, this is the heart for your app. ACL, notifiter, console, geoip, areas, utils and many more...
Stars: ✭ 24 (-57.89%)
Mutual labels:  assets
fingerprint-brunch
A brunch plugin for cache busting assets
Stars: ✭ 15 (-73.68%)
Mutual labels:  assets
ProjectCleaner
Unreal engine plugin for managing all unused assets and empty folders in project.
Stars: ✭ 53 (-7.02%)
Mutual labels:  assets
proposal-symbol-thenable
gus.host/proposal-symbol-thenable
Stars: ✭ 18 (-68.42%)
Mutual labels:  namespace
lxroot
A lightweight, flexible, and safer alternative to chroot and/or Docker.
Stars: ✭ 69 (+21.05%)
Mutual labels:  namespace
disclosedassets
DEPRECATED Allow your clients to find asset sub-folders by disclosing them by default
Stars: ✭ 13 (-77.19%)
Mutual labels:  assets
SecureAssetDownload
Craft CMS plugin for secure asset download URLs
Stars: ✭ 22 (-61.4%)
Mutual labels:  assets
django-webpack-starter
Django Webpack starter template for using Webpack 5 with Django 3.1 & Bootstrap 4. Yes, it can hot-reload.
Stars: ✭ 52 (-8.77%)
Mutual labels:  assets
RxAssetManager
An RxJava2 implementation of the Android AssetManager.
Stars: ✭ 53 (-7.02%)
Mutual labels:  assets
fastify-bankai
Bankai assets compiler for Fastify
Stars: ✭ 15 (-73.68%)
Mutual labels:  assets
numerifides
A proposal for a system of decentralized trust, built on an open, public blockchain.
Stars: ✭ 14 (-75.44%)
Mutual labels:  namespace
koko
Connect containers as point-to-point connection, using veth/vxlan/vlan/macvlan
Stars: ✭ 77 (+35.09%)
Mutual labels:  namespace
Stamp-Craft
Plugin for adding timestamp to filenames.
Stars: ✭ 28 (-50.88%)
Mutual labels:  assets

JsNamespaceRails Build Status Coverage Status Code Climate Dependency Status Gem Version

Rails's asset pipeline compiles all of js file into a single file which is executed on all pages. There has a problem, some time we want to execute selective code on specific page, but asset pipeline doesn't support. js-namespace-rails can handle this problem by using it's method to namespace and selectively execute certain javascript depending on which Rails controller action is active.

Installation

Add this line to your application's Gemfile:

gem 'js-namespace-rails'

Setup

Require js-namespace-rails file in application.js or other main file, notice js-namespace-rails has no dependency

//= require js-namespace-rails

Usage

Assume your project have articles_controller

class ArticlesController < ApplicationController
  def index
  end
end

And its corresponding js file app/assets/javascripts/articles.js.erb

then you just need to write below into the js file

// app/assets/javascripts/articles.js.erb
JsSpace.on('articles', {
  init: function(){
  	console.log('common logic of article in here');
  },
  index: function(){
  	console.log('logic of index action in here');
  }
});

Feature

Passing Parameters to js

class ArticlesController < ApplicationController
  def show
    @article = Article.find(params[:id])
    js author: @article.author
    # also you can passing an object
    js article: @article
  end
end
// app/assets/javascripts/articles.js.erb
JsSpace.on('articles', {
  show: function(){
    console.log(this.params.author); // get author from params
    console.log(this.params.article.title); // get title of article
  }
});

License

MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].