Skip to content

Require does not work on *.haml files on Windows #7

@magynhard

Description

@magynhard

Hi there,

I'm playing with ruby at the moment and decided to do with opal.

With *.opalerb templates everything works fine.
But I wanted to use haml templates, but it does not work.

Seems that what u call to "add *.haml" to sprockets does not work. Maybe a Windows related problem?

Here is my sample app:

# app/application.rb
require 'opal'
require 'jquery'
require 'opal-jquery'

# require views/example.haml
require 'views/example'

# require views/example2.opalerb - working fine!
require 'views/example2'

Document.ready? do
  template = Template['views/example']
  puts template.render(Example.new)
end

I added opal-haml to the Gemfile and did bundle install. I tried the gem from rubygems as well as the github version. The behaviour is the same.

This is my rakefile

# Rakefile
require 'opal'
require 'opal-jquery'
require 'sass'

desc "Build our app - transpiling rb to js and scss to css and copying some files ..."
task :build do

  Opal.append_path "app"
  Opal.append_path "app/views"
  Opal.append_path "app/class"

  #
  # FRONTEND JS
  #

  js_container = ""

  # RUBY -> JS
  js_container << Opal::Builder.build("application").to_s

  File.binwrite "public/lib/app.js", js_container

  #
  # FRONTEND CSS
  #

  css_container = ""

  # SASS/SCSS -> CSS
  sass_file = File.read "app/assets/stylesheets/application.scss"
  sass_engine = Sass::Engine.new sass_file, { :load_paths => [ "app/assets/stylesheets" ], :syntax => :scss }
  css_container << sass_engine.render {}

  # FONT AWESOME
  fa_file = File.read "app/lib/font-awesome-4.5.0/css/font-awesome.min.css"
  css_container << fa_file
  FileUtils::cp_r "app/lib/font-awesome-4.5.0/fonts/.","public/fonts"

  File.binwrite "public/lib/app.css", css_container

  puts "... finished"
end

When i execute rake build i get the following output:

** Invoke build (first_time)
** Execute build
rake aborted!
Opal::Builder::MissingRequire: A file required by "application" wasn't found.
can't find file: "views/example" in ["C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/opal-0.9.0/opal", "C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/opal-0.9.0/stdlib",
"C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/opal-0.9.0/lib", "C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/opal-jquery-0.4.1/lib", "D:/project/example/app", "D:/project/example/app/views", "D:/project/example/app/class"]
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/opal-0.9.0/lib/opal/builder.rb:118:in `read'
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/opal-0.9.0/lib/opal/builder.rb:127:in `process_require'
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/opal-0.9.0/lib/opal/builder.rb:42:in `block in build_str'
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/opal-0.9.0/lib/opal/builder.rb:42:in `map'
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/opal-0.9.0/lib/opal/builder.rb:42:in `build_str'
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/opal-0.9.0/lib/opal/builder.rb:35:in `build'
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/opal-0.9.0/lib/opal/builder.rb:30:in `build'
D:/project/example/rakefile.rb:25:in `block in <top (required)>'
C:/Ruby22-x64/lib/ruby/2.2.0/rake/task.rb:240:in `call'
C:/Ruby22-x64/lib/ruby/2.2.0/rake/task.rb:240:in `block in execute'
C:/Ruby22-x64/lib/ruby/2.2.0/rake/task.rb:235:in `each'
C:/Ruby22-x64/lib/ruby/2.2.0/rake/task.rb:235:in `execute'
C:/Ruby22-x64/lib/ruby/2.2.0/rake/task.rb:179:in `block in invoke_with_call_chain'
C:/Ruby22-x64/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
C:/Ruby22-x64/lib/ruby/2.2.0/rake/task.rb:172:in `invoke_with_call_chain'
C:/Ruby22-x64/lib/ruby/2.2.0/rake/task.rb:165:in `invoke'
C:/Ruby22-x64/lib/ruby/2.2.0/rake/application.rb:150:in `invoke_task'
C:/Ruby22-x64/lib/ruby/2.2.0/rake/application.rb:106:in `block (2 levels) in top_level'
C:/Ruby22-x64/lib/ruby/2.2.0/rake/application.rb:106:in `each'
C:/Ruby22-x64/lib/ruby/2.2.0/rake/application.rb:106:in `block in top_level'
C:/Ruby22-x64/lib/ruby/2.2.0/rake/application.rb:115:in `run_with_threads'
C:/Ruby22-x64/lib/ruby/2.2.0/rake/application.rb:100:in `top_level'
C:/Ruby22-x64/lib/ruby/2.2.0/rake/application.rb:78:in `block in run'
C:/Ruby22-x64/lib/ruby/2.2.0/rake/application.rb:176:in `standard_exception_handling'
C:/Ruby22-x64/lib/ruby/2.2.0/rake/application.rb:75:in `run'
C:/Ruby22-x64/bin/rake:33:in `<main>'
Opal::Builder::MissingRequire: can't find file: "views/example" in ["C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/opal-0.9.0/opal", "C:/Ruby22-x64/lib/ruby/gems/
2.2.0/gems/opal-0.9.0/stdlib", "C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/opal-0.9.0/lib", "C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/opal-jquery-0.4.1/lib", "
D:/project/example/app", "D:/project/example/app/views", "D:/FIRMA_MGH/PROJEKTE/_INTERN/_webg
ames/rubymaze/app/class"]
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/opal-0.9.0/lib/opal/builder.rb:118:in `read'
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/opal-0.9.0/lib/opal/builder.rb:127:in `process_require'
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/opal-0.9.0/lib/opal/builder.rb:42:in `block in build_str'
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/opal-0.9.0/lib/opal/builder.rb:42:in `map'
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/opal-0.9.0/lib/opal/builder.rb:42:in `build_str'
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/opal-0.9.0/lib/opal/builder.rb:35:in `build'
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/opal-0.9.0/lib/opal/builder.rb:30:in `build'
D:/project/example/rakefile.rb:25:in `block in <top (required)>'
C:/Ruby22-x64/lib/ruby/2.2.0/rake/task.rb:240:in `call'
C:/Ruby22-x64/lib/ruby/2.2.0/rake/task.rb:240:in `block in execute'
C:/Ruby22-x64/lib/ruby/2.2.0/rake/task.rb:235:in `each'
C:/Ruby22-x64/lib/ruby/2.2.0/rake/task.rb:235:in `execute'
C:/Ruby22-x64/lib/ruby/2.2.0/rake/task.rb:179:in `block in invoke_with_call_chain'
C:/Ruby22-x64/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
C:/Ruby22-x64/lib/ruby/2.2.0/rake/task.rb:172:in `invoke_with_call_chain'
C:/Ruby22-x64/lib/ruby/2.2.0/rake/task.rb:165:in `invoke'
C:/Ruby22-x64/lib/ruby/2.2.0/rake/application.rb:150:in `invoke_task'
C:/Ruby22-x64/lib/ruby/2.2.0/rake/application.rb:106:in `block (2 levels) in top_level'
C:/Ruby22-x64/lib/ruby/2.2.0/rake/application.rb:106:in `each'
C:/Ruby22-x64/lib/ruby/2.2.0/rake/application.rb:106:in `block in top_level'
C:/Ruby22-x64/lib/ruby/2.2.0/rake/application.rb:115:in `run_with_threads'
C:/Ruby22-x64/lib/ruby/2.2.0/rake/application.rb:100:in `top_level'
C:/Ruby22-x64/lib/ruby/2.2.0/rake/application.rb:78:in `block in run'
C:/Ruby22-x64/lib/ruby/2.2.0/rake/application.rb:176:in `standard_exception_handling'
C:/Ruby22-x64/lib/ruby/2.2.0/rake/application.rb:75:in `run'
C:/Ruby22-x64/bin/rake:33:in `<main>'
Tasks: TOP => build

Ruby x64 @ Win7 x64

Any idea?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions