paulnicholson / coffee-filter Goto Github PK
View Code? Open in Web Editor NEWCoffeeFilter is a custom haml filter for rendering coffeescript.
License: MIT License
CoffeeFilter is a custom haml filter for rendering coffeescript.
License: MIT License
Hello,
gem "coffee-script"
gem "coffee-filter", :git => "git://github.com/paulnicholson/coffee-filter.git"
gem "haml", :git => "git://github.com/nex3/haml.git"
/Users/kain/.rvm/gems/ruby-1.9.2-p180/bundler/gems/coffee-filter-1f0ad0e93c06/lib/coffee-filter/coffeescript.rb:4:in `<module:Coffeescript>': uninitialized constant Coffee::Filter::Coffeescript::Haml (NameError)
from /Users/kain/.rvm/gems/ruby-1.9.2-p180/bundler/gems/coffee-filter-1f0ad0e93c06/lib/coffee-filter/coffeescript.rb:3:in `<module:Filter>'
from /Users/kain/.rvm/gems/ruby-1.9.2-p180/bundler/gems/coffee-filter-1f0ad0e93c06/lib/coffee-filter/coffeescript.rb:2:in `<module:Coffee>'
from /Users/kain/.rvm/gems/ruby-1.9.2-p180/bundler/gems/coffee-filter-1f0ad0e93c06/lib/coffee-filter/coffeescript.rb:1:in `<top (required)>'
from /Users/kain/.rvm/gems/ruby-1.9.2-p180/bundler/gems/coffee-filter-1f0ad0e93c06/lib/coffee-filter.rb:1:in `<top (required)>'
I got this error when I upgraded to haml 4.0 release candidate:
gems/coffee-filter-0.1.2/lib/coffee-filter/coffeescript.rb:8:in `<module:Coffeescript>': undefined method `lazy_require' for Coffee::Filter::Coffeescript:Module (NoMethodError)
Looks like haml 4.0 is going to be officially released in 2 days: haml/haml-rails#38
Fortunately, it looks like it includes official support for :coffee
/ :coffeescript
filters so this gem will no longer be needed. (Thanks for providing it in the meantime though!)
I'm glad to see this gem—the various coffee-haml-filter forks were pretty undermaintained—but I'm curious: Is there any way to get around the requirement that I use a require 'coffee-filter'
from Ruby code before using the filter? If I simply do
gem install coffee-filter
haml example.haml
(where example.haml
contains your example code), I get
Haml error on line 3: Filter "coffeescript" is not defined.
Use --trace for backtrace.
Some strange errors I'm getting today when I rebooted my rails app
Anytime I use :coffeescript I get an error.
For example
:coffeescript
alert("a")
The page results in:
ExecJS::RuntimeError in Users#index
Showing /index.html.haml where line # raised:
["ok","(function() {\n\n alert("a");\n\n}).call(this);\n"]
Which is weird because it looks like the script actually converted into coffeescript, but now it's just erroring anytime. I'm using thin web server on windows, and I have execjs installed. i'm not 100% sure it's the coffee-filter, but I do know that all my other coffeescripts in external files are being loaded OK.
The code below will display a alert with whatever version of Ruby you are using. Haven't gone under the hood yet but I couldn't think of any obvious way to get Barista to parse these interpolated strings instead of Haml/Ruby.
- content_for :javascripts do
:coffeescript
alert "This is coming from Rubyland: #{RUBY_VERSION}"
When I use only numbers in the expression there is no error.
console.log "#{1+3}"
But when I use a variable in the expression, there is an error
a=3; console.log "#{a}"
The error message
ERROR: compiling /Users/praphan/Development/lab/rails3.1/hello/app/assets/haml/hello.html.haml RAISED undefined local variable or method a' for #<HamlAssets::HamlSprocketsEngine::ViewContext:0x007fa9e64d6dd0> Backtrace: (haml):3:in
block in render'
/Users/praphan/.rvm/gems/[email protected]/bundler/gems/haml-46d64d1123a9/lib/haml/engine.rb:191:in eval' /Users/praphan/.rvm/gems/[email protected]/bundler/gems/haml-46d64d1123a9/lib/haml/engine.rb:191:in
render'
/Users/praphan/.rvm/gems/[email protected]/gems/haml_assets-0.0.3/lib/haml_assets/haml_sprockets_engine.rb:40:in render_haml' /Users/praphan/.rvm/gems/[email protected]/gems/haml_assets-0.0.3/lib/haml_assets/haml_sprockets_engine.rb:28:in
evaluate'
/Users/praphan/.rvm/gems/[email protected]/gems/tilt-1.3.3/lib/tilt/template.rb:76:in render' /Users/praphan/.rvm/gems/[email protected]/gems/sprockets-2.0.3/lib/sprockets/context.rb:175:in
block in evaluate'
/Users/praphan/.rvm/gems/[email protected]/gems/sprockets-2.0.3/lib/sprockets/context.rb:172:in each' /Users/praphan/.rvm/gems/[email protected]/gems/sprockets-2.0.3/lib/sprockets/context.rb:172:in
evaluate'
/Users/praphan/.rvm/gems/[email protected]/gems/sprockets-2.0.3/lib/sprockets/bundled_asset.rb:171:in build_dependency_context_and_body' /Users/praphan/.rvm/gems/[email protected]/gems/sprockets-2.0.3/lib/sprockets/bundled_asset.rb:135:in
dependency_context'
/Users/praphan/.rvm/gems/[email protected]/gems/sprockets-2.0.3/lib/sprockets/bundled_asset.rb:194:in build_dependencies_paths_and_assets' /Users/praphan/.rvm/gems/[email protected]/gems/sprockets-2.0.3/lib/sprockets/bundled_asset.rb:141:in
dependency_paths'
/Users/praphan/.rvm/gems/[email protected]/gems/sprockets-2.0.3/lib/sprockets/bundled_asset.rb:61:in mtime' /Users/praphan/.rvm/gems/[email protected]/gems/sprockets-2.0.3/lib/sprockets/asset.rb:58:in
block in encode_with'
/Users/praphan/.rvm/gems/[email protected]/gems/sprockets-2.0.3/lib/sprockets/asset.rb:57:in each' /Users/praphan/.rvm/gems/[email protected]/gems/sprockets-2.0.3/lib/sprockets/asset.rb:57:in
encode_with'
/Users/praphan/.rvm/gems/[email protected]/gems/sprockets-2.0.3/lib/sprockets/bundled_asset.rb:43:in encode_with' /Users/praphan/.rvm/gems/[email protected]/gems/sprockets-2.0.3/lib/sprockets/caching.rb:52:in
cache_asset'
/Users/praphan/.rvm/gems/[email protected]/gems/sprockets-2.0.3/lib/sprockets/environment.rb:82:in build_asset' /Users/praphan/.rvm/gems/[email protected]/gems/sprockets-2.0.3/lib/sprockets/trail.rb:102:in
find_asset_in_path'
/Users/praphan/.rvm/gems/[email protected]/gems/sprockets-2.0.3/lib/sprockets/base.rb:101:in find_asset' /Users/praphan/.rvm/gems/[email protected]/gems/sprockets-2.0.3/lib/sprockets/environment.rb:72:in
find_asset'
/Users/praphan/.rvm/gems/[email protected]/gems/sprockets-2.0.3/lib/sprockets/server.rb:42:in call' /Users/praphan/.rvm/gems/[email protected]/gems/rack-mount-0.8.3/lib/rack/mount/prefix.rb:26:in
call'
/Users/praphan/.rvm/gems/[email protected]/gems/rack-mount-0.8.3/lib/rack/mount/route_set.rb:152:in block in call' /Users/praphan/.rvm/gems/[email protected]/gems/rack-mount-0.8.3/lib/rack/mount/code_generation.rb:96:in
block in recognize'
/Users/praphan/.rvm/gems/[email protected]/gems/rack-mount-0.8.3/lib/rack/mount/code_generation.rb:68:in optimized_each' /Users/praphan/.rvm/gems/[email protected]/gems/rack-mount-0.8.3/lib/rack/mount/code_generation.rb:95:in
recognize'
/Users/praphan/.rvm/gems/[email protected]/gems/rack-mount-0.8.3/lib/rack/mount/route_set.rb:141:in call' /Users/praphan/.rvm/gems/[email protected]/gems/actionpack-3.1.1/lib/action_dispatch/routing/route_set.rb:532:in
call'
/Users/praphan/.rvm/gems/[email protected]/gems/actionpack-3.1.1/lib/action_dispatch/middleware/best_standards_support.rb:17:in call' /Users/praphan/.rvm/gems/[email protected]/gems/rack-1.3.5/lib/rack/etag.rb:23:in
call'
/Users/praphan/.rvm/gems/[email protected]/gems/rack-1.3.5/lib/rack/conditionalget.rb:25:in call' /Users/praphan/.rvm/gems/[email protected]/gems/actionpack-3.1.1/lib/action_dispatch/middleware/head.rb:14:in
call'
/Users/praphan/.rvm/gems/[email protected]/gems/actionpack-3.1.1/lib/action_dispatch/middleware/params_parser.rb:21:in call' /Users/praphan/.rvm/gems/[email protected]/gems/actionpack-3.1.1/lib/action_dispatch/middleware/flash.rb:243:in
call'
/Users/praphan/.rvm/gems/[email protected]/gems/rack-1.3.5/lib/rack/session/abstract/id.rb:195:in context' /Users/praphan/.rvm/gems/[email protected]/gems/rack-1.3.5/lib/rack/session/abstract/id.rb:190:in
call'
/Users/praphan/.rvm/gems/[email protected]/gems/actionpack-3.1.1/lib/action_dispatch/middleware/cookies.rb:331:in call' /Users/praphan/.rvm/gems/[email protected]/gems/activerecord-3.1.1/lib/active_record/query_cache.rb:62:in
call'
/Users/praphan/.rvm/gems/[email protected]/gems/activerecord-3.1.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:477:in call' /Users/praphan/.rvm/gems/[email protected]/gems/actionpack-3.1.1/lib/action_dispatch/middleware/callbacks.rb:29:in
block in call'
/Users/praphan/.rvm/gems/[email protected]/gems/activesupport-3.1.1/lib/active_support/callbacks.rb:392:in _run_call_callbacks' /Users/praphan/.rvm/gems/[email protected]/gems/activesupport-3.1.1/lib/active_support/callbacks.rb:81:in
run_callbacks'
/Users/praphan/.rvm/gems/[email protected]/gems/actionpack-3.1.1/lib/action_dispatch/middleware/callbacks.rb:28:in call' /Users/praphan/.rvm/gems/[email protected]/gems/actionpack-3.1.1/lib/action_dispatch/middleware/reloader.rb:68:in
call'
/Users/praphan/.rvm/gems/[email protected]/gems/rack-1.3.5/lib/rack/sendfile.rb:101:in call' /Users/praphan/.rvm/gems/[email protected]/gems/actionpack-3.1.1/lib/action_dispatch/middleware/remote_ip.rb:48:in
call'
/Users/praphan/.rvm/gems/[email protected]/gems/actionpack-3.1.1/lib/action_dispatch/middleware/show_exceptions.rb:47:in call' /Users/praphan/.rvm/gems/[email protected]/gems/railties-3.1.1/lib/rails/rack/logger.rb:13:in
call'
/Users/praphan/.rvm/gems/[email protected]/gems/rack-1.3.5/lib/rack/methodoverride.rb:24:in call' /Users/praphan/.rvm/gems/[email protected]/gems/rack-1.3.5/lib/rack/runtime.rb:17:in
call'
/Users/praphan/.rvm/gems/[email protected]/gems/activesupport-3.1.1/lib/active_support/cache/strategy/local_cache.rb:72:in call' /Users/praphan/.rvm/gems/[email protected]/gems/rack-1.3.5/lib/rack/lock.rb:15:in
call'
/Users/praphan/.rvm/gems/[email protected]/gems/actionpack-3.1.1/lib/action_dispatch/middleware/static.rb:53:in call' /Users/praphan/.rvm/gems/[email protected]/gems/railties-3.1.1/lib/rails/engine.rb:456:in
call'
/Users/praphan/.rvm/gems/[email protected]/gems/railties-3.1.1/lib/rails/rack/content_length.rb:16:in call' /Users/praphan/.rvm/gems/[email protected]/gems/railties-3.1.1/lib/rails/rack/log_tailer.rb:14:in
call'
/Users/praphan/.rvm/gems/[email protected]/gems/rack-1.3.5/lib/rack/handler/mongrel.rb:77:in process' /Users/praphan/.rvm/gems/[email protected]/gems/mongrel-1.2.0.pre2/lib/mongrel.rb:165:in
block in process_client'
/Users/praphan/.rvm/gems/[email protected]/gems/mongrel-1.2.0.pre2/lib/mongrel.rb:164:in each' /Users/praphan/.rvm/gems/[email protected]/gems/mongrel-1.2.0.pre2/lib/mongrel.rb:164:in
process_client'
/Users/praphan/.rvm/gems/[email protected]/gems/mongrel-1.2.0.pre2/lib/mongrel.rb:291:in `block (2 levels) in run'
Compiled hello.html (6ms) (pid 8920)
Served asset /hello.html - 200 OK (10ms)
I use Rails 3.1.1
My GemFile
gem 'mongrel'
gem 'haml_assets'
gem 'ejs'
gem "haml"
gem "coffee-filter"
gem 'guard-livereload'
Is there a way that it can be used in helpers?
like this:
coffee_filter_tag("alert 'tag created' if 1=1")
Hello
I have a following problem. I'm using HAML views in my rails app and i wanted to use some coffeescript in them. I added Barista to my gemfile:
gem 'haml'
gem 'coffee-filter'
and ran bundle install.
But when I try to use :coffeescript filter I get:
Haml::Error in carts#index
Showing /home/jesha/ror/prefab/app/views/carts/index.html.haml where line #7 raised:
Filter "coffeescript" is not defined.
Extracted source (around line #7):
4:
5: %br
6:
7: :coffeescript
8: alert("test")
9:
10: %table
Do you know what am I doing wrong?
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.