pieces 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 64cbce7a11d487d3cd6ba5b28592c05777238d69
4
- data.tar.gz: 7372e016548ffafb26cccfa147c9b929079fcd13
3
+ metadata.gz: 7161643008f10d4bbf17b26d79e932f4372f004b
4
+ data.tar.gz: 2c6d081965d88f549c94de4af7b9ad2be023b191
5
5
  SHA512:
6
- metadata.gz: bd1f4366fdb91cbea5628c12b8516c278d627414c55cef67dd6df71c4ac49c5447a35cd0222ce0dae28237aabfa4ba6b749d3d6a6f428c727762e7deb6e141f9
7
- data.tar.gz: 64f235649c1c8b096f11f0d642183e05645a7a0c7022d70fc6c94fa52bcb8c0ec92426920e12f90745a63953aa8ccb3dd360fc7f3122f958f80043b1729ea8fa
6
+ metadata.gz: e7dbcb86cff8f805379f89749dc21d49a2be17ae1afc458fa8b2e681c632789db36c5abf19c15dd098d6926443fe70d7397c17b328939a9b4dd2bb8c7810eaf8
7
+ data.tar.gz: 0d3e2772554880ef914e915cc1fe82674dca8f7e06c141b132cbfbfb5d4d60656ca2b7abaffa81bdd097011cf916a29a726043c611492a95ac9fbee77baf14da
data/README.md CHANGED
@@ -123,7 +123,11 @@ The child pieces will be rendered in order and passed into the parent
123
123
 
124
124
  ## More Examples
125
125
 
126
- For more examples please see: https://github.com/drpheltright/pieces/tree/master/example
126
+ - [Original example][original] using .erb and .mustache (liek wtf!)
127
+ - [Boilerplate example][boilerplate] used by `pieces init`
128
+
129
+ [original]: https://github.com/drpheltright/pieces/tree/master/examples/original
130
+ [boilerplate]: https://github.com/drpheltright/pieces/tree/master/examples/boilerplate
127
131
 
128
132
  ## Contributing
129
133
 
@@ -1,3 +1,3 @@
1
1
  <header>
2
- <%= self['title'] %>
2
+ <%= title %>
3
3
  </header>
@@ -1,3 +1,3 @@
1
1
  module Pieces
2
- VERSION = '0.2.2'
2
+ VERSION = '0.2.3'
3
3
  end
data/lib/tilt/mustache.rb CHANGED
@@ -7,7 +7,23 @@ module Tilt
7
7
  def prepare; end
8
8
 
9
9
  def evaluate(scope, locals, &block)
10
- Mustache.render(data, locals.merge(scope.is_a?(Hash) ? scope : {}).merge(:yield => block.nil? ? '' : block.call))
10
+ Mustache.render(data, with_block(view_model(scope, locals), &block))
11
+ end
12
+
13
+ private
14
+
15
+ def view_model(scope, locals)
16
+ if scope.is_a?(Hash)
17
+ locals.merge(scope)
18
+ elsif scope.respond_to?(:to_h)
19
+ locals.merge(scope.to_h)
20
+ else
21
+ locals
22
+ end
23
+ end
24
+
25
+ def with_block(view_model, &block)
26
+ view_model.merge(:yield => block.nil? ? '' : block.call)
11
27
  end
12
28
  end
13
29
  end
data/pieces.gemspec CHANGED
@@ -21,6 +21,7 @@ Gem::Specification.new do |spec|
21
21
  spec.add_development_dependency 'bundler'
22
22
  spec.add_development_dependency 'codeclimate-test-reporter'
23
23
  spec.add_development_dependency 'mustache'
24
+ spec.add_development_dependency 'pry'
24
25
  spec.add_development_dependency 'rake'
25
26
  spec.add_development_dependency 'rspec'
26
27
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pieces
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luke Morton
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: rake
71
85
  requirement: !ruby/object:Gem::Requirement