rblade 2.0.2 → 3.0.0

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.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +24 -0
  3. data/CHANGELOG.md +11 -0
  4. data/README.md +83 -16
  5. data/REFERENCE.md +4 -2
  6. data/do +4 -4
  7. data/docker-compose.yml +4 -1
  8. data/lib/rblade/compiler/compiles_comments.rb +2 -2
  9. data/lib/rblade/compiler/compiles_components.rb +26 -5
  10. data/lib/rblade/compiler/compiles_injections.rb +81 -0
  11. data/lib/rblade/compiler/compiles_statements.rb +69 -64
  12. data/lib/rblade/compiler/compiles_verbatim.rb +1 -1
  13. data/lib/rblade/compiler/statements/compiles_component_helpers.rb +17 -13
  14. data/lib/rblade/compiler/statements/compiles_conditionals.rb +18 -18
  15. data/lib/rblade/compiler/statements/compiles_form.rb +8 -8
  16. data/lib/rblade/compiler/statements/compiles_html_attributes.rb +2 -2
  17. data/lib/rblade/compiler/statements/compiles_inline_ruby.rb +1 -1
  18. data/lib/rblade/compiler/statements/compiles_loops.rb +11 -11
  19. data/lib/rblade/compiler/statements/compiles_once.rb +3 -3
  20. data/lib/rblade/compiler/statements/compiles_stacks.rb +5 -5
  21. data/lib/rblade/compiler/tokenizes_components.rb +30 -31
  22. data/lib/rblade/compiler/tokenizes_statements.rb +29 -30
  23. data/lib/rblade/compiler.rb +20 -19
  24. data/lib/rblade/component_store.rb +20 -20
  25. data/lib/rblade/helpers/attributes_manager.rb +10 -9
  26. data/lib/rblade/helpers/class_manager.rb +1 -1
  27. data/lib/rblade/helpers/slot_manager.rb +2 -2
  28. data/lib/rblade/helpers/stack_manager.rb +3 -3
  29. data/lib/rblade/helpers/style_manager.rb +1 -1
  30. data/lib/rblade/helpers/tokenizer.rb +5 -5
  31. data/lib/rblade/rails_template.rb +9 -2
  32. data/lib/rblade/railtie.rb +34 -2
  33. data/rblade.gemspec +4 -1
  34. metadata +50 -8
  35. data/lib/rblade/compiler/compiles_prints.rb +0 -83
  36. data/lib/rblade/compiler/compiles_ruby.rb +0 -59
@@ -23,7 +23,7 @@ module RBlade
23
23
 
24
24
  name = token.value[:name]
25
25
  arguments = token.value[:arguments]
26
- handler = getHandler(name)
26
+ handler_class, handler = get_handler(name)
27
27
 
28
28
  handler_arguments = []
29
29
  handler.parameters.each do |parameter|
@@ -34,10 +34,12 @@ module RBlade
34
34
  handler_arguments.push tokens
35
35
  when :token_index
36
36
  handler_arguments.push token_index
37
+ else
38
+ handler_arguments.push nil
37
39
  end
38
40
  end
39
41
 
40
- token.value = if handler.is_a? Proc
42
+ token.value = if handler_class == "proc"
41
43
  "@output_buffer.raw_buffer<<-'#{RBlade.escape_quotes(handler.call(*handler_arguments).to_s)}';"
42
44
  else
43
45
  handler.call(*handler_arguments)
@@ -46,97 +48,100 @@ module RBlade
46
48
  end
47
49
  end
48
50
 
49
- def compileEnd
51
+ def compile_end
50
52
  "end;"
51
53
  end
52
54
 
53
55
  def self.has_handler(name)
54
- name = name.downcase
55
- @@statement_handlers[name.tr("_", "")].present? || name.start_with?("end")
56
+ statement_handlers[name].present? || (name.start_with?("end") && name != "endruby")
56
57
  end
57
58
 
58
59
  def self.register_handler(name, &block)
59
- @@statement_handlers[name.tr("_", "").downcase] = ["proc", block]
60
+ statement_handlers[name.tr("_", "").downcase] = ["proc", block]
61
+ end
62
+
63
+ def self.register_raw_handler(name, &block)
64
+ statement_handlers[name.tr("_", "").downcase] = ["raw_proc", block]
60
65
  end
61
66
 
62
67
  private
63
68
 
64
- def getHandler(name)
65
- handler_class, handler_method = @@statement_handlers[name.tr("_", "").downcase]
69
+ def get_handler(name)
70
+ handler_class, handler_method = statement_handlers[name]
66
71
 
67
- if handler_class == "proc"
68
- return handler_method
72
+ if handler_class == "proc" || handler_class == "raw_proc"
73
+ return [handler_class, handler_method]
69
74
  end
70
75
 
71
76
  if !handler_class&.method_defined?(handler_method)
72
77
  if name.start_with? "end"
73
78
  ## Fallback to the default end handler
74
- handler_class, handler_method = @@statement_handlers["end"]
79
+ handler_class, handler_method = statement_handlers["end"]
75
80
  else
76
81
  raise RBladeTemplateError.new "Unhandled statement: @#{name}"
77
82
  end
78
83
  end
79
84
 
80
85
  if handler_class == CompilesStatements
81
- @@handler_instances[handler_class] = self
86
+ handler_instances[handler_class] = self
82
87
  else
83
- @@handler_instances[handler_class] ||= handler_class.new
88
+ handler_instances[handler_class] ||= handler_class.new
84
89
  end
85
90
 
86
- @@handler_instances[handler_class].method(handler_method)
91
+ [handler_class, handler_instances[handler_class].method(handler_method)]
87
92
  end
88
93
 
89
- @@handler_instances = {}
90
-
91
- @@statement_handlers = {
92
- "blank?" => [CompilesConditionals, :compileBlank],
93
- "break" => [CompilesLoops, :compileBreak],
94
- "case" => [CompilesConditionals, :compileCase],
95
- "checked" => [CompilesConditionals, :compileChecked],
96
- "class" => [CompilesHtmlAttributes, :compileClass],
97
- "defined?" => [CompilesConditionals, :compileDefined],
98
- "delete" => [CompilesForm, :compileDelete],
99
- "disabled" => [CompilesConditionals, :compileDisabled],
100
- "else" => [CompilesConditionals, :compileElse],
101
- "elsif" => [CompilesConditionals, :compileElsif],
102
- "each" => [CompilesLoops, :compileEach],
103
- "eachelse" => [CompilesLoops, :compileEachElse],
104
- "eachwithindex" => [CompilesLoops, :compileEachWithIndex],
105
- "eachwithindexelse" => [CompilesLoops, :compileEachWithIndexElse],
106
- "empty" => [CompilesLoops, :compileEmpty],
107
- "empty?" => [CompilesConditionals, :compileEmpty],
108
- "end" => [CompilesStatements, :compileEnd],
109
- "env" => [CompilesConditionals, :compileEnv],
110
- "for" => [CompilesLoops, :compileFor],
111
- "forelse" => [CompilesLoops, :compileForElse],
112
- "if" => [CompilesConditionals, :compileIf],
113
- "method" => [CompilesForm, :compileMethod],
114
- "next" => [CompilesLoops, :compileNext],
115
- "nil?" => [CompilesConditionals, :compileNil],
116
- "old" => [CompilesForm, :compileOld],
117
- "once" => [CompilesOnce, :compileOnce],
118
- "patch" => [CompilesForm, :compilePatch],
119
- "prepend" => [CompilesStacks, :compilePrepend],
120
- "prependif" => [CompilesStacks, :compilePrependIf],
121
- "prependonce" => [CompilesOnce, :compilePrependOnce],
122
- "present?" => [CompilesConditionals, :compilePresent],
123
- "production" => [CompilesConditionals, :compileProduction],
124
- "props" => [CompilesComponentHelpers, :compileProps],
125
- "push" => [CompilesStacks, :compilePush],
126
- "pushif" => [CompilesStacks, :compilePushIf],
127
- "pushonce" => [CompilesOnce, :compilePushOnce],
128
- "put" => [CompilesForm, :compilePut],
129
- "readonly" => [CompilesConditionals, :compileReadonly],
130
- "required" => [CompilesConditionals, :compileRequired],
94
+ cattr_accessor :handler_instances, default: {}
95
+
96
+ cattr_accessor :statement_handlers, default: {
97
+ "blank?" => [CompilesConditionals, :compile_blank],
98
+ "break" => [CompilesLoops, :compile_break],
99
+ "case" => [CompilesConditionals, :compile_case],
100
+ "checked" => [CompilesConditionals, :compile_checked],
101
+ "class" => [CompilesHtmlAttributes, :compile_class],
102
+ "defined?" => [CompilesConditionals, :compile_defined],
103
+ "delete" => [CompilesForm, :compile_delete],
104
+ "disabled" => [CompilesConditionals, :compile_disabled],
105
+ "else" => [CompilesConditionals, :compile_else],
106
+ "elsif" => [CompilesConditionals, :compile_elsif],
107
+ "each" => [CompilesLoops, :compile_each],
108
+ "eachelse" => [CompilesLoops, :compile_each_else],
109
+ "eachwithindex" => [CompilesLoops, :compile_each_with_index],
110
+ "eachwithindexelse" => [CompilesLoops, :compile_each_with_index_else],
111
+ "empty" => [CompilesLoops, :compile_empty],
112
+ "empty?" => [CompilesConditionals, :compile_empty],
113
+ "end" => [CompilesStatements, :compile_end],
114
+ "env" => [CompilesConditionals, :compile_env],
115
+ "for" => [CompilesLoops, :compile_for],
116
+ "forelse" => [CompilesLoops, :compile_for_else],
117
+ "if" => [CompilesConditionals, :compile_if],
118
+ "method" => [CompilesForm, :compile_method],
119
+ "next" => [CompilesLoops, :compile_next],
120
+ "nil?" => [CompilesConditionals, :compile_nil],
121
+ "old" => [CompilesForm, :compile_old],
122
+ "once" => [CompilesOnce, :compile_once],
123
+ "patch" => [CompilesForm, :compile_patch],
124
+ "prepend" => [CompilesStacks, :compile_prepend],
125
+ "prependif" => [CompilesStacks, :compile_prepend_if],
126
+ "prependonce" => [CompilesOnce, :compile_prepend_once],
127
+ "present?" => [CompilesConditionals, :compile_present],
128
+ "production" => [CompilesConditionals, :compile_production],
129
+ "props" => [CompilesComponentHelpers, :compile_props],
130
+ "push" => [CompilesStacks, :compile_push],
131
+ "pushif" => [CompilesStacks, :compile_push_if],
132
+ "pushonce" => [CompilesOnce, :compile_push_once],
133
+ "put" => [CompilesForm, :compile_put],
134
+ "readonly" => [CompilesConditionals, :compile_readonly],
135
+ "required" => [CompilesConditionals, :compile_required],
131
136
  "ruby" => [CompilesInlineRuby, :compile],
132
- "selected" => [CompilesConditionals, :compileSelected],
133
- "shouldrender" => [CompilesComponentHelpers, :compileShouldRender],
134
- "stack" => [CompilesStacks, :compileStack],
135
- "style" => [CompilesHtmlAttributes, :compileStyle],
136
- "unless" => [CompilesConditionals, :compileUnless],
137
- "until" => [CompilesLoops, :compileUntil],
138
- "when" => [CompilesConditionals, :compileWhen],
139
- "while" => [CompilesLoops, :compileWhile]
137
+ "selected" => [CompilesConditionals, :compile_selected],
138
+ "shouldrender" => [CompilesComponentHelpers, :compile_should_render],
139
+ "stack" => [CompilesStacks, :compile_stack],
140
+ "style" => [CompilesHtmlAttributes, :compile_style],
141
+ "unless" => [CompilesConditionals, :compile_unless],
142
+ "until" => [CompilesLoops, :compile_until],
143
+ "when" => [CompilesConditionals, :compile_when],
144
+ "while" => [CompilesLoops, :compile_while],
140
145
  }
141
146
  end
142
147
  end
@@ -6,7 +6,7 @@ module RBlade
6
6
  tokens.map! do |token|
7
7
  next(token) if token.type != :unprocessed
8
8
 
9
- segments = token.value.split(/\s?(?<!\w)(@verbatim)(?!\w)\s?(.+?)\s?(?<!\w)@end_?verbatim(?!\w)\s?/mi)
9
+ segments = token.value.split(/\s?(?<!\w)(@verbatim)(?!\w)\s?((?:[^@\s]++|[@\s])+?)\s?(?<!\w)@end_?verbatim(?!\w)\s?/i)
10
10
 
11
11
  i = 0
12
12
  while i < segments.count
@@ -5,7 +5,9 @@ require "rblade/helpers/tokenizer"
5
5
  module RBlade
6
6
  class CompilesStatements
7
7
  class CompilesComponentHelpers
8
- def compileShouldRender args
8
+ RUBY_RESERVED_KEYWORDS = %w[__FILE__ __LINE__ alias and begin BEGIN break case class def defined? do else elsif end END ensure false for if in module next nil not or redo rescue retry return self super then true undef unless until when while yield].freeze
9
+
10
+ def compile_should_render(args)
9
11
  if args&.count != 1
10
12
  raise RBladeTemplateError.new "Should render statement: wrong number of arguments (given #{args&.count || 0}, expecting 1)"
11
13
  end
@@ -13,18 +15,22 @@ module RBlade
13
15
  "unless(#{args[0]});return'';end;"
14
16
  end
15
17
 
16
- def compileProps args, tokens
17
- props = extractProps args
18
+ def compile_props(args, tokens)
19
+ props = extract_props args
18
20
  props.map do |key, value|
19
- # `_required` is deprecated. Use `required`. To be removed in 2.0.0
20
- compiled_code = if value == "_required" || value == "required"
21
+ compiled_code = if RBlade.direct_component_rendering
22
+ "if !attributes.has?(:'#{RBlade.escape_quotes(key)}') && content_for?(:'#{RBlade.escape_quotes(key)}');attributes[:'#{RBlade.escape_quotes(key)}']=content_for :'#{RBlade.escape_quotes(key)}';end;"
23
+ else
24
+ +""
25
+ end
26
+ compiled_code << if value == "required"
21
27
  "if !attributes.has?(:'#{RBlade.escape_quotes(key)}');raise \"Props statement: #{key} is not defined\";end;"
22
28
  else
23
29
  "attributes.default(:'#{RBlade.escape_quotes(key)}', #{value});"
24
30
  end
25
31
 
26
- if isValidVariableName key
27
- compiled_code += if variableIsSlot key, tokens
32
+ if is_valid_variable_name key
33
+ compiled_code << if variable_is_slot key, tokens
28
34
  "#{key}=RBlade::SlotManager.wrap(attributes.delete :'#{RBlade.escape_quotes(key)}');"
29
35
  else
30
36
  "#{key}=attributes.delete :'#{RBlade.escape_quotes(key)}';"
@@ -37,7 +43,7 @@ module RBlade
37
43
 
38
44
  private
39
45
 
40
- def extractProps prop_strings
46
+ def extract_props(prop_strings)
41
47
  props = {}
42
48
 
43
49
  prop_strings.each do |prop|
@@ -71,10 +77,8 @@ module RBlade
71
77
  props
72
78
  end
73
79
 
74
- RUBY_RESERVED_KEYWORDS = %w[__FILE__ __LINE__ alias and begin BEGIN break case class def defined? do else elsif end END ensure false for if in module next nil not or redo rescue retry return self super then true undef unless until when while yield].freeze
75
-
76
- def isValidVariableName key
77
- return false unless key.match?(/\A[a-zA-Z_][a-zA-Z0-9_]*\Z/)
80
+ def is_valid_variable_name(key)
81
+ return false unless key.match?(/\A[a-zA-Z_][a-zA-Z0-9_]*\z/)
78
82
 
79
83
  return false if RUBY_RESERVED_KEYWORDS.include? key
80
84
 
@@ -82,7 +86,7 @@ module RBlade
82
86
  end
83
87
 
84
88
  # Automatically detect if a variable is a slot by looking for "<var>.attributes"
85
- def variableIsSlot name, tokens
89
+ def variable_is_slot(name, tokens)
86
90
  tokens.any? { |token| token.value.to_s.match? "#{name}.attributes" }
87
91
  end
88
92
  end
@@ -3,7 +3,7 @@
3
3
  module RBlade
4
4
  class CompilesStatements
5
5
  class CompilesConditionals
6
- def compileIf args
6
+ def compile_if(args)
7
7
  if args&.count != 1
8
8
  raise RBladeTemplateError.new "If statement: wrong number of arguments (given #{args&.count || 0}, expecting 1)"
9
9
  end
@@ -11,7 +11,7 @@ module RBlade
11
11
  "if #{args[0]};"
12
12
  end
13
13
 
14
- def compileBlank args
14
+ def compile_blank(args)
15
15
  if args&.count != 1
16
16
  raise RBladeTemplateError.new "Blank? statement: wrong number of arguments (given #{args&.count || 0}, expecting 1)"
17
17
  end
@@ -19,7 +19,7 @@ module RBlade
19
19
  "if (#{args[0]}).blank?;"
20
20
  end
21
21
 
22
- def compileDefined args
22
+ def compile_defined(args)
23
23
  if args&.count != 1
24
24
  raise RBladeTemplateError.new "Defined? statement: wrong number of arguments (given #{args&.count || 0}, expecting 1)"
25
25
  end
@@ -27,7 +27,7 @@ module RBlade
27
27
  "if defined? #{args[0]};"
28
28
  end
29
29
 
30
- def compileEmpty args
30
+ def compile_empty(args)
31
31
  if args&.count != 1
32
32
  raise RBladeTemplateError.new "Empty? statement: wrong number of arguments (given #{args&.count || 0}, expecting 1)"
33
33
  end
@@ -35,7 +35,7 @@ module RBlade
35
35
  "if (#{args[0]}).empty?;"
36
36
  end
37
37
 
38
- def compileNil args
38
+ def compile_nil(args)
39
39
  if args&.count != 1
40
40
  raise RBladeTemplateError.new "Nil? statement: wrong number of arguments (given #{args&.count || 0}, expecting 1)"
41
41
  end
@@ -43,7 +43,7 @@ module RBlade
43
43
  "if (#{args[0]}).nil?;"
44
44
  end
45
45
 
46
- def compilePresent args
46
+ def compile_present(args)
47
47
  if args&.count != 1
48
48
  raise RBladeTemplateError.new "Present? statement: wrong number of arguments (given #{args&.count || 0}, expecting 1)"
49
49
  end
@@ -51,7 +51,7 @@ module RBlade
51
51
  "if (#{args[0]}).present?;"
52
52
  end
53
53
 
54
- def compileElsif args
54
+ def compile_elsif(args)
55
55
  if args&.count != 1
56
56
  raise RBladeTemplateError.new "Elsif statement: wrong number of arguments (given #{args&.count || 0}, expecting 1)"
57
57
  end
@@ -59,7 +59,7 @@ module RBlade
59
59
  "elsif #{args[0]};"
60
60
  end
61
61
 
62
- def compileElse args
62
+ def compile_else(args)
63
63
  unless args.nil?
64
64
  raise RBladeTemplateError.new "Else statement: wrong number of arguments (given #{args.count}, expecting 0)"
65
65
  end
@@ -67,7 +67,7 @@ module RBlade
67
67
  "else;"
68
68
  end
69
69
 
70
- def compileUnless args
70
+ def compile_unless(args)
71
71
  if args&.count != 1
72
72
  raise RBladeTemplateError.new "Unless statement: wrong number of arguments (given #{args&.count || 0}, expecting 1)"
73
73
  end
@@ -75,7 +75,7 @@ module RBlade
75
75
  "unless #{args[0]};"
76
76
  end
77
77
 
78
- def compileCase args
78
+ def compile_case(args)
79
79
  if args&.count != 1
80
80
  raise RBladeTemplateError.new "Case statement: wrong number of arguments (given #{args&.count || 0}, expecting 1)"
81
81
  end
@@ -83,7 +83,7 @@ module RBlade
83
83
  "case #{args[0]};"
84
84
  end
85
85
 
86
- def compileWhen args
86
+ def compile_when(args)
87
87
  if args.nil?
88
88
  raise RBladeTemplateError.new "When statement: wrong number of arguments (given 0, expecting at least 1)"
89
89
  end
@@ -91,7 +91,7 @@ module RBlade
91
91
  "when #{args.join ","};"
92
92
  end
93
93
 
94
- def compileChecked args
94
+ def compile_checked(args)
95
95
  if args&.count != 1
96
96
  raise RBladeTemplateError.new "Checked statement: wrong number of arguments (given #{args&.count || 0}, expecting 1)"
97
97
  end
@@ -99,7 +99,7 @@ module RBlade
99
99
  "if #{args[0]};@output_buffer.raw_buffer<<-'checked';end;"
100
100
  end
101
101
 
102
- def compileDisabled args
102
+ def compile_disabled(args)
103
103
  if args&.count != 1
104
104
  raise RBladeTemplateError.new "Disabled statement: wrong number of arguments (given #{args&.count || 0}, expecting 1)"
105
105
  end
@@ -107,7 +107,7 @@ module RBlade
107
107
  "if #{args[0]};@output_buffer.raw_buffer<<-'disabled';end;"
108
108
  end
109
109
 
110
- def compileReadonly args
110
+ def compile_readonly(args)
111
111
  if args&.count != 1
112
112
  raise RBladeTemplateError.new "Readonly statement: wrong number of arguments (given #{args&.count || 0}, expecting 1)"
113
113
  end
@@ -115,7 +115,7 @@ module RBlade
115
115
  "if #{args[0]};@output_buffer.raw_buffer<<-'readonly';end;"
116
116
  end
117
117
 
118
- def compileRequired args
118
+ def compile_required(args)
119
119
  if args&.count != 1
120
120
  raise RBladeTemplateError.new "Required statement: wrong number of arguments (given #{args&.count || 0}, expecting 1)"
121
121
  end
@@ -123,7 +123,7 @@ module RBlade
123
123
  "if #{args[0]};@output_buffer.raw_buffer<<-'required';end;"
124
124
  end
125
125
 
126
- def compileSelected args
126
+ def compile_selected(args)
127
127
  if args&.count != 1
128
128
  raise RBladeTemplateError.new "Selected statement: wrong number of arguments (given #{args&.count || 0}, expecting 1)"
129
129
  end
@@ -131,7 +131,7 @@ module RBlade
131
131
  "if #{args[0]};@output_buffer.raw_buffer<<-'selected';end;"
132
132
  end
133
133
 
134
- def compileEnv args
134
+ def compile_env(args)
135
135
  if args&.count != 1
136
136
  raise RBladeTemplateError.new "Env statement: wrong number of arguments (given #{args&.count || 0}, expecting 1)"
137
137
  end
@@ -141,7 +141,7 @@ module RBlade
141
141
  "if Array.wrap(#{environments}).include?(Rails.env);"
142
142
  end
143
143
 
144
- def compileProduction args
144
+ def compile_production(args)
145
145
  unless args.nil?
146
146
  raise RBladeTemplateError.new "Production statement: wrong number of arguments (given #{args.count}, expecting 0)"
147
147
  end
@@ -3,7 +3,7 @@
3
3
  module RBlade
4
4
  class CompilesStatements
5
5
  class CompilesForm
6
- def compileMethod args
6
+ def compile_method(args)
7
7
  if args&.count != 1
8
8
  raise RBladeTemplateError.new "Method statement: wrong number of arguments (given #{args&.count || 0}, expecting 1)"
9
9
  end
@@ -11,31 +11,31 @@ module RBlade
11
11
  %(@output_buffer.raw_buffer<<-"<input type=\\"hidden\\" name=\\"_method\\" value=\\"\#{#{args[0]}}\\">";)
12
12
  end
13
13
 
14
- def compileDelete args
14
+ def compile_delete(args)
15
15
  unless args.nil?
16
16
  raise RBladeTemplateError.new "Delete statement: wrong number of arguments (given #{args.count}, expecting 0)"
17
17
  end
18
18
 
19
- compileMethod(["'DELETE'"])
19
+ compile_method(["'DELETE'"])
20
20
  end
21
21
 
22
- def compilePatch args
22
+ def compile_patch(args)
23
23
  unless args.nil?
24
24
  raise RBladeTemplateError.new "Patch statement: wrong number of arguments (given #{args.count}, expecting 0)"
25
25
  end
26
26
 
27
- compileMethod(["'PATCH'"])
27
+ compile_method(["'PATCH'"])
28
28
  end
29
29
 
30
- def compilePut args
30
+ def compile_put(args)
31
31
  unless args.nil?
32
32
  raise RBladeTemplateError.new "Put statement: wrong number of arguments (given #{args.count}, expecting 0)"
33
33
  end
34
34
 
35
- compileMethod(["'PUT'"])
35
+ compile_method(["'PUT'"])
36
36
  end
37
37
 
38
- def compileOld args
38
+ def compile_old(args)
39
39
  if args.nil? || args.count > 2
40
40
  raise RBladeTemplateError.new "Old statement: wrong number of arguments (given #{args&.count || 0}, expecting 1 or 2)"
41
41
  end
@@ -3,7 +3,7 @@
3
3
  module RBlade
4
4
  class CompilesStatements
5
5
  class CompilesHtmlAttributes
6
- def compileClass args
6
+ def compile_class(args)
7
7
  if args&.count != 1
8
8
  raise RBladeTemplateError.new "Class statement: wrong number of arguments (given #{args&.count || 0}, expecting 1)"
9
9
  end
@@ -11,7 +11,7 @@ module RBlade
11
11
  %`@output_buffer.raw_buffer<<-"class=\\"\#{RBlade::ClassManager.new(#{args[0]})}\\"";`
12
12
  end
13
13
 
14
- def compileStyle args
14
+ def compile_style(args)
15
15
  if args&.count != 1
16
16
  raise RBladeTemplateError.new "Style statement: wrong number of arguments (given #{args&.count || 0}, expecting 1)"
17
17
  end
@@ -3,7 +3,7 @@
3
3
  module RBlade
4
4
  class CompilesStatements
5
5
  class CompilesInlineRuby
6
- def compile args
6
+ def compile(args)
7
7
  if args&.count != 1
8
8
  raise RBladeTemplateError.new "Ruby statement: wrong number of arguments (given #{args&.count || 0}, expecting 1)"
9
9
  end
@@ -7,7 +7,7 @@ module RBlade
7
7
  @loop_else_counter = 0
8
8
  end
9
9
 
10
- def compileBreak args
10
+ def compile_break(args)
11
11
  if args&.count&.> 1
12
12
  raise RBladeTemplateError.new "Break statement: wrong number of arguments (given #{args.count}, expecting 0 or 1)"
13
13
  end
@@ -19,7 +19,7 @@ module RBlade
19
19
  end
20
20
  end
21
21
 
22
- def compileEach args
22
+ def compile_each(args)
23
23
  if args.nil? || args.count > 2
24
24
  raise RBladeTemplateError.new "Each statement: wrong number of arguments (given #{args&.count || 0}, expecting 1 or 2)"
25
25
  end
@@ -33,7 +33,7 @@ module RBlade
33
33
  "#{collection}.each do |#{args.join(",")}|;"
34
34
  end
35
35
 
36
- def compileEachWithIndex args
36
+ def compile_each_with_index(args)
37
37
  if args.nil? || args.count > 3
38
38
  raise RBladeTemplateError.new "Each with index statement: wrong number of arguments (given #{args&.count || 0}, expecting 1 to 3)"
39
39
  end
@@ -53,7 +53,7 @@ module RBlade
53
53
  end
54
54
  end
55
55
 
56
- def compileEachElse args
56
+ def compile_each_else(args)
57
57
  if args.nil? || args.count > 2
58
58
  raise RBladeTemplateError.new "Each else statement: wrong number of arguments (given #{args&.count || 0}, expecting 1)"
59
59
  end
@@ -69,7 +69,7 @@ module RBlade
69
69
  "_looped_#{@loop_else_counter}=false;#{collection}.each do |#{args.join(",")}|;_looped_#{@loop_else_counter}=true;"
70
70
  end
71
71
 
72
- def compileEachWithIndexElse args
72
+ def compile_each_with_index_else(args)
73
73
  if args.nil? || args.count > 3
74
74
  raise RBladeTemplateError.new "Each with index statement: wrong number of arguments (given #{args&.count || 0}, expecting 1 to 3)"
75
75
  end
@@ -91,7 +91,7 @@ module RBlade
91
91
  end
92
92
  end
93
93
 
94
- def compileFor args
94
+ def compile_for(args)
95
95
  if args&.count != 1
96
96
  raise RBladeTemplateError.new "For statement: wrong number of arguments (given #{args&.count || 0}, expecting 1)"
97
97
  end
@@ -99,7 +99,7 @@ module RBlade
99
99
  "for #{args[0]};"
100
100
  end
101
101
 
102
- def compileForElse args
102
+ def compile_for_else(args)
103
103
  if args&.count != 1
104
104
  raise RBladeTemplateError.new "For else statement: wrong number of arguments (given #{args&.count || 0}, expecting 1)"
105
105
  end
@@ -108,7 +108,7 @@ module RBlade
108
108
  "_looped_#{@loop_else_counter}=false;for #{args[0]};_looped_#{@loop_else_counter}=true;"
109
109
  end
110
110
 
111
- def compileEmpty args
111
+ def compile_empty(args)
112
112
  unless args.nil?
113
113
  raise RBladeTemplateError.new "Empty statement: wrong number of arguments (given #{args.count}, expecting 0)"
114
114
  end
@@ -118,7 +118,7 @@ module RBlade
118
118
  "end;if !_looped_#{@loop_else_counter + 1};"
119
119
  end
120
120
 
121
- def compileNext args
121
+ def compile_next(args)
122
122
  if args&.count&.> 1
123
123
  raise RBladeTemplateError.new "Next statement: wrong number of arguments (given #{args.count}, expecting 0 or 1)"
124
124
  end
@@ -130,7 +130,7 @@ module RBlade
130
130
  end
131
131
  end
132
132
 
133
- def compileUntil args
133
+ def compile_until(args)
134
134
  if args&.count != 1
135
135
  raise RBladeTemplateError.new "Until statement: wrong number of arguments (given #{args&.count || 0}, expecting 1)"
136
136
  end
@@ -138,7 +138,7 @@ module RBlade
138
138
  "until #{args[0]};"
139
139
  end
140
140
 
141
- def compileWhile args
141
+ def compile_while(args)
142
142
  if args&.count != 1
143
143
  raise RBladeTemplateError.new "While statement: wrong number of arguments (given #{args&.count || 0}, expecting 1)"
144
144
  end
@@ -7,7 +7,7 @@ module RBlade
7
7
  @once_counter = 0
8
8
  end
9
9
 
10
- def compileOnce args
10
+ def compile_once(args)
11
11
  if args&.count&.> 1
12
12
  raise RBladeTemplateError.new "Once statement: wrong number of arguments (given #{args.count}, expecting 0 or 1)"
13
13
  end
@@ -17,7 +17,7 @@ module RBlade
17
17
  "unless @_rblade_once_tokens.include? #{once_id};@_rblade_once_tokens<<#{once_id};"
18
18
  end
19
19
 
20
- def compilePushOnce args
20
+ def compile_push_once(args)
21
21
  if args&.count != 1 && args&.count != 2
22
22
  raise RBladeTemplateError.new "Push once statement: wrong number of arguments (given #{args&.count || 0}, expecting 1 or 2)"
23
23
  end
@@ -27,7 +27,7 @@ module RBlade
27
27
  "(@_rblade_once_tokens.include? #{once_id}) || @_rblade_once_tokens<<#{once_id} && @_rblade_stack_manager.push(#{args[0]}, @output_buffer) do;"
28
28
  end
29
29
 
30
- def compilePrependOnce args
30
+ def compile_prepend_once(args)
31
31
  if args&.count != 1 && args&.count != 2
32
32
  raise RBladeTemplateError.new "Prepend once statement: wrong number of arguments (given #{args&.count || 0}, expecting 1 or 2)"
33
33
  end