0.0
No commit activity in last 3 years
No release in over 3 years
Avoid JS mayhem on your Rails app! js-initializers is an engine that adds a micro-framework for initializing and organizing client-side logic in a modular way
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.7
~> 10.0

Runtime

> 3.1
 Project Readme

js-initializers

Rails engine that provides a micro-framework for organizing in a modular way your client-side scripts, as well as it enables you to only run the necessary modules for each page.

(Better readme coming soon!)

Usage

Add js-initializers to your Gemfile

# Gemfile
gem 'js-initializers'

Add js-initializers to your Sprockets manifest:

//= require js-initializers

Et voilĂ ! You're ready to add your initializers:

// app/assets/javascripts/initializers/rickroll.js
(function($) {
  function isRickrollable() {
    return window.user !== 'admin';
  }

  function rickroll() {
    $('a').on('click', function() { window.location = 'www.youtube.com/watch?v=dQw4w9WgXcQ'; return false; });
  }

  Initializers.register('rickroll', rickroll, isRickrollable);
}(jQuery));

For further instructions on how to use this library and defining your own initializers, you may refer to the source code of js-initializers.js.

Contributing

Contributions are welcome! Just fork, commit and send a pull request :)

Author

This skinny gem is brought to you by Nahuel Cuesta Luengo. You may reach him at @ncuestal on Twitter or by email at nahuelcuestaluengo@gmail.com.