Class: RBlade::CompilesStatements::CompilesForm
- Inherits:
-
Object
- Object
- RBlade::CompilesStatements::CompilesForm
- Defined in:
- lib/rblade/compiler/statements/compiles_form.rb
Instance Method Summary collapse
- #compile_delete(args) ⇒ Object
- #compile_method(args) ⇒ Object
- #compile_old(args) ⇒ Object
- #compile_patch(args) ⇒ Object
- #compile_put(args) ⇒ Object
Instance Method Details
#compile_delete(args) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/rblade/compiler/statements/compiles_form.rb', line 14 def compile_delete(args) unless args.nil? raise RBladeTemplateError.new "Delete statement: wrong number of arguments (given #{args.count}, expecting 0)" end compile_method(["'DELETE'"]) end |
#compile_method(args) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/rblade/compiler/statements/compiles_form.rb', line 6 def compile_method(args) if args&.count != 1 raise RBladeTemplateError.new "Method statement: wrong number of arguments (given #{args&.count || 0}, expecting 1)" end %(@output_buffer.raw_buffer<<-"<input type=\\"hidden\\" name=\\"_method\\" value=\\"\#{#{args[0]}}\\">";) end |
#compile_old(args) ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/rblade/compiler/statements/compiles_form.rb', line 38 def compile_old(args) if args.nil? || args.count > 2 raise RBladeTemplateError.new "Old statement: wrong number of arguments (given #{args&.count || 0}, expecting 1 or 2)" end default_value = args[1] || "''" "@output_buffer.raw_buffer<<params.fetch(#{args[0]},#{default_value});" end |
#compile_patch(args) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/rblade/compiler/statements/compiles_form.rb', line 22 def compile_patch(args) unless args.nil? raise RBladeTemplateError.new "Patch statement: wrong number of arguments (given #{args.count}, expecting 0)" end compile_method(["'PATCH'"]) end |
#compile_put(args) ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/rblade/compiler/statements/compiles_form.rb', line 30 def compile_put(args) unless args.nil? raise RBladeTemplateError.new "Put statement: wrong number of arguments (given #{args.count}, expecting 0)" end compile_method(["'PUT'"]) end |