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 +4 -4
- data/README.md +5 -1
- data/examples/original/pieces/application/header.html.erb +1 -1
- data/lib/pieces/version.rb +1 -1
- data/lib/tilt/mustache.rb +17 -1
- data/pieces.gemspec +1 -0
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7161643008f10d4bbf17b26d79e932f4372f004b
|
4
|
+
data.tar.gz: 2c6d081965d88f549c94de4af7b9ad2be023b191
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
|
data/lib/pieces/version.rb
CHANGED
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,
|
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.
|
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
|