ruby-handlebars 0.0.2 → 0.0.3
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.
- checksums.yaml +4 -4
- data/lib/ruby-handlebars.rb +6 -2
- data/lib/ruby-handlebars/context.rb +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e63c4f5d37f79ac23d9c970942bee195d95e14a
|
4
|
+
data.tar.gz: 4cf5f61a9e046de6c3630d792a32f9636bfede90
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7fde4e2ae941f01c7c43b2aaf2ebf4f508f603a0dc2797cb77a8e2e35a96309c14fddf4902589009ebdc0396e51b3b5c96798054a60f7f98e0399aa592a53ed1
|
7
|
+
data.tar.gz: 9b5592a196121201380ea33588ab8321e6009097ef34aba8b77548081f3b15dbdc8d1aeb573a58a32e8e1e8bbbdc9cca9f02dffe142d18750ed6d10b3dc53ac1
|
data/lib/ruby-handlebars.rb
CHANGED
@@ -38,8 +38,12 @@ module Handlebars
|
|
38
38
|
end
|
39
39
|
|
40
40
|
private
|
41
|
+
|
42
|
+
PARSER = Parser.new
|
43
|
+
TRANSFORM = Transform.new
|
44
|
+
|
41
45
|
def template_to_ast(content)
|
42
|
-
|
46
|
+
TRANSFORM.apply(PARSER.parse(content))
|
43
47
|
end
|
44
48
|
|
45
49
|
def register_default_helpers
|
@@ -79,4 +83,4 @@ module Handlebars
|
|
79
83
|
end
|
80
84
|
end
|
81
85
|
end
|
82
|
-
end
|
86
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Handlebars
|
2
2
|
module Context
|
3
3
|
def get(path)
|
4
|
-
items = path.split('.')
|
4
|
+
items = path.split('.'.freeze)
|
5
5
|
|
6
6
|
current = @data
|
7
7
|
until items.empty?
|
@@ -21,7 +21,7 @@ module Handlebars
|
|
21
21
|
sym_attr = attribute.to_sym
|
22
22
|
str_attr = attribute.to_s
|
23
23
|
|
24
|
-
if item.respond_to?(
|
24
|
+
if item.respond_to?(:[])
|
25
25
|
if item.has_key?(sym_attr)
|
26
26
|
return item[sym_attr]
|
27
27
|
elsif item.has_key?(str_attr)
|
@@ -38,4 +38,4 @@ module Handlebars
|
|
38
38
|
end
|
39
39
|
end
|
40
40
|
end
|
41
|
-
end
|
41
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-handlebars
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vincent Pretre
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-10-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: parslet
|