Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when using .html.erb in assets pipeline while slim-rails is installed #145

Open
ivan-kolmychek opened this issue Apr 24, 2017 · 2 comments

Comments

@ivan-kolmychek
Copy link

Setup:

  • Rails 5.0.2
  • Sprockets 3.7.1
  • Slim 3.0.7
  • slim-rails 3.1.2
  • Some ERB pages in assets/html/ (like 404.html.erb, you can just copy default Rails 404 page and name it 404.html.erb).

Without slim-rails:

$ bundle exec rails tmp:cache:clear assets:clobber assets:precompile
(works fine)

With slim-rails (please ignore the fact that path is absolute, it's being run in container):

$ bundle exec rails tmp:cache:clear assets:clobber assets:precompile
warning: parser/current is loading parser/ruby24, which recognizes
warning: 2.4.0-compliant syntax, but you are running 2.4.1.
warning: please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.
I, [2017-04-24T19:34:09.301413 #26473]  INFO -- : Removed /app/public/assets
rails aborted!
Slim::Parser::SyntaxError: Expected attribute
  404, Line 12, Column 17
    font-family: "Raleway", sans-serif;
                 ^
404:12
/app/vendor/bundle/gems/slim-3.0.7/lib/slim/parser.rb:513:in `syntax_error!'
/app/vendor/bundle/gems/slim-3.0.7/lib/slim/parser.rb:451:in `parse_attributes'
/app/vendor/bundle/gems/slim-3.0.7/lib/slim/parser.rb:352:in `parse_tag'
/app/vendor/bundle/gems/slim-3.0.7/lib/slim/parser.rb:248:in `parse_line_indicators'
/app/vendor/bundle/gems/slim-3.0.7/lib/slim/parser.rb:192:in `parse_line'
/app/vendor/bundle/gems/slim-3.0.7/lib/slim/parser.rb:95:in `call'
/app/vendor/bundle/gems/temple-0.7.7/lib/temple/engine.rb:50:in `block in call'
/app/vendor/bundle/gems/temple-0.7.7/lib/temple/engine.rb:50:in `each'
/app/vendor/bundle/gems/temple-0.7.7/lib/temple/engine.rb:50:in `inject'
/app/vendor/bundle/gems/temple-0.7.7/lib/temple/engine.rb:50:in `call'
/app/vendor/bundle/gems/temple-0.7.7/lib/temple/mixins/template.rb:10:in `compile'
/app/vendor/bundle/gems/temple-0.7.7/lib/temple/templates/tilt.rb:30:in `prepare'
/app/vendor/bundle/gems/tilt-2.0.7/lib/tilt/template.rb:99:in `initialize'
/app/vendor/bundle/gems/slim-rails-3.1.2/lib/slim-rails/register_engine.rb:6:in `new'
/app/vendor/bundle/gems/slim-rails-3.1.2/lib/slim-rails/register_engine.rb:6:in `call'
/app/vendor/bundle/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:75:in `call_processor'
/app/vendor/bundle/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:57:in `block in call_processors'
/app/vendor/bundle/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:56:in `reverse_each'
/app/vendor/bundle/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:56:in `call_processors'
/app/vendor/bundle/gems/sprockets-3.7.1/lib/sprockets/loader.rb:134:in `load_from_unloaded'
/app/vendor/bundle/gems/sprockets-3.7.1/lib/sprockets/loader.rb:60:in `block in load'
/app/vendor/bundle/gems/sprockets-3.7.1/lib/sprockets/loader.rb:317:in `fetch_asset_from_dependency_cache'
/app/vendor/bundle/gems/sprockets-3.7.1/lib/sprockets/loader.rb:44:in `load'
/app/vendor/bundle/gems/sprockets-3.7.1/lib/sprockets/cached_environment.rb:20:in `block in initialize'
/app/vendor/bundle/gems/sprockets-3.7.1/lib/sprockets/cached_environment.rb:47:in `load'
/app/vendor/bundle/gems/sprockets-3.7.1/lib/sprockets/base.rb:66:in `find_asset'
/app/vendor/bundle/gems/sprockets-3.7.1/lib/sprockets/base.rb:73:in `find_all_linked_assets'
/app/vendor/bundle/gems/sprockets-3.7.1/lib/sprockets/manifest.rb:142:in `block in find'
/app/vendor/bundle/gems/sprockets-3.7.1/lib/sprockets/legacy.rb:114:in `block (2 levels) in logical_paths'
/app/vendor/bundle/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:228:in `block in stat_tree'
/app/vendor/bundle/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:212:in `block in stat_directory'
/app/vendor/bundle/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:209:in `each'
/app/vendor/bundle/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:209:in `stat_directory'
/app/vendor/bundle/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:227:in `stat_tree'
/app/vendor/bundle/gems/sprockets-3.7.1/lib/sprockets/legacy.rb:105:in `each'
/app/vendor/bundle/gems/sprockets-3.7.1/lib/sprockets/legacy.rb:105:in `block in logical_paths'
/app/vendor/bundle/gems/sprockets-3.7.1/lib/sprockets/legacy.rb:104:in `each'
/app/vendor/bundle/gems/sprockets-3.7.1/lib/sprockets/legacy.rb:104:in `logical_paths'
/app/vendor/bundle/gems/sprockets-3.7.1/lib/sprockets/manifest.rb:140:in `find'
/app/vendor/bundle/gems/sprockets-3.7.1/lib/sprockets/manifest.rb:185:in `compile'
/app/vendor/bundle/gems/sprockets-rails-3.2.0/lib/sprockets/rails/task.rb:68:in `block (3 levels) in define'
/app/vendor/bundle/gems/sprockets-3.7.1/lib/rake/sprocketstask.rb:147:in `with_logger'
/app/vendor/bundle/gems/sprockets-rails-3.2.0/lib/sprockets/rails/task.rb:67:in `block (2 levels) in define'
/app/vendor/bundle/gems/airbrake-6.0.0/lib/airbrake/rake/task_ext.rb:19:in `execute'
/app/vendor/bundle/gems/railties-5.0.2/lib/rails/commands/rake_proxy.rb:14:in `block in run_rake_task'
/app/vendor/bundle/gems/railties-5.0.2/lib/rails/commands/rake_proxy.rb:11:in `run_rake_task'
/app/vendor/bundle/gems/railties-5.0.2/lib/rails/commands/commands_tasks.rb:51:in `run_command!'
/app/vendor/bundle/gems/railties-5.0.2/lib/rails/commands.rb:18:in `<top (required)>'
/app/bin/rails:9:in `require'
/app/bin/rails:9:in `<top (required)>'
/app/vendor/bundle/gems/spring-2.0.1/lib/spring/client/rails.rb:28:in `load'
/app/vendor/bundle/gems/spring-2.0.1/lib/spring/client/rails.rb:28:in `call'
/app/vendor/bundle/gems/spring-2.0.1/lib/spring/client/command.rb:7:in `call'
/app/vendor/bundle/gems/spring-2.0.1/lib/spring/client.rb:30:in `run'
/app/vendor/bundle/gems/spring-2.0.1/bin/spring:49:in `<top (required)>'
/app/vendor/bundle/gems/spring-2.0.1/lib/spring/binstub.rb:31:in `load'
/app/vendor/bundle/gems/spring-2.0.1/lib/spring/binstub.rb:31:in `<top (required)>'
/app/bin/spring:15:in `require'
/app/bin/spring:15:in `<top (required)>'
bin/rails:3:in `load'
bin/rails:3:in `<main>'
Tasks: TOP => assets:precompile
(See full trace by running task with --trace)

The line that Slim complains about is actually an inline style. Still seeing this error with or without type specified in style tag.

Extracting inline styles to their own .css files works as a work-around.

Do you have any idea why Rails tries to use Slim to parse inline CSS?

@ivan-kolmychek
Copy link
Author

The "extracting styles to their own files" works fine with me so feel free to close this issue if it's a not an issue or wontfix.

I decided to post it anyway because:

  • I'm not sure is that an intended behavior or not
  • Someone else may run into the similar issue, this may help them

@januszm
Copy link
Contributor

januszm commented Oct 5, 2017

@ivan-kolmychek we released version 3.1.3, please upgrade and re-test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants