From 1f0ad0e93c0689911601f5d62ef5b4284af23bc5 Mon Sep 17 00:00:00 2001 From: Paul Nicholson Date: Fri, 29 Apr 2011 14:07:18 -0400 Subject: [PATCH] coffeescript filter for haml --- .gitignore | 4 ++++ Gemfile | 4 ++++ MIT-LICENSE | 21 +++++++++++++++++++ README.rdoc | 35 +++++++++++++++++++++++++++++++ Rakefile | 2 ++ coffee-filter.gemspec | 23 ++++++++++++++++++++ lib/coffee-filter.rb | 6 ++++++ lib/coffee-filter/coffeescript.rb | 20 ++++++++++++++++++ lib/coffee-filter/version.rb | 5 +++++ 9 files changed, 120 insertions(+) create mode 100644 .gitignore create mode 100644 Gemfile create mode 100644 MIT-LICENSE create mode 100644 README.rdoc create mode 100644 Rakefile create mode 100644 coffee-filter.gemspec create mode 100644 lib/coffee-filter.rb create mode 100644 lib/coffee-filter/coffeescript.rb create mode 100644 lib/coffee-filter/version.rb diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4040c6c --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +*.gem +.bundle +Gemfile.lock +pkg/* diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..96c3008 --- /dev/null +++ b/Gemfile @@ -0,0 +1,4 @@ +source "http://rubygems.org" + +# Specify your gem's dependencies in coffee-filter.gemspec +gemspec diff --git a/MIT-LICENSE b/MIT-LICENSE new file mode 100644 index 0000000..844b74b --- /dev/null +++ b/MIT-LICENSE @@ -0,0 +1,21 @@ +Copyright (c) 2011 Paul Nicholson + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + diff --git a/README.rdoc b/README.rdoc new file mode 100644 index 0000000..0cb9734 --- /dev/null +++ b/README.rdoc @@ -0,0 +1,35 @@ +=== What is coffee-filter? +Coffee-filter provides a custom haml filter allowing you to inline coffeescript in your haml templates. +It was inspired by Ivan Nemytchenko's coffee-haml-filter but I wanted an installable gem and "coffeescript" as the filter name. + +=== Example +Haml: + + %div + stuff + :coffeescript + alert 'here' + +Html: + +
+ stuff + +
+ +=== Installation +Add the following to your Gemfile: + + gem 'coffee-filter' + + +Copyright (c) 2011 Paul Nicholson, released under the MIT license + + diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..14cfe0b --- /dev/null +++ b/Rakefile @@ -0,0 +1,2 @@ +require 'bundler' +Bundler::GemHelper.install_tasks diff --git a/coffee-filter.gemspec b/coffee-filter.gemspec new file mode 100644 index 0000000..276ce0f --- /dev/null +++ b/coffee-filter.gemspec @@ -0,0 +1,23 @@ +# -*- encoding: utf-8 -*- +$:.push File.expand_path("../lib", __FILE__) +require "coffee-filter/version" + +Gem::Specification.new do |s| + s.name = "coffee-filter" + s.version = Coffee::Filter::VERSION + s.platform = Gem::Platform::RUBY + s.authors = ["Paul Nicholson"] + s.email = ["paul@webpowerdesign.net"] + s.homepage = "http://github.com/paulnicholson/coffee-filter" + s.summary = %q{CoffeeFilter is a custom haml filter for rendering coffeescript.} + s.description = %q{CoffeeFilter is a custom haml filter for rendering coffeescript inside your haml templates. It was inspired by Ivan Nemytchenko's coffee-haml-filter but I wanted an installable gem and coffeescript as the filter name.} + + s.rubyforge_project = "coffee-filter" + s.add_dependency('haml', '>= 3.0.18') + s.add_dependency('coffee-script', '>= 2.2.0') + + s.files = `git ls-files`.split("\n") + s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") + s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } + s.require_paths = ["lib"] +end diff --git a/lib/coffee-filter.rb b/lib/coffee-filter.rb new file mode 100644 index 0000000..d2d74c1 --- /dev/null +++ b/lib/coffee-filter.rb @@ -0,0 +1,6 @@ +require 'coffee-filter/coffeescript' + +module Coffee + module Filter + end +end diff --git a/lib/coffee-filter/coffeescript.rb b/lib/coffee-filter/coffeescript.rb new file mode 100644 index 0000000..a02a99a --- /dev/null +++ b/lib/coffee-filter/coffeescript.rb @@ -0,0 +1,20 @@ +module Coffee + module Filter + module Coffeescript + include Haml::Filters::Base + + lazy_require 'coffee-script' + + def render_with_options(text, options) + < + // + +END + end + end + end +end + diff --git a/lib/coffee-filter/version.rb b/lib/coffee-filter/version.rb new file mode 100644 index 0000000..ac3cec4 --- /dev/null +++ b/lib/coffee-filter/version.rb @@ -0,0 +1,5 @@ +module Coffee + module Filter + VERSION = "0.1.0" + end +end