sprockets_spacely 0.0.2 → 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/README.md CHANGED
@@ -14,9 +14,10 @@ We assume that you are requiring jQuery and Mustache.js higher up in your Sprock
14
14
 
15
15
  ```ruby
16
16
  Sprockets::Mustache::Template::Namespace.value = 'namespace.for.my.templates'
17
+ Sprockets::Mustache::Template::Library.value = 'Zepto'
17
18
  ```
18
19
 
19
- This will take any *.mustache file under Sprockets' paths and generate a closure that sets a function that evaluates your template.
20
+ This will take any `*.mustache` file under Sprockets' paths and generate a closure that sets a function that evaluates your template.
20
21
 
21
22
  File: "app/assets/javascripts/my_template.mustache"
22
23
 
@@ -42,7 +43,7 @@ This function will be created:
42
43
  function render(obj, partials) {
43
44
  return Mustache.to_html(#{@namespace}.mustache['#{@template_name}'].template, obj, partials);
44
45
  }
45
- }(jQuery));
46
+ }(#{@library}));
46
47
  ```
47
48
 
48
49
  ...which Sprockets will add to the appropriate JavaScript asset bundle.
@@ -59,4 +60,4 @@ Which means in your code you can call:
59
60
  ## Versions
60
61
 
61
62
  ### 0.0.2
62
- - Added ability to use mustache partials
63
+ - Added ability to use mustache partials
@@ -1,3 +1,4 @@
1
+ require 'sprockets'
1
2
  require 'sprockets/engines'
2
3
  require 'tilt'
3
4
  require 'action_view'
@@ -5,6 +6,7 @@ require 'action_view/helpers'
5
6
  require 'action_view/helpers/javascript_helper'
6
7
 
7
8
  require "sprockets_spacely/version"
9
+ require "sprockets_spacely/mustache/template/library"
8
10
  require "sprockets_spacely/mustache/template/namespace"
9
11
  require "sprockets_spacely/mustache/template/generator"
10
- require "sprockets_spacely/mustache/template/processor"
12
+ require "sprockets_spacely/mustache/template/processor"
@@ -5,10 +5,11 @@ module Sprockets
5
5
 
6
6
  attr_reader :template_name
7
7
 
8
- def initialize(namespace, logical_path, template_string)
8
+ def initialize(namespace, logical_path, template_string, library)
9
9
  @template_name = logical_path
10
10
  @namespace = namespace
11
11
  @template_string = template_string
12
+ @library = library
12
13
  end
13
14
 
14
15
  def generate
@@ -24,7 +25,7 @@ module Sprockets
24
25
  function render(obj, partials) {
25
26
  return Mustache.to_html(#{@namespace}.mustache['#{@template_name}'].template, obj, partials);
26
27
  }
27
- }(jQuery));
28
+ }(#{@library}));
28
29
  JS
29
30
 
30
31
  end
@@ -0,0 +1,17 @@
1
+ module Sprockets
2
+ module Mustache
3
+ module Template
4
+ class Library
5
+
6
+ def self.value=(val)
7
+ @@value = val
8
+ end
9
+
10
+ def self.value
11
+ @@value
12
+ end
13
+
14
+ end
15
+ end
16
+ end
17
+ end
@@ -12,14 +12,14 @@ module Sprockets
12
12
  end
13
13
 
14
14
  def evaluate(scope, locals, &block)
15
-
16
15
  namespace = Namespace.value || "window"
16
+ library = Library.value || "jQuery"
17
17
 
18
- Generator.new(namespace, scope.logical_path, escape_javascript(data)).generate
18
+ Generator.new(namespace, scope.logical_path, escape_javascript(data), library).generate
19
19
  end
20
20
  end
21
21
  end
22
22
  end
23
23
 
24
24
  register_engine '.mustache', ::Sprockets::Mustache::Template::Processor
25
- end
25
+ end
@@ -1,3 +1,3 @@
1
1
  module SprocketsSpacely
2
- VERSION = "0.0.2"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -5,6 +5,7 @@ describe Sprockets::Mustache::Template::Generator do
5
5
  let :generator do
6
6
 
7
7
  namespace = "my.Namespace"
8
+ library = "Zepto"
8
9
  logical_path = "javascripts/backbone/templates/mustache/entryList"
9
10
  template_string = <<-HTML
10
11
  <table class="ledger">
@@ -20,7 +21,7 @@ describe Sprockets::Mustache::Template::Generator do
20
21
  </table>
21
22
  HTML
22
23
 
23
- Sprockets::Mustache::Template::Generator.new(namespace, logical_path, template_string)
24
+ Sprockets::Mustache::Template::Generator.new(namespace, logical_path, template_string, library)
24
25
  end
25
26
 
26
27
  it "calculates the template name" do
@@ -40,6 +41,10 @@ describe Sprockets::Mustache::Template::Generator do
40
41
  @js.should match(/my\.Namespace\.mustache\['javascripts\/backbone\/templates\/mustache\/entryList'\] = \{/)
41
42
  end
42
43
 
44
+ it "assigns the correct library" do
45
+ @js.should match(/}\(Zepto\)/)
46
+ end
47
+
43
48
  it "puts the template in the mustache object" do
44
49
  @js.should match(/<table class="ledger">/)
45
50
  end
@@ -53,4 +58,4 @@ describe Sprockets::Mustache::Template::Generator do
53
58
  end
54
59
 
55
60
  end
56
- end
61
+ end
metadata CHANGED
@@ -1,74 +1,71 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: sprockets_spacely
3
- version: !ruby/object:Gem::Version
4
- hash: 27
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 0
9
- - 2
10
- version: 0.0.2
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Outright
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-11-06 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
21
- version_requirements: &id001 !ruby/object:Gem::Requirement
22
- none: false
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- hash: 3
27
- segments:
28
- - 0
29
- version: "0"
12
+ date: 2013-02-28 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
30
15
  name: rails
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
31
22
  type: :runtime
32
23
  prerelease: false
33
- requirement: *id001
34
- - !ruby/object:Gem::Dependency
35
- version_requirements: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: !ruby/object:Gem::Requirement
36
25
  none: false
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- hash: 3
41
- segments:
42
- - 0
43
- version: "0"
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
44
31
  name: tilt
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
45
38
  type: :runtime
46
39
  prerelease: false
47
- requirement: *id002
48
- - !ruby/object:Gem::Dependency
49
- version_requirements: &id003 !ruby/object:Gem::Requirement
40
+ version_requirements: !ruby/object:Gem::Requirement
50
41
  none: false
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- hash: 3
55
- segments:
56
- - 0
57
- version: "0"
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
58
47
  name: rspec
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
59
54
  type: :development
60
55
  prerelease: false
61
- requirement: *id003
62
- description: " Mr.Spacely, of Spacely Sprockets, Inc. had a mustache: http://www.google.com/search?q=mr.+spacely&hl=en&prmd=imvns&tbm=isch&tbo=u&source=univ&sa=X&ei=YI2wTpafH9PPiALHnIAF&ved=0CD0QsAQ&biw=1080&bih=1282&sei=%20jY6wTsr-CsSmiQKg0Tw"
63
- email:
64
- - ""
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ description: ! ' Mr.Spacely, of Spacely Sprockets, Inc. had a mustache: http://www.google.com/search?q=mr.+spacely&hl=en&prmd=imvns&tbm=isch&tbo=u&source=univ&sa=X&ei=YI2wTpafH9PPiALHnIAF&ved=0CD0QsAQ&biw=1080&bih=1282&sei=%20jY6wTsr-CsSmiQKg0Tw'
63
+ email:
64
+ - ''
65
65
  executables: []
66
-
67
66
  extensions: []
68
-
69
67
  extra_rdoc_files: []
70
-
71
- files:
68
+ files:
72
69
  - .gitignore
73
70
  - .rspec
74
71
  - Gemfile
@@ -77,45 +74,38 @@ files:
77
74
  - Rakefile
78
75
  - lib/sprockets_spacely.rb
79
76
  - lib/sprockets_spacely/mustache/template/generator.rb
77
+ - lib/sprockets_spacely/mustache/template/library.rb
80
78
  - lib/sprockets_spacely/mustache/template/namespace.rb
81
79
  - lib/sprockets_spacely/mustache/template/processor.rb
82
80
  - lib/sprockets_spacely/version.rb
83
81
  - spec/lib/template_generator_spec.rb
84
82
  - spec/spec_helper.rb
85
83
  - sprockets_spacely.gemspec
86
- homepage: ""
84
+ homepage: ''
87
85
  licenses: []
88
-
89
86
  post_install_message:
90
87
  rdoc_options: []
91
-
92
- require_paths:
88
+ require_paths:
93
89
  - lib
94
- required_ruby_version: !ruby/object:Gem::Requirement
90
+ required_ruby_version: !ruby/object:Gem::Requirement
95
91
  none: false
96
- requirements:
97
- - - ">="
98
- - !ruby/object:Gem::Version
99
- hash: 3
100
- segments:
101
- - 0
102
- version: "0"
103
- required_rubygems_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ! '>='
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ required_rubygems_version: !ruby/object:Gem::Requirement
104
97
  none: false
105
- requirements:
106
- - - ">="
107
- - !ruby/object:Gem::Version
108
- hash: 3
109
- segments:
110
- - 0
111
- version: "0"
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
112
102
  requirements: []
113
-
114
103
  rubyforge_project:
115
- rubygems_version: 1.8.6
104
+ rubygems_version: 1.8.23
116
105
  signing_key:
117
106
  specification_version: 3
118
- summary: Even lighter-weight way to get Mustache.js into your Sprockets. Entirely influenced by Ryan Dy's '
119
- test_files:
107
+ summary: Even lighter-weight way to get Mustache.js into your Sprockets. Entirely
108
+ influenced by Ryan Dy's '
109
+ test_files:
120
110
  - spec/lib/template_generator_spec.rb
121
111
  - spec/spec_helper.rb