yury / coffee-views Goto Github PK
View Code? Open in Web Editor NEWCoffeeScript in your views
License: MIT License
CoffeeScript in your views
License: MIT License
The following code produces strange javascript:
Coffeescript:
test =
"<%='key'%>": <%='value'%>
Generated code:
test = {
"`"key"`": "value"
};
Expected code:
test = {
"key": "value"
};
Also using "raw" output does not work, it produces:
test = {
"`key`": "value"
};
The following code generates a parse error:
test =
"<%="key"%>": <%='value'%>
Unfortunately, we had this old gem in a application, which we upgraded from 5.2 to 6.0.
Due to the same issue described in rspec/rspec-rails#2086 we monkey patched coffee-views to make it work again. Feel free to implement it, if you need it.
# Monkey patch for rails 6.
# The fix was adopted from the fix by rspec.
# https://github.com/rspec/rspec-rails/issues/2086
# https://github.com/rails/rails/commit/28f88e0074f473f58c2d3fd54cb3daff81027c12#diff-562906215bf781788ec5aaf37e958cb8
# https://github.com/yury/coffee-views/blob/master/lib/coffee_views/rails.rb#L29
CoffeeViews::Rails::TemplateHandler.class_eval do
def self.call(template)
source = compile_coffee(template.source)
template.instance_variable_set :@source, source
erb_handler.call(template, _source = source)
end
end
If the coffee-views
gem is put before the slim
gem in the Gemfile the filter does not register.
This should either be documented or fixed :)
After a recent bundle update, I'm getting this:
5: from /usr/local/lib/ruby/gems/2.5.0/gems/coffee-views-0.2.0/lib/coffee_views/slim.rb:5:in `block in <main>'
4: from /usr/local/lib/ruby/gems/2.5.0/gems/coffee-views-0.2.0/lib/coffee_views/slim.rb:6:in `<module:CoffeeViews>'
3: from /usr/local/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/active_support.rb:42:in `load_missing_constant'
2: from /usr/local/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/active_support.rb:53:in `rescue in load_missing_constant'
1: from /usr/local/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/active_support.rb:8:in `without_bootsnap_cache'
/usr/local/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/active_support.rb:53:in `block in load_missing_constant': uninitialized constant Slim::Embedded::ERBEngine (NameError)
Any ideas?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.