poirot 0.1.0 → 0.2.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.markdown CHANGED
@@ -46,7 +46,7 @@ type will be set as `text/mustache` and the id will be `post-list-template`.
46
46
 
47
47
  ### Javascript Helper
48
48
 
49
- Poirot also adds a javascript helper for using mustache templates from the browser. In Rails 3.1 this will be automatically added to the asset pipeline.
49
+ Poirot also adds a javascript helper for using mustache templates from the browser. In Rails 3.1 this will be automatically added to the asset pipeline, you just need to add `//= require poirot` in your application.js file.
50
50
 
51
51
  If you are using rails 3 then you can run the `rails g poirot:install` to install the javascripts in your application.
52
52
 
@@ -62,6 +62,14 @@ This will return the contents of the `post_list` template wrapped in a jQuery ob
62
62
 
63
63
  poirot.postList({foo: "bar"})
64
64
 
65
+ #### Using Handlebars.js
66
+
67
+ It is possible to use handlebars instead of mustache when rendering templates client side. To do this you need to first include the handlebars.js source. The instead of including `//= require poirot` in the asset pipeline you should include `//= require poirot-handlebars`
68
+
69
+ #### Using Hogan.js
70
+
71
+ It is also possible to use hogan.js instead of mustache when rendering templates client side. To do this you need to first include the hogan.js source. The instead of including `//= require poirot` in the asset pipeline you should include `//= require poirot-hogan`
72
+
65
73
  ## Dependencies
66
74
 
67
75
  * Rails >3.0.0
@@ -5,16 +5,26 @@ module Poirot
5
5
  class InstallGenerator < ::Rails::Generators::Base
6
6
 
7
7
  desc "This generator installs Poirot JavaScript helper"
8
- source_root File.expand_path('../../../../../vendor/assets/javascripts/poirot', __FILE__)
8
+ source_root File.expand_path('../../../../../vendor/assets/javascripts', __FILE__)
9
9
 
10
10
  def copy_mustache
11
11
  say_status("copying", "Mustache.js", :green)
12
- copy_file "mustache.js", "public/javascripts/mustache.js"
12
+ copy_file "poirot-mustache/mustache.js", "public/javascripts/mustache.js"
13
13
  end
14
14
 
15
15
  def copy_poirot
16
16
  say_status("copying", "poirot.js", :green)
17
- copy_file "poirot.js", "public/javascripts/poirot.js"
17
+ copy_file "poirot-base/poirot.js", "public/javascripts/poirot.js"
18
+ end
19
+
20
+ def copy_poirot_handlebars
21
+ say_status("copying", "poirot-handlebars.js", :green)
22
+ copy_file "poirot-handlebars/poirot-handlebars.js", "public/javascripts/poirot-handlebars.js"
23
+ end
24
+
25
+ def copy_poirot_hogan
26
+ say_status("copying", "poirot-hogan.js", :green)
27
+ copy_file "poirot-hogan/poirot-hogan.js", "public/javascripts/poirot-hogan.js"
18
28
  end
19
29
  end
20
30
  end
@@ -1,3 +1,3 @@
1
1
  module Poirot
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -0,0 +1 @@
1
+ //= require ./poirot
@@ -7,7 +7,7 @@ var poirot = (function ($) {
7
7
  }
8
8
 
9
9
  var poirot = {
10
- partials: {},
10
+ _partials: {},
11
11
  _viewFactory: viewFactory
12
12
  }
13
13
 
@@ -18,9 +18,9 @@ var poirot = (function ($) {
18
18
  return str.replace("-", "").toUpperCase()
19
19
  }).replace("Template", "")
20
20
 
21
- poirot.partials[methodName] = template
21
+ poirot._partials[methodName] = template
22
22
 
23
- poirot[methodName] = poirot._viewFactory(template, poirot.partials)
23
+ poirot[methodName] = poirot._viewFactory(template, poirot._partials)
24
24
  })
25
25
  })
26
26
 
@@ -0,0 +1,2 @@
1
+ //= require poirot-base
2
+ //= require ./poirot-handlebars
@@ -0,0 +1,8 @@
1
+ ;(function () {
2
+ poirot._viewFactory = function (template, partials) {
3
+ var compiledTemplate = Handlebars.compile(template)
4
+ return function (data) {
5
+ return $(compiledTemplate(data))
6
+ }
7
+ }
8
+ })()
@@ -0,0 +1,2 @@
1
+ //= require poirot-base
2
+ //= require ./poirot-hogan
@@ -0,0 +1,8 @@
1
+ ;(function () {
2
+ poirot._viewFactory = function (template, partials) {
3
+ var compiledTemplate = Hogan.compile(template)
4
+ return function (data) {
5
+ return $(compiledTemplate.render(data, partials))
6
+ }
7
+ }
8
+ })()
@@ -0,0 +1 @@
1
+ //= require ./mustache
@@ -1,2 +1,2 @@
1
- //= require ./mustache
2
- //= require ./poirot
1
+ //= require poirot-base
2
+ //= require poirot-mustache
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: poirot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,11 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-01-04 00:00:00.000000000 Z
13
+ date: 2012-01-06 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
17
- requirement: &70170133189960 !ruby/object:Gem::Requirement
17
+ requirement: &70254598090860 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>'
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: '3'
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *70170133189960
25
+ version_requirements: *70254598090860
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: mustache
28
- requirement: &70170133189380 !ruby/object:Gem::Requirement
28
+ requirement: &70254598090020 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ! '>='
@@ -33,7 +33,7 @@ dependencies:
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *70170133189380
36
+ version_requirements: *70254598090020
37
37
  description: mustaches are cool
38
38
  email:
39
39
  - oliver.nightingale1@gmail.com
@@ -53,9 +53,15 @@ files:
53
53
  - lib/poirot/version.rb
54
54
  - lib/poirot/view.rb
55
55
  - poirot.gemspec
56
+ - vendor/assets/javascripts/poirot-base/index.js
57
+ - vendor/assets/javascripts/poirot-base/poirot.js
58
+ - vendor/assets/javascripts/poirot-handlebars/index.js
59
+ - vendor/assets/javascripts/poirot-handlebars/poirot-handlebars.js
60
+ - vendor/assets/javascripts/poirot-hogan/index.js
61
+ - vendor/assets/javascripts/poirot-hogan/poirot-hogan.js
62
+ - vendor/assets/javascripts/poirot-mustache/index.js
63
+ - vendor/assets/javascripts/poirot-mustache/mustache.js
56
64
  - vendor/assets/javascripts/poirot/index.js
57
- - vendor/assets/javascripts/poirot/mustache.js
58
- - vendor/assets/javascripts/poirot/poirot.js
59
65
  homepage: http://rubygems.org/gems/poirot
60
66
  licenses: []
61
67
  post_install_message: