Class: ComponentHandler
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(component_paths) ⇒ ComponentHandler
constructor
A new instance of ComponentHandler.
Constructor Details
#initialize(component_paths) ⇒ ComponentHandler
Returns a new instance of ComponentHandler.
6 7 8 |
# File 'lib/volt/server/component_handler.rb', line 6 def initialize(component_paths) @component_paths = component_paths end |
Instance Method Details
#call(env) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/volt/server/component_handler.rb', line 10 def call(env) req = Rack::Request.new(env) # TODO: Sanatize template path component_name = req.path.strip.gsub(/^\/components\//, '').gsub(/[.]js$/, '') code = ComponentCode.new(component_name, @component_paths).code javascript_code = Opal.compile(code) # puts "ENV: #{env.inspect}" [200, {"Content-Type" => "text/html"}, StringIO.new(javascript_code)] end |