opal 0.3.26 → 0.3.27
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -6
- data/.travis.yml +1 -4
- data/Gemfile +1 -1
- data/README.md +3 -8
- data/Rakefile +26 -3
- data/core/array.rb +33 -91
- data/core/boolean.rb +1 -4
- data/core/class.rb +25 -71
- data/core/error.rb +5 -3
- data/core/hash.rb +3 -2
- data/core/kernel.rb +40 -1
- data/core/load_order +1 -1
- data/core/nil_class.rb +1 -3
- data/core/runtime.js +4 -44
- data/core/template.rb +20 -0
- data/core/{opal-spec → test_runner}/runner.js +0 -6
- data/lib/opal.rb +1 -12
- data/lib/opal/builder.rb +3 -10
- data/lib/opal/lexer.rb +1095 -1110
- data/lib/opal/parser.rb +229 -26
- data/lib/opal/rake_task.rb +3 -3
- data/lib/opal/version.rb +1 -1
- data/opal.gemspec +2 -2
- data/spec/core/array/assoc_spec.rb +2 -3
- data/spec/core/array/comparison_spec.rb +16 -0
- data/spec/core/array/constructor_spec.rb +0 -9
- data/spec/core/array/drop_spec.rb +21 -0
- data/spec/core/array/dup_spec.rb +15 -0
- data/spec/core/array/{eql_spec.rb → equal_value_spec.rb} +0 -0
- data/spec/core/array/index_spec.rb +26 -0
- data/spec/core/array/inspect_spec.rb +13 -0
- data/spec/core/array/intersection_spec.rb +22 -0
- data/spec/core/array/join_spec.rb +9 -0
- data/spec/core/array/keep_if_spec.rb +7 -0
- data/spec/core/array/minus_spec.rb +19 -9
- data/spec/core/array/multiply_spec.rb +13 -0
- data/spec/core/array/new_spec.rb +40 -0
- data/spec/core/array/rindex_spec.rb +21 -0
- data/spec/core/array/select_spec.rb +13 -0
- data/spec/core/array/shift_spec.rb +51 -0
- data/spec/core/array/slice_spec.rb +37 -0
- data/spec/core/array/take_spec.rb +21 -0
- data/spec/core/array/take_while_spec.rb +13 -0
- data/spec/core/array/to_a_spec.rb +7 -0
- data/spec/core/array/unshift_spec.rb +29 -0
- data/spec/core/hash/constructor_spec.rb +13 -0
- data/spec/core/hash/default_proc_spec.rb +20 -0
- data/spec/core/hash/default_spec.rb +8 -0
- data/spec/core/hash/delete_spec.rb +11 -0
- data/spec/core/hash/dup_spec.rb +10 -0
- data/spec/core/hash/reject_spec.rb +18 -0
- data/spec/core/hash/to_a_spec.rb +13 -0
- data/spec/core/kernel/Array_spec.rb +10 -0
- data/spec/core/kernel/class_spec.rb +6 -0
- data/spec/core/kernel/equal_spec.rb +12 -0
- data/spec/core/kernel/extend_spec.rb +21 -0
- data/spec/core/kernel/instance_eval_spec.rb +28 -0
- data/spec/core/kernel/instance_variable_get_spec.rb +14 -0
- data/spec/core/kernel/instance_variable_set_spec.rb +10 -0
- data/spec/core/kernel/match_spec.rb +5 -0
- data/spec/core/module/alias_method_spec.rb +10 -0
- data/spec/core/module/ancestors_spec.rb +11 -0
- data/spec/core/module/append_features_spec.rb +14 -0
- data/spec/core/proc/call_spec.rb +21 -0
- data/spec/core/proc/proc_tricks_spec.rb +1 -1
- data/spec/language/alias_spec.rb +1 -1
- data/spec/opal/class/instance_methods_spec.rb +13 -0
- data/spec/opal/kernel/attribute_spec.rb +57 -0
- data/spec/spec_helper.rb +1 -1
- data/spec/test_case.html +13 -0
- metadata +88 -12
- data/core/erb.rb +0 -32
- data/lib/opal/erb_parser.rb +0 -20
- data/spec/opal/erb/erb_spec.rb +0 -23
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.27
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,10 +9,10 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-09-
|
12
|
+
date: 2012-09-22 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Ruby runtime and core library for javascript.
|
15
|
-
email: adam@
|
15
|
+
email: adam.beynon@gmail.com
|
16
16
|
executables:
|
17
17
|
- opal
|
18
18
|
extensions: []
|
@@ -31,7 +31,6 @@ files:
|
|
31
31
|
- core/class.rb
|
32
32
|
- core/comparable.rb
|
33
33
|
- core/enumerable.rb
|
34
|
-
- core/erb.rb
|
35
34
|
- core/error.rb
|
36
35
|
- core/hash.rb
|
37
36
|
- core/json.rb
|
@@ -39,7 +38,6 @@ files:
|
|
39
38
|
- core/load_order
|
40
39
|
- core/nil_class.rb
|
41
40
|
- core/numeric.rb
|
42
|
-
- core/opal-spec/runner.js
|
43
41
|
- core/parser/browser.js
|
44
42
|
- core/parser/racc.rb
|
45
43
|
- core/parser/strscan.rb
|
@@ -48,10 +46,11 @@ files:
|
|
48
46
|
- core/regexp.rb
|
49
47
|
- core/runtime.js
|
50
48
|
- core/string.rb
|
49
|
+
- core/template.rb
|
50
|
+
- core/test_runner/runner.js
|
51
51
|
- core/time.rb
|
52
52
|
- lib/opal.rb
|
53
53
|
- lib/opal/builder.rb
|
54
|
-
- lib/opal/erb_parser.rb
|
55
54
|
- lib/opal/grammar.rb
|
56
55
|
- lib/opal/grammar.y
|
57
56
|
- lib/opal/lexer.rb
|
@@ -68,26 +67,36 @@ files:
|
|
68
67
|
- spec/core/array/clone_spec.rb
|
69
68
|
- spec/core/array/collect_spec.rb
|
70
69
|
- spec/core/array/compact_spec.rb
|
70
|
+
- spec/core/array/comparison_spec.rb
|
71
71
|
- spec/core/array/concat_spec.rb
|
72
72
|
- spec/core/array/constructor_spec.rb
|
73
73
|
- spec/core/array/count_spec.rb
|
74
74
|
- spec/core/array/delete_at_spec.rb
|
75
75
|
- spec/core/array/delete_if_spec.rb
|
76
76
|
- spec/core/array/delete_spec.rb
|
77
|
+
- spec/core/array/drop_spec.rb
|
78
|
+
- spec/core/array/dup_spec.rb
|
77
79
|
- spec/core/array/each_index_spec.rb
|
78
80
|
- spec/core/array/each_spec.rb
|
79
81
|
- spec/core/array/element_reference_spec.rb
|
80
82
|
- spec/core/array/empty_spec.rb
|
81
|
-
- spec/core/array/
|
83
|
+
- spec/core/array/equal_value_spec.rb
|
82
84
|
- spec/core/array/fetch_spec.rb
|
83
85
|
- spec/core/array/first_spec.rb
|
84
86
|
- spec/core/array/flatten_spec.rb
|
85
87
|
- spec/core/array/include_spec.rb
|
88
|
+
- spec/core/array/index_spec.rb
|
86
89
|
- spec/core/array/insert_spec.rb
|
90
|
+
- spec/core/array/inspect_spec.rb
|
91
|
+
- spec/core/array/intersection_spec.rb
|
92
|
+
- spec/core/array/join_spec.rb
|
93
|
+
- spec/core/array/keep_if_spec.rb
|
87
94
|
- spec/core/array/last_spec.rb
|
88
95
|
- spec/core/array/length_spec.rb
|
89
96
|
- spec/core/array/map_spec.rb
|
90
97
|
- spec/core/array/minus_spec.rb
|
98
|
+
- spec/core/array/multiply_spec.rb
|
99
|
+
- spec/core/array/new_spec.rb
|
91
100
|
- spec/core/array/plus_spec.rb
|
92
101
|
- spec/core/array/pop_spec.rb
|
93
102
|
- spec/core/array/push_spec.rb
|
@@ -96,9 +105,17 @@ files:
|
|
96
105
|
- spec/core/array/replace_spec.rb
|
97
106
|
- spec/core/array/reverse_each_spec.rb
|
98
107
|
- spec/core/array/reverse_spec.rb
|
108
|
+
- spec/core/array/rindex_spec.rb
|
109
|
+
- spec/core/array/select_spec.rb
|
110
|
+
- spec/core/array/shift_spec.rb
|
99
111
|
- spec/core/array/size_spec.rb
|
112
|
+
- spec/core/array/slice_spec.rb
|
113
|
+
- spec/core/array/take_spec.rb
|
114
|
+
- spec/core/array/take_while_spec.rb
|
115
|
+
- spec/core/array/to_a_spec.rb
|
100
116
|
- spec/core/array/to_ary_spec.rb
|
101
117
|
- spec/core/array/uniq_spec.rb
|
118
|
+
- spec/core/array/unshift_spec.rb
|
102
119
|
- spec/core/array/zip_spec.rb
|
103
120
|
- spec/core/class/fixtures/classes.rb
|
104
121
|
- spec/core/class/new_spec.rb
|
@@ -130,8 +147,12 @@ files:
|
|
130
147
|
- spec/core/hash/assoc_spec.rb
|
131
148
|
- spec/core/hash/clear_spec.rb
|
132
149
|
- spec/core/hash/clone_spec.rb
|
150
|
+
- spec/core/hash/constructor_spec.rb
|
151
|
+
- spec/core/hash/default_proc_spec.rb
|
133
152
|
- spec/core/hash/default_spec.rb
|
134
153
|
- spec/core/hash/delete_if_spec.rb
|
154
|
+
- spec/core/hash/delete_spec.rb
|
155
|
+
- spec/core/hash/dup_spec.rb
|
135
156
|
- spec/core/hash/each_key_spec.rb
|
136
157
|
- spec/core/hash/each_pair_spec.rb
|
137
158
|
- spec/core/hash/each_spec.rb
|
@@ -156,18 +177,28 @@ files:
|
|
156
177
|
- spec/core/hash/merge_spec.rb
|
157
178
|
- spec/core/hash/new_spec.rb
|
158
179
|
- spec/core/hash/rassoc_spec.rb
|
180
|
+
- spec/core/hash/reject_spec.rb
|
159
181
|
- spec/core/hash/replace_spec.rb
|
160
182
|
- spec/core/hash/select_spec.rb
|
161
183
|
- spec/core/hash/shift_spec.rb
|
162
184
|
- spec/core/hash/size_spec.rb
|
185
|
+
- spec/core/hash/to_a_spec.rb
|
163
186
|
- spec/core/hash/update_spec.rb
|
164
187
|
- spec/core/hash/value_spec.rb
|
165
188
|
- spec/core/hash/values_at_spec.rb
|
166
189
|
- spec/core/hash/values_spec.rb
|
190
|
+
- spec/core/kernel/Array_spec.rb
|
191
|
+
- spec/core/kernel/class_spec.rb
|
167
192
|
- spec/core/kernel/define_singleton_method_spec.rb
|
168
193
|
- spec/core/kernel/eql_spec.rb
|
194
|
+
- spec/core/kernel/equal_spec.rb
|
169
195
|
- spec/core/kernel/equal_value_spec.rb
|
196
|
+
- spec/core/kernel/extend_spec.rb
|
197
|
+
- spec/core/kernel/instance_eval_spec.rb
|
198
|
+
- spec/core/kernel/instance_variable_get_spec.rb
|
199
|
+
- spec/core/kernel/instance_variable_set_spec.rb
|
170
200
|
- spec/core/kernel/loop_spec.rb
|
201
|
+
- spec/core/kernel/match_spec.rb
|
171
202
|
- spec/core/kernel/nil_spec.rb
|
172
203
|
- spec/core/kernel/proc_spec.rb
|
173
204
|
- spec/core/kernel/rand_spec.rb
|
@@ -176,6 +207,9 @@ files:
|
|
176
207
|
- spec/core/kernel/tap_spec.rb
|
177
208
|
- spec/core/kernel/to_s_spec.rb
|
178
209
|
- spec/core/matchdata/to_a_spec.rb
|
210
|
+
- spec/core/module/alias_method_spec.rb
|
211
|
+
- spec/core/module/ancestors_spec.rb
|
212
|
+
- spec/core/module/append_features_spec.rb
|
179
213
|
- spec/core/nil/and_spec.rb
|
180
214
|
- spec/core/nil/inspect_spec.rb
|
181
215
|
- spec/core/nil/nil_spec.rb
|
@@ -186,6 +220,7 @@ files:
|
|
186
220
|
- spec/core/nil/to_s_spec.rb
|
187
221
|
- spec/core/nil/xor_spec.rb
|
188
222
|
- spec/core/numeric/equal_value_spec.rb
|
223
|
+
- spec/core/proc/call_spec.rb
|
189
224
|
- spec/core/proc/proc_tricks_spec.rb
|
190
225
|
- spec/core/range/begin_spec.rb
|
191
226
|
- spec/core/range/case_compare_spec.rb
|
@@ -321,10 +356,11 @@ files:
|
|
321
356
|
- spec/opal/boolean/singleton_class_spec.rb
|
322
357
|
- spec/opal/boolean/to_json_spec.rb
|
323
358
|
- spec/opal/class/bridge_class_spec.rb
|
324
|
-
- spec/opal/
|
359
|
+
- spec/opal/class/instance_methods_spec.rb
|
325
360
|
- spec/opal/hash/to_json_spec.rb
|
326
361
|
- spec/opal/hash/to_native_spec.rb
|
327
362
|
- spec/opal/json/parse_spec.rb
|
363
|
+
- spec/opal/kernel/attribute_spec.rb
|
328
364
|
- spec/opal/kernel/to_json_spec.rb
|
329
365
|
- spec/opal/nil/to_json_spec.rb
|
330
366
|
- spec/opal/numeric/to_json_spec.rb
|
@@ -340,7 +376,8 @@ files:
|
|
340
376
|
- spec/opal/strscan/check_spec.rb
|
341
377
|
- spec/opal/strscan/scan_spec.rb
|
342
378
|
- spec/spec_helper.rb
|
343
|
-
|
379
|
+
- spec/test_case.html
|
380
|
+
homepage: http://opal.github.com
|
344
381
|
licenses: []
|
345
382
|
post_install_message:
|
346
383
|
rdoc_options: []
|
@@ -360,7 +397,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
360
397
|
version: '0'
|
361
398
|
requirements: []
|
362
399
|
rubyforge_project:
|
363
|
-
rubygems_version: 1.8.
|
400
|
+
rubygems_version: 1.8.24
|
364
401
|
signing_key:
|
365
402
|
specification_version: 3
|
366
403
|
summary: Ruby runtime and core library for javascript
|
@@ -373,26 +410,36 @@ test_files:
|
|
373
410
|
- spec/core/array/clone_spec.rb
|
374
411
|
- spec/core/array/collect_spec.rb
|
375
412
|
- spec/core/array/compact_spec.rb
|
413
|
+
- spec/core/array/comparison_spec.rb
|
376
414
|
- spec/core/array/concat_spec.rb
|
377
415
|
- spec/core/array/constructor_spec.rb
|
378
416
|
- spec/core/array/count_spec.rb
|
379
417
|
- spec/core/array/delete_at_spec.rb
|
380
418
|
- spec/core/array/delete_if_spec.rb
|
381
419
|
- spec/core/array/delete_spec.rb
|
420
|
+
- spec/core/array/drop_spec.rb
|
421
|
+
- spec/core/array/dup_spec.rb
|
382
422
|
- spec/core/array/each_index_spec.rb
|
383
423
|
- spec/core/array/each_spec.rb
|
384
424
|
- spec/core/array/element_reference_spec.rb
|
385
425
|
- spec/core/array/empty_spec.rb
|
386
|
-
- spec/core/array/
|
426
|
+
- spec/core/array/equal_value_spec.rb
|
387
427
|
- spec/core/array/fetch_spec.rb
|
388
428
|
- spec/core/array/first_spec.rb
|
389
429
|
- spec/core/array/flatten_spec.rb
|
390
430
|
- spec/core/array/include_spec.rb
|
431
|
+
- spec/core/array/index_spec.rb
|
391
432
|
- spec/core/array/insert_spec.rb
|
433
|
+
- spec/core/array/inspect_spec.rb
|
434
|
+
- spec/core/array/intersection_spec.rb
|
435
|
+
- spec/core/array/join_spec.rb
|
436
|
+
- spec/core/array/keep_if_spec.rb
|
392
437
|
- spec/core/array/last_spec.rb
|
393
438
|
- spec/core/array/length_spec.rb
|
394
439
|
- spec/core/array/map_spec.rb
|
395
440
|
- spec/core/array/minus_spec.rb
|
441
|
+
- spec/core/array/multiply_spec.rb
|
442
|
+
- spec/core/array/new_spec.rb
|
396
443
|
- spec/core/array/plus_spec.rb
|
397
444
|
- spec/core/array/pop_spec.rb
|
398
445
|
- spec/core/array/push_spec.rb
|
@@ -401,9 +448,17 @@ test_files:
|
|
401
448
|
- spec/core/array/replace_spec.rb
|
402
449
|
- spec/core/array/reverse_each_spec.rb
|
403
450
|
- spec/core/array/reverse_spec.rb
|
451
|
+
- spec/core/array/rindex_spec.rb
|
452
|
+
- spec/core/array/select_spec.rb
|
453
|
+
- spec/core/array/shift_spec.rb
|
404
454
|
- spec/core/array/size_spec.rb
|
455
|
+
- spec/core/array/slice_spec.rb
|
456
|
+
- spec/core/array/take_spec.rb
|
457
|
+
- spec/core/array/take_while_spec.rb
|
458
|
+
- spec/core/array/to_a_spec.rb
|
405
459
|
- spec/core/array/to_ary_spec.rb
|
406
460
|
- spec/core/array/uniq_spec.rb
|
461
|
+
- spec/core/array/unshift_spec.rb
|
407
462
|
- spec/core/array/zip_spec.rb
|
408
463
|
- spec/core/class/fixtures/classes.rb
|
409
464
|
- spec/core/class/new_spec.rb
|
@@ -435,8 +490,12 @@ test_files:
|
|
435
490
|
- spec/core/hash/assoc_spec.rb
|
436
491
|
- spec/core/hash/clear_spec.rb
|
437
492
|
- spec/core/hash/clone_spec.rb
|
493
|
+
- spec/core/hash/constructor_spec.rb
|
494
|
+
- spec/core/hash/default_proc_spec.rb
|
438
495
|
- spec/core/hash/default_spec.rb
|
439
496
|
- spec/core/hash/delete_if_spec.rb
|
497
|
+
- spec/core/hash/delete_spec.rb
|
498
|
+
- spec/core/hash/dup_spec.rb
|
440
499
|
- spec/core/hash/each_key_spec.rb
|
441
500
|
- spec/core/hash/each_pair_spec.rb
|
442
501
|
- spec/core/hash/each_spec.rb
|
@@ -461,18 +520,28 @@ test_files:
|
|
461
520
|
- spec/core/hash/merge_spec.rb
|
462
521
|
- spec/core/hash/new_spec.rb
|
463
522
|
- spec/core/hash/rassoc_spec.rb
|
523
|
+
- spec/core/hash/reject_spec.rb
|
464
524
|
- spec/core/hash/replace_spec.rb
|
465
525
|
- spec/core/hash/select_spec.rb
|
466
526
|
- spec/core/hash/shift_spec.rb
|
467
527
|
- spec/core/hash/size_spec.rb
|
528
|
+
- spec/core/hash/to_a_spec.rb
|
468
529
|
- spec/core/hash/update_spec.rb
|
469
530
|
- spec/core/hash/value_spec.rb
|
470
531
|
- spec/core/hash/values_at_spec.rb
|
471
532
|
- spec/core/hash/values_spec.rb
|
533
|
+
- spec/core/kernel/Array_spec.rb
|
534
|
+
- spec/core/kernel/class_spec.rb
|
472
535
|
- spec/core/kernel/define_singleton_method_spec.rb
|
473
536
|
- spec/core/kernel/eql_spec.rb
|
537
|
+
- spec/core/kernel/equal_spec.rb
|
474
538
|
- spec/core/kernel/equal_value_spec.rb
|
539
|
+
- spec/core/kernel/extend_spec.rb
|
540
|
+
- spec/core/kernel/instance_eval_spec.rb
|
541
|
+
- spec/core/kernel/instance_variable_get_spec.rb
|
542
|
+
- spec/core/kernel/instance_variable_set_spec.rb
|
475
543
|
- spec/core/kernel/loop_spec.rb
|
544
|
+
- spec/core/kernel/match_spec.rb
|
476
545
|
- spec/core/kernel/nil_spec.rb
|
477
546
|
- spec/core/kernel/proc_spec.rb
|
478
547
|
- spec/core/kernel/rand_spec.rb
|
@@ -481,6 +550,9 @@ test_files:
|
|
481
550
|
- spec/core/kernel/tap_spec.rb
|
482
551
|
- spec/core/kernel/to_s_spec.rb
|
483
552
|
- spec/core/matchdata/to_a_spec.rb
|
553
|
+
- spec/core/module/alias_method_spec.rb
|
554
|
+
- spec/core/module/ancestors_spec.rb
|
555
|
+
- spec/core/module/append_features_spec.rb
|
484
556
|
- spec/core/nil/and_spec.rb
|
485
557
|
- spec/core/nil/inspect_spec.rb
|
486
558
|
- spec/core/nil/nil_spec.rb
|
@@ -491,6 +563,7 @@ test_files:
|
|
491
563
|
- spec/core/nil/to_s_spec.rb
|
492
564
|
- spec/core/nil/xor_spec.rb
|
493
565
|
- spec/core/numeric/equal_value_spec.rb
|
566
|
+
- spec/core/proc/call_spec.rb
|
494
567
|
- spec/core/proc/proc_tricks_spec.rb
|
495
568
|
- spec/core/range/begin_spec.rb
|
496
569
|
- spec/core/range/case_compare_spec.rb
|
@@ -626,10 +699,11 @@ test_files:
|
|
626
699
|
- spec/opal/boolean/singleton_class_spec.rb
|
627
700
|
- spec/opal/boolean/to_json_spec.rb
|
628
701
|
- spec/opal/class/bridge_class_spec.rb
|
629
|
-
- spec/opal/
|
702
|
+
- spec/opal/class/instance_methods_spec.rb
|
630
703
|
- spec/opal/hash/to_json_spec.rb
|
631
704
|
- spec/opal/hash/to_native_spec.rb
|
632
705
|
- spec/opal/json/parse_spec.rb
|
706
|
+
- spec/opal/kernel/attribute_spec.rb
|
633
707
|
- spec/opal/kernel/to_json_spec.rb
|
634
708
|
- spec/opal/nil/to_json_spec.rb
|
635
709
|
- spec/opal/numeric/to_json_spec.rb
|
@@ -645,3 +719,5 @@ test_files:
|
|
645
719
|
- spec/opal/strscan/check_spec.rb
|
646
720
|
- spec/opal/strscan/scan_spec.rb
|
647
721
|
- spec/spec_helper.rb
|
722
|
+
- spec/test_case.html
|
723
|
+
has_rdoc:
|
data/core/erb.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
# A wapper for ERB templates in Opal. Other templates may be used
|
2
|
-
class ERB
|
3
|
-
|
4
|
-
# @private Stores all registered instances
|
5
|
-
@templates = {}
|
6
|
-
def self.[]=(name, instance)
|
7
|
-
@templates[name] = instance
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.[](name)
|
11
|
-
@templates[name]
|
12
|
-
end
|
13
|
-
|
14
|
-
def initialize(name, &body)
|
15
|
-
ERB[name] = self
|
16
|
-
@body = body
|
17
|
-
end
|
18
|
-
|
19
|
-
# Run this erb template against the given context. Unlike ERB, opals
|
20
|
-
# implementation uses a normal object as a context.
|
21
|
-
#
|
22
|
-
# view = UserView.new
|
23
|
-
# ERB[:user_view].render(view)
|
24
|
-
#
|
25
|
-
# @param [Object] context
|
26
|
-
# @result [String]
|
27
|
-
def render(content)
|
28
|
-
content.instance_eval(&@body)
|
29
|
-
end
|
30
|
-
|
31
|
-
alias :result :render
|
32
|
-
end
|
data/lib/opal/erb_parser.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'opal/parser'
|
2
|
-
|
3
|
-
module Opal
|
4
|
-
class ERBParser
|
5
|
-
|
6
|
-
def parse(str, name = 'erb')
|
7
|
-
Parser.new.parse compile(str, name)
|
8
|
-
end
|
9
|
-
|
10
|
-
def compile(str, name)
|
11
|
-
res = "ERB.new('#{name}') do\nout = []\nout.<<(\"" +
|
12
|
-
str.gsub('"', '\\"'
|
13
|
-
).gsub(/<%=([\s\S]+?)%>/) do
|
14
|
-
"\")\nout.<<(" + $1.gsub(/\\'/, "'").gsub(/\\"/, '"') + ")\nout.<<(\""
|
15
|
-
end.gsub(/<%([\s\S]+?)%>/) do
|
16
|
-
"\")\n" + $1 + "\nout.<<(\""
|
17
|
-
end + "\")\nout.join\nend"
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
data/spec/opal/erb/erb_spec.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
describe 'ERB' do
|
2
|
-
before do
|
3
|
-
opal_eval(Opal::ERBParser.new.compile("<div><%= @some_data %></div>", "simple_test"))
|
4
|
-
@simple = ERB['simple_test']
|
5
|
-
|
6
|
-
opal_eval(Opal::ERBParser.new.compile('<div class="foo">hello <%= "there " + @name %></div>', "quoted_test"))
|
7
|
-
@quoted = ERB['quoted_test']
|
8
|
-
end
|
9
|
-
|
10
|
-
it "should create an instance for each template by its basename" do
|
11
|
-
@simple.should be_kind_of(ERB)
|
12
|
-
end
|
13
|
-
|
14
|
-
it "should execute the body and return the result as a string, with #result" do
|
15
|
-
@some_data = "hello"
|
16
|
-
@simple.render(self).should == "<div>hello</div>"
|
17
|
-
end
|
18
|
-
|
19
|
-
it "should accept quotes in strings" do
|
20
|
-
@name = "adam"
|
21
|
-
@quoted.render(self).should == "<div class=\"foo\">hello there adam</div>"
|
22
|
-
end
|
23
|
-
end
|