Skip to content

Instantly share code, notes, and snippets.

@cj

cj/component.rb Secret

Created January 16, 2015 20:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cj/8e363e15ab9b3db0c775 to your computer and use it in GitHub Desktop.
Save cj/8e363e15ab9b3db0c775 to your computer and use it in GitHub Desktop.
opal = Opal::Server.new do |s|
# Append the gems path
s.debug = true
s.source_map = true
s.append_path Gem::Specification.find_by_name("roda-component").gem_dir + '/lib'
# Append the path to the components folder
s.append_path scope.component_opts[:path]
s.main = 'roda/component'
end
on self.class.component_assets_route_regex do |component, action|
path = scope.request.env['REQUEST_PATH']
if path[/\.js\Z/]
run opal.sprockets
else
run Opal::SourceMapServer.new(opal.sprockets, path)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment