flavour_saver 0.3.6 → 0.3.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +4 -1
- data/README.md +8 -0
- data/lib/flavour_saver/lexer.rb +15 -0
- data/lib/flavour_saver/parser.rb +7 -2
- data/lib/flavour_saver/version.rb +1 -1
- data/spec/acceptance/raw_block_spec.rb +12 -0
- data/spec/fixtures/raw.hbs +3 -0
- data/spec/lib/flavour_saver/parser_spec.rb +12 -3
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c3efa30121a2e226ebb1274cf5597d35ab7f9c47
|
4
|
+
data.tar.gz: c89bc7f065e3dfbb07882c44465711981643d454
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1292541b248293451704808a7458b2132ab7109f9664845c77d01c375581396192af2ee2a19c6cfae4fa567294757cb5b563803e23ccfd8110961f204adbdd03
|
7
|
+
data.tar.gz: a74f63a36b4864fbc248fde7ff9e03c19ffc49412f37b472521cf2ed13bf7403e24243e423211c1599c924a92a8e9f9b1472ba15c07b12a12955de70f131da7c
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -14,6 +14,13 @@ Rails and on other frameworks (such as Sinatra) via Tilt.
|
|
14
14
|
|
15
15
|
Please use it, break it, and send issues/PR's for improvement.
|
16
16
|
|
17
|
+
## Caveat
|
18
|
+
|
19
|
+
FlavourSaver is used in production by a lot of folks, none of whom are me. As
|
20
|
+
I don't use FlavourSaver in my daily life I will not be responding to issues
|
21
|
+
unless they have a corresponding PR. If you'd like to take over maintaining
|
22
|
+
this project then get in contact.
|
23
|
+
|
17
24
|
## License
|
18
25
|
|
19
26
|
FlavourSaver is Copyright (c) 2013 Resistor Limited and licensed under the terms
|
@@ -66,6 +73,7 @@ Currently supported:
|
|
66
73
|
- Block expressions with inverse blocks
|
67
74
|
- Inverse blocks
|
68
75
|
- Partials
|
76
|
+
- Raw content (`{{{{raw}}}} not parsed or validated {{{{/raw}}}}`)
|
69
77
|
|
70
78
|
## Helpers
|
71
79
|
|
data/lib/flavour_saver/lexer.rb
CHANGED
@@ -3,6 +3,21 @@ require 'rltk'
|
|
3
3
|
module FlavourSaver
|
4
4
|
class Lexer < RLTK::Lexer
|
5
5
|
|
6
|
+
# seems to have problem with hash symbol in regex
|
7
|
+
rule /\{\{\{\{raw\}\}\}\}/, :default do
|
8
|
+
push_state :raw
|
9
|
+
:RAWSTART
|
10
|
+
end
|
11
|
+
|
12
|
+
rule /.*?(?=\{\{\{\{\/raw\}\}\}\})/m, :raw do |str|
|
13
|
+
[ :RAWSTRING, str ]
|
14
|
+
end
|
15
|
+
|
16
|
+
rule /\{\{\{\{\/raw\}\}\}\}/, :raw do
|
17
|
+
pop_state
|
18
|
+
:RAWEND
|
19
|
+
end
|
20
|
+
|
6
21
|
rule /{{{/, :default do
|
7
22
|
push_state :expression
|
8
23
|
:TEXPRST
|
data/lib/flavour_saver/parser.rb
CHANGED
@@ -39,7 +39,8 @@ module FlavourSaver
|
|
39
39
|
end
|
40
40
|
|
41
41
|
production(:template_item) do
|
42
|
-
clause('
|
42
|
+
clause('raw_bl') { |e| e }
|
43
|
+
clause('output') { |e| e }
|
43
44
|
clause('expression') { |e| e }
|
44
45
|
end
|
45
46
|
|
@@ -47,6 +48,10 @@ module FlavourSaver
|
|
47
48
|
clause('OUT') { |o| OutputNode.new(o) }
|
48
49
|
end
|
49
50
|
|
51
|
+
production(:raw_bl) do
|
52
|
+
clause('RAWSTART RAWSTRING RAWEND') { |_,e,_| OutputNode.new(e) }
|
53
|
+
end
|
54
|
+
|
50
55
|
production(:expression) do
|
51
56
|
clause('block_expression') { |e| e }
|
52
57
|
clause('expr') { |e| ExpressionNode.new(e) }
|
@@ -121,7 +126,7 @@ module FlavourSaver
|
|
121
126
|
|
122
127
|
production('arguments') do
|
123
128
|
clause('argument_list') { |e| e }
|
124
|
-
clause('argument_list hash') { |e0,e1| e0 + [e1] }
|
129
|
+
clause('argument_list WHITE hash') { |e0,_,e1| e0 + [e1] }
|
125
130
|
clause('hash') { |e| [e] }
|
126
131
|
end
|
127
132
|
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'tilt'
|
2
|
+
require 'flavour_saver'
|
3
|
+
|
4
|
+
describe 'Fixture: raw.hbs' do
|
5
|
+
subject { Tilt.new(template).render(context).gsub(/[\s\r\n]+/, ' ').strip }
|
6
|
+
let(:template) { File.expand_path('../../fixtures/raw.hbs', __FILE__) }
|
7
|
+
let(:context) { double(:context) }
|
8
|
+
|
9
|
+
it 'renders correctly' do
|
10
|
+
subject.should == "{{=if brokensyntax}"
|
11
|
+
end
|
12
|
+
end
|
@@ -41,7 +41,7 @@ describe FlavourSaver::Parser do
|
|
41
41
|
items.first.method.first.name.should == 'foo'
|
42
42
|
items.first.method.first.arguments.should be_empty
|
43
43
|
end
|
44
|
-
|
44
|
+
end
|
45
45
|
|
46
46
|
describe '{{foo.bar}}' do
|
47
47
|
subject { FlavourSaver::Parser.parse(FlavourSaver::Lexer.lex('{{foo.bar}}')) }
|
@@ -296,7 +296,6 @@ describe FlavourSaver::Parser do
|
|
296
296
|
-> { subject }.should_not raise_error
|
297
297
|
end
|
298
298
|
end
|
299
|
-
|
300
299
|
describe '' do
|
301
300
|
subject { FlavourSaver::Parser.parse(FlavourSaver::Lexer.lex('')) }
|
302
301
|
|
@@ -304,5 +303,15 @@ describe FlavourSaver::Parser do
|
|
304
303
|
items.should be_empty
|
305
304
|
end
|
306
305
|
end
|
307
|
-
|
306
|
+
describe '{{foo "bar" fred="wilma"}}' do
|
307
|
+
subject { FlavourSaver::Parser.parse(FlavourSaver::Lexer.lex('{{foo "bar" fred="wilma"}}')) }
|
308
|
+
it 'calls the method "foo" with the "bar" and {:fred => "wilma"} as arguments' do
|
309
|
+
items.first.method.first.should be_a(FlavourSaver::CallNode)
|
310
|
+
items.first.method.first.name.should == 'foo'
|
311
|
+
items.first.method.first.arguments.first.should be_a(FlavourSaver::StringNode)
|
312
|
+
items.first.method.first.arguments.first.value.should == 'bar'
|
313
|
+
items.first.method.first.arguments.last.should be_a(Hash)
|
314
|
+
items.first.method.first.arguments.last.should == { :fred => FlavourSaver::StringNode.new('wilma') }
|
315
|
+
end
|
316
|
+
end
|
308
317
|
end
|
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.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Harton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -172,6 +172,7 @@ files:
|
|
172
172
|
- spec/acceptance/if_else_spec.rb
|
173
173
|
- spec/acceptance/multi_level_with_spec.rb
|
174
174
|
- spec/acceptance/one_character_identifier_spec.rb
|
175
|
+
- spec/acceptance/raw_block_spec.rb
|
175
176
|
- spec/acceptance/runtime_run_spec.rb
|
176
177
|
- spec/acceptance/sections_spec.rb
|
177
178
|
- spec/acceptance/segment_literals_spec.rb
|
@@ -184,6 +185,7 @@ files:
|
|
184
185
|
- spec/fixtures/multi_level_if.hbs
|
185
186
|
- spec/fixtures/multi_level_with.hbs
|
186
187
|
- spec/fixtures/one_character_identifier.hbs
|
188
|
+
- spec/fixtures/raw.hbs
|
187
189
|
- spec/fixtures/sections.hbs
|
188
190
|
- spec/fixtures/simple_expression.hbs
|
189
191
|
- spec/lib/flavour_saver/lexer_spec.rb
|
@@ -209,7 +211,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
209
211
|
version: '0'
|
210
212
|
requirements: []
|
211
213
|
rubyforge_project:
|
212
|
-
rubygems_version: 2.4.
|
214
|
+
rubygems_version: 2.4.5.1
|
213
215
|
signing_key:
|
214
216
|
specification_version: 4
|
215
217
|
summary: Handlebars.js without the .js
|
@@ -223,6 +225,7 @@ test_files:
|
|
223
225
|
- spec/acceptance/if_else_spec.rb
|
224
226
|
- spec/acceptance/multi_level_with_spec.rb
|
225
227
|
- spec/acceptance/one_character_identifier_spec.rb
|
228
|
+
- spec/acceptance/raw_block_spec.rb
|
226
229
|
- spec/acceptance/runtime_run_spec.rb
|
227
230
|
- spec/acceptance/sections_spec.rb
|
228
231
|
- spec/acceptance/segment_literals_spec.rb
|
@@ -235,6 +238,7 @@ test_files:
|
|
235
238
|
- spec/fixtures/multi_level_if.hbs
|
236
239
|
- spec/fixtures/multi_level_with.hbs
|
237
240
|
- spec/fixtures/one_character_identifier.hbs
|
241
|
+
- spec/fixtures/raw.hbs
|
238
242
|
- spec/fixtures/sections.hbs
|
239
243
|
- spec/fixtures/simple_expression.hbs
|
240
244
|
- spec/lib/flavour_saver/lexer_spec.rb
|