Last active
December 14, 2015 14:18
-
-
Save laod/5099827 to your computer and use it in GitHub Desktop.
Opal fun - Opal::Server version:
config.ru that made the current version of opal work for me. Put your files (whatever.js.opal or whatever.js.rb) in the assets directory. Change s.main to the name of the appropriate js.opal file. rackup. Enjoy. Some parts may be redundant. Investigating. Non-server version: convert.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'opal' | |
run Opal::Server.new { |s| | |
s.main = 'doi' | |
e = s.sprockets | |
e.append_path 'assets' | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
require 'opal' | |
require 'opal-jquery' | |
require 'sprockets' | |
e = Sprockets::Environment.new | |
e.append_path 'src' | |
e.register_engine '.opal', Opal::Processor | |
e.register_engine '.rb', Opal::Processor | |
Opal.paths.each{|p| e.append_path p} | |
# parse and emit src/doi.js.rb | |
puts e['doi.js'].to_s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//= require jquery.min.js | |
require 'opal' | |
require 'opal-jquery' | |
Document.ready? { | |
Element["body"].append [1,2,3,4,5].map{|i| i*2}.reduce(0){|m,v| m+v} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
assets is probably a poor choice of name for the directory, since it has so much rails baggage.