flavour_saver 0.3.8 → 0.3.9
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/.travis.yml +4 -0
- data/README.md +4 -4
- data/lib/flavour_saver/lexer.rb +10 -5
- data/lib/flavour_saver/nodes.rb +1 -1
- data/lib/flavour_saver/version.rb +1 -1
- data/spec/acceptance/handlebars_qunit_spec.rb +1 -1
- data/spec/lib/flavour_saver/lexer_spec.rb +21 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 54b7344a636871a83f045d46103bfc0bcb8fa1e6
|
4
|
+
data.tar.gz: 2755904a1a108cd04a2fd626521a2b1eae819185
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b378381e8e40ee8d14848d50a2e4896c3ec940205420f225aefa7067da076877120d4e7d7f7ff70415d4dc56b2cd073b766c44939545daa24d0cbf919ac8d95
|
7
|
+
data.tar.gz: e4b3befa9a7584f4497451331a2d9251ff1281cbfb290303a44f022bf6c79cf31187f4e3a535708ba7fefb0d2f86074cd2b295f487bed088d80c51288f19bef0
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -2,13 +2,13 @@
|
|
2
2
|
|
3
3
|
[Handlebars.js](http://handlebarsjs.com) without the `.js`
|
4
4
|
|
5
|
-
[](https://travis-ci.org/jamesotron/FlavourSaver)
|
6
|
+
[](https://gemnasium.com/jamesotron/FlavourSaver)
|
7
|
+
[](https://codeclimate.com/github/jamesotron/FlavourSaver)
|
8
8
|
|
9
9
|
## WAT?
|
10
10
|
|
11
|
-
FlavourSaver is a ruby-based implementation of the [Handlebars.js](http://
|
11
|
+
FlavourSaver is a ruby-based implementation of the [Handlebars.js](http://handlebarsjs.com)
|
12
12
|
templating language. FlavourSaver supports Handlebars template rendering natively on
|
13
13
|
Rails and on other frameworks (such as Sinatra) via Tilt.
|
14
14
|
|
data/lib/flavour_saver/lexer.rb
CHANGED
@@ -78,7 +78,7 @@ module FlavourSaver
|
|
78
78
|
:ELSE
|
79
79
|
end
|
80
80
|
|
81
|
-
rule /([A-Za-
|
81
|
+
rule /([A-Za-z_]\w*)/, :expression do |name|
|
82
82
|
[ :IDENT, name ]
|
83
83
|
end
|
84
84
|
|
@@ -122,10 +122,15 @@ module FlavourSaver
|
|
122
122
|
pop_state
|
123
123
|
end
|
124
124
|
|
125
|
-
# Handlebars allows
|
126
|
-
#
|
127
|
-
#
|
128
|
-
|
125
|
+
# Handlebars allows identifiers with characters in them which Ruby does not.
|
126
|
+
# These are mapped to the literal notation and accessed in this way.
|
127
|
+
#
|
128
|
+
# As per the http://handlebarsjs.com/expressions.html:
|
129
|
+
#
|
130
|
+
# Identifiers may be any unicode character except for the following:
|
131
|
+
# Whitespace ! " # % & ' ( ) * + , . / ; < = > @ [ \ ] ^ ` { | } ~
|
132
|
+
#
|
133
|
+
rule /([^\s!-#%-,.\/;->@\[-^`{-~]+)/, :expression do |str|
|
129
134
|
[ :LITERAL, str ]
|
130
135
|
end
|
131
136
|
|
data/lib/flavour_saver/nodes.rb
CHANGED
@@ -766,7 +766,7 @@ describe FlavourSaver do
|
|
766
766
|
let(:template) { "Message: {{hello \"world\" 12 true false}}" }
|
767
767
|
before do
|
768
768
|
FS.register_helper(:hello) do |param,times,bool1,bool2|
|
769
|
-
times = "NaN" unless times.is_a?
|
769
|
+
times = "NaN" unless times.is_a? Integer
|
770
770
|
bool1 = "NaB" unless bool1 == true
|
771
771
|
bool2 = "NaB" unless bool2 == false
|
772
772
|
"Hello #{param} #{times} times: #{bool1} #{bool2}"
|
@@ -75,6 +75,27 @@ describe FlavourSaver::Lexer do
|
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
78
|
+
describe 'Identities' do
|
79
|
+
|
80
|
+
it 'supports as ruby methods' do
|
81
|
+
ids = %w( _ __ __123__ __ABC__ ABC123 Abc134def )
|
82
|
+
ids.each do |id|
|
83
|
+
subject = FlavourSaver::Lexer.lex "{{#{id}}}"
|
84
|
+
subject[1].type.should == :IDENT
|
85
|
+
subject[1].value.should == id
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'maps non-ruby identities to literals' do
|
90
|
+
ids = %w( A-B 12_Mine - :example 0A test? )
|
91
|
+
ids.each do |id|
|
92
|
+
subject = FlavourSaver::Lexer.lex "{{#{id}}}"
|
93
|
+
subject[1].type.should == :LITERAL
|
94
|
+
subject[1].value.should == id
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
78
99
|
describe '{{foo bar=(baz qux)}}' do
|
79
100
|
subject { FlavourSaver::Lexer.lex '{{foo bar=(baz qux)}}' }
|
80
101
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flavour_saver
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Harton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-05-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -212,7 +212,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
212
212
|
version: '0'
|
213
213
|
requirements: []
|
214
214
|
rubyforge_project:
|
215
|
-
rubygems_version: 2.
|
215
|
+
rubygems_version: 2.6.11
|
216
216
|
signing_key:
|
217
217
|
specification_version: 4
|
218
218
|
summary: Handlebars.js without the .js
|