Sha256: 1d4a443033748248118dae18ef39a7cb84529794a1ec8e441d09a0c65dcf8006

Contents?: true

Size: 703 Bytes

Versions: 68

Compression:

Stored size: 703 Bytes

Contents

# Example usage:
#
#   $ echo gem 'ruby2js', require: 'ruby2js/rails' > Gemfile
#   $ bundle update
#   $ rails generate controller Say hello
#   $ echo 'alert "Hello world!"' > app/views/say/hello.js.rb
#   $ rails server
#   $ curl http://localhost:3000/say/hello.js
#
# Using an optional filter:
#
#   $ echo 'require "ruby2js/filter/functions"' > config/initializers/ruby2js.rb

require 'ruby2js'

module Ruby2JS
  module Rails
    class Template
      cattr_accessor :default_format
      self.default_format = Mime::JS
      def self.call(template)
        "Ruby2JS.convert(#{template.source.inspect})"
      end
    end

    ActionView::Template.register_template_handler :rb, Template
  end
end

Version data entries

68 entries across 68 versions & 1 rubygems

Version Path
ruby2js-2.1.21 lib/ruby2js/rails.rb
ruby2js-2.1.20 lib/ruby2js/rails.rb
ruby2js-2.1.19 lib/ruby2js/rails.rb
ruby2js-2.1.18 lib/ruby2js/rails.rb
ruby2js-2.1.17 lib/ruby2js/rails.rb
ruby2js-2.1.16 lib/ruby2js/rails.rb
ruby2js-2.1.15 lib/ruby2js/rails.rb
ruby2js-2.1.14 lib/ruby2js/rails.rb
ruby2js-2.1.13 lib/ruby2js/rails.rb
ruby2js-2.1.12 lib/ruby2js/rails.rb
ruby2js-2.1.11 lib/ruby2js/rails.rb
ruby2js-2.1.10 lib/ruby2js/rails.rb
ruby2js-2.1.9 lib/ruby2js/rails.rb
ruby2js-2.1.8 lib/ruby2js/rails.rb
ruby2js-2.1.7 lib/ruby2js/rails.rb
ruby2js-2.1.6 lib/ruby2js/rails.rb
ruby2js-2.1.5 lib/ruby2js/rails.rb
ruby2js-2.1.4 lib/ruby2js/rails.rb
ruby2js-2.1.3 lib/ruby2js/rails.rb
ruby2js-2.1.2 lib/ruby2js/rails.rb