jquery-tmpl-rails 0.0.1 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore CHANGED
@@ -2,3 +2,4 @@
2
2
  .bundle
3
3
  Gemfile.lock
4
4
  pkg/*
5
+ .rvmrc
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format nested
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (C) 2011 by Jimmy Cuadra
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
@@ -1,6 +1,6 @@
1
1
  h1. jquery-tmpl-rails
2
2
 
3
- This gem added the jQuery Templates plugin to the asset pipeline in Rails => 3.1 applications.
3
+ This gem adds the jQuery Templates plugin and a corresponding Sprockets engine to the asset pipeline in Rails => 3.1 applications.
4
4
 
5
5
  h2. Installation
6
6
 
@@ -16,9 +16,22 @@ Update your bundle:
16
16
 
17
17
  h2. Usage
18
18
 
19
- Add jQuery Templates to any JavaScript file by requiring it:
19
+ Place individual jQuery templates in their own files with the @.tmpl@ extension:
20
20
 
21
- <pre lang="javascript"><code>//= require jquery.tmpl
21
+ <pre lang="html"><code><!-- app/assets/javascripts/tmpl/author.tmpl -->
22
+ <div class="author">{{name}}</div>
23
+ </code></pre>
24
+
25
+ In your manifest file, require the plugin followed by your individual templates. The templates are compiled and named with their Sprockets logical path:
26
+
27
+ <pre lang="javascript"><code>//= require jquery-tmpl
28
+ //= require tmpl.author
29
+
30
+ $.tmpl("tmpl/author", { name: "Jimmy" }).appendTo("#author");
22
31
  </code></pre>
23
32
 
24
33
  Happy templating!
34
+
35
+ h2. Acknowledgements
36
+
37
+ The @.tmpl@ Sprockets engine is based on the "sprockets-jquery-tmpl":https://github.com/rdy/sprockets-jquery-tmpl gem. If you want a similar mechanism for use outside of Rails, take a look at this project.
data/Rakefile CHANGED
@@ -1 +1,6 @@
1
1
  require 'bundler/gem_tasks'
2
+
3
+ require 'rspec/core/rake_task'
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -8,11 +8,14 @@ Gem::Specification.new do |s|
8
8
  s.authors = ["Jimmy Cuadra"]
9
9
  s.email = ["jimmy@jimmycuadra.com"]
10
10
  s.homepage = ""
11
- s.summary = %q{jQuery Templates plugin for Rails >= 3.1}
12
- s.description = %q{Adds the jQuery Templates plugin to the asset pipeline in Rails >= 3.1 applications.}
11
+ s.summary = %q{jQuery Templates for the Rails asset pipeline.}
12
+ s.description = %q{Adds the jQuery Templates plugin and a corresponding Sprockets engine to the asset pipeline in Rails applications.}
13
13
 
14
14
  s.files = `git ls-files`.split("\n")
15
15
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
16
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
17
  s.require_paths = ["lib"]
18
+
19
+ s.add_dependency 'rails', '~> 3.1.0'
20
+ s.add_development_dependency 'rspec'
18
21
  end
@@ -1,2 +1,3 @@
1
+ require "jquery-tmpl-rails/jquery_tmpl_processor"
1
2
  require "jquery-tmpl-rails/engine"
2
3
  require "jquery-tmpl-rails/version"
@@ -0,0 +1,27 @@
1
+ require 'sprockets/engines'
2
+ require 'tilt'
3
+ require 'action_view'
4
+ require 'action_view/helpers'
5
+
6
+ module Sprockets
7
+ class JqueryTmplProcessor < Tilt::Template
8
+ include ActionView::Helpers::JavaScriptHelper
9
+
10
+ def self.default_mime_type
11
+ 'application/javascript'
12
+ end
13
+
14
+ def prepare
15
+ end
16
+
17
+ def evaluate(scope, locals, &block)
18
+ <<-TMPL
19
+ ;(function($) {
20
+ return $.template(#{scope.logical_path.inspect}, "#{escape_javascript data}");
21
+ })(jQuery);
22
+ TMPL
23
+ end
24
+ end
25
+
26
+ register_engine '.tmpl', JqueryTmplProcessor
27
+ end
@@ -1,7 +1,7 @@
1
1
  module Jquery
2
2
  module Tmpl
3
3
  module Rails
4
- VERSION = "0.0.1"
4
+ VERSION = "0.1.0"
5
5
  JQUERY_TMPL_VERSION = "beta1"
6
6
  end
7
7
  end
@@ -0,0 +1 @@
1
+ <div class="test">{{test}}</div>
@@ -0,0 +1,16 @@
1
+ require "spec_helper"
2
+
3
+ describe Sprockets::JqueryTmplProcessor do
4
+ before(:all) do
5
+ @assets = Sprockets::Environment.new
6
+ @assets.append_path "spec/fixtures"
7
+ end
8
+
9
+ it "compiles templates with the .tmpl extension" do
10
+ @assets["test"].to_s.should == <<-TMPL
11
+ ;(function($) {
12
+ return $.template("test", "<div class=\\\"test\\\">{{test}}<\\/div>\\n");
13
+ })(jQuery);
14
+ TMPL
15
+ end
16
+ end
@@ -0,0 +1,2 @@
1
+ require "sprockets"
2
+ require "jquery-tmpl-rails/jquery_tmpl_processor"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jquery-tmpl-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,10 +9,32 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-08-10 00:00:00.000000000Z
13
- dependencies: []
14
- description: Adds the jQuery Templates plugin to the asset pipeline in Rails >= 3.1
15
- applications.
12
+ date: 2011-09-10 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rails
16
+ requirement: &70216038612220 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 3.1.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70216038612220
25
+ - !ruby/object:Gem::Dependency
26
+ name: rspec
27
+ requirement: &70216038611800 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *70216038611800
36
+ description: Adds the jQuery Templates plugin and a corresponding Sprockets engine
37
+ to the asset pipeline in Rails applications.
16
38
  email:
17
39
  - jimmy@jimmycuadra.com
18
40
  executables: []
@@ -20,14 +42,20 @@ extensions: []
20
42
  extra_rdoc_files: []
21
43
  files:
22
44
  - .gitignore
45
+ - .rspec
23
46
  - Gemfile
47
+ - LICENSE
24
48
  - README.textile
25
49
  - Rakefile
26
50
  - jquery-tmpl-rails.gemspec
27
51
  - lib/jquery-tmpl-rails.rb
28
52
  - lib/jquery-tmpl-rails/engine.rb
53
+ - lib/jquery-tmpl-rails/jquery_tmpl_processor.rb
29
54
  - lib/jquery-tmpl-rails/version.rb
30
- - vendor/assets/javascripts/jquery.tmpl.js
55
+ - spec/fixtures/test.tmpl
56
+ - spec/jquery-tmpl-rails/jquery_tmpl_processor_spec.rb
57
+ - spec/spec_helper.rb
58
+ - vendor/assets/javascripts/jquery-tmpl.js
31
59
  homepage: ''
32
60
  licenses: []
33
61
  post_install_message:
@@ -48,8 +76,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
48
76
  version: '0'
49
77
  requirements: []
50
78
  rubyforge_project:
51
- rubygems_version: 1.8.5
79
+ rubygems_version: 1.8.10
52
80
  signing_key:
53
81
  specification_version: 3
54
- summary: jQuery Templates plugin for Rails >= 3.1
55
- test_files: []
82
+ summary: jQuery Templates for the Rails asset pipeline.
83
+ test_files:
84
+ - spec/fixtures/test.tmpl
85
+ - spec/jquery-tmpl-rails/jquery_tmpl_processor_spec.rb
86
+ - spec/spec_helper.rb