opal / opal-jquery

jQuery for Opal
https://github.com/opal/opal-jquery#readme
MIT License
186 stars 63 forks source link

html from file? #71

Closed cj closed 7 years ago

cj commented 9 years ago

Would there be anyway to grab the contents from a file and add a method like html_file https://github.com/opal/opal-jquery/blob/6d864fb0dfa0a5cd399f1a46bfa2e24fcb257768/lib/opal/jquery/rspec.rb#L50 ?

adambeynon commented 9 years ago

At runtime, we don't have access to the filesystem. One alternative option is to use a .haml or .erb file, which are already supported in the build system, and add a helper which renders those templates and adds them to the DOM.

cj commented 9 years ago

@adambeynon so I already have an index.html.erb file:

<!DOCTYPE html>
<html>
<head>
</head>
<body>
  <%= javascript_include_tag 'public/vendor/jquery/jquery' %>
  <%= javascript_include_tag 'bower_components/fine-uploader/_build/s3.jquery.fine-uploader' %>
  <%= javascript_include_tag @server.main %>
</body>
</html>

using:

Opal::RSpec::RakeTask.new('opal:rspec') do |s|
  s.index_path = 'spec/index.html.erb'
end

So are you talking about adding a helper like javascript_include_tag ? If so would you be able to handle an html file per test? Maybe linking the name of the test file to an html file? i.e.

load_html({
  'uploader_spec' => 'public/uploader.html'
})
elia commented 9 years ago

@cj did you resolve this somehow?