rango 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +6 -0
- data/CONTRIBUTORS +1 -0
- data/README.textile +4 -1
- data/bin/rango +1 -1
- data/lib/rango.rb +78 -12
- data/lib/rango/contrib/pagination.rb +2 -0
- data/lib/rango/controller.rb +58 -12
- data/lib/rango/environments.rb +26 -0
- data/lib/rango/exceptions.rb +2 -14
- data/lib/rango/gv.rb +7 -90
- data/lib/rango/gv/static.rb +22 -0
- data/lib/rango/helpers.rb +0 -1
- data/lib/rango/helpers/assets.rb +2 -0
- data/lib/rango/helpers/general.rb +1 -0
- data/lib/rango/helpers/syntax.rb +2 -0
- data/lib/rango/mini.rb +30 -0
- data/lib/rango/mixins/application.rb +5 -3
- data/lib/rango/mixins/configurable.rb +1 -0
- data/lib/rango/mixins/render.rb +13 -84
- data/lib/rango/orm/tasks/datamapper.rake +2 -2
- data/lib/rango/project.rb +2 -2
- data/lib/rango/rack/middlewares/basic.rb +15 -11
- data/lib/rango/rack/request.rb +5 -3
- data/lib/rango/router.rb +20 -2
- data/lib/rango/router/adapters/rack_mount.rb +0 -1
- data/lib/rango/router/adapters/rack_router.rb +0 -1
- data/lib/rango/router/adapters/urlmap.rb +0 -1
- data/lib/rango/router/adapters/usher.rb +0 -1
- data/lib/rango/settings/framework.rb +2 -43
- data/lib/rango/templates/{erubis.rb → exts/erubis.rb} +0 -19
- data/lib/rango/templates/exts/tilt.rb +16 -0
- data/lib/rango/templates/helpers.rb +107 -0
- data/lib/rango/templates/template.rb +44 -115
- data/lib/rango/utils.rb +9 -4
- data/spec/rango/controller_spec.rb +3 -1
- data/spec/rango/environments_spec.rb +68 -0
- data/spec/rango/gv_spec.rb +10 -0
- data/spec/rango/mini_spec.rb +58 -0
- data/spec/rango/project_spec.rb +1 -1
- data/spec/rango/templates/template_spec.rb +81 -0
- data/spec/rango/utils_spec.rb +33 -0
- data/spec/rango_spec.rb +3 -17
- data/spec/spec_helper.rb +5 -3
- data/spec/stubs/config.ru +5 -0
- data/spec/stubs/templates/capture.html.erb +1 -1
- data/spec/stubs/templates/erubis.html.erubis +2 -0
- data/spec/stubs/templates/inheritance/basic/base.html.haml +2 -0
- data/spec/stubs/templates/inheritance/basic/index.html.haml +2 -0
- data/spec/stubs/templates/inheritance/capture/erb/base.html.erb +3 -0
- data/spec/stubs/templates/inheritance/capture/erb/index.html.erb +4 -0
- data/spec/stubs/templates/inheritance/capture/erubis/base.html.erubis +3 -0
- data/spec/stubs/templates/inheritance/capture/erubis/index.html.erubis +4 -0
- data/spec/stubs/templates/inheritance/capture/haml/base.html.haml +2 -0
- data/spec/stubs/templates/inheritance/capture/haml/index.html.haml +3 -0
- data/spec/stubs/templates/test.html.haml +1 -0
- data/spec/stubs/templates/variables.html.haml +1 -0
- data/stubs/app/content/init.rb.rbt +2 -1
- data/stubs/app/content/views.rb.rbt +2 -0
- data/stubs/bigapp/content/views/%controller%.rb.rbt +2 -0
- data/stubs/project/content/config.ru.rbt +3 -0
- data/stubs/project/content/init.rb.rbt +11 -5
- data/stubs/project/content/settings.rb +0 -2
- data/stubs/project/content/settings_local.rb.rbt +1 -1
- data/stubs/project/content/templates/base.html.haml.rbt +1 -0
- metadata +42 -329
- data/examples/README.textile +0 -12
- data/examples/blog/Gemfile +0 -80
- data/examples/blog/Rakefile +0 -12
- data/examples/blog/TODO.txt +0 -0
- data/examples/blog/bin/autospec +0 -3
- data/examples/blog/bin/css2sass +0 -3
- data/examples/blog/bin/cucumber +0 -3
- data/examples/blog/bin/haml +0 -3
- data/examples/blog/bin/html2haml +0 -3
- data/examples/blog/bin/htmldiff +0 -3
- data/examples/blog/bin/launchy +0 -3
- data/examples/blog/bin/ldiff +0 -3
- data/examples/blog/bin/nokogiri +0 -3
- data/examples/blog/bin/racksh +0 -3
- data/examples/blog/bin/rackup +0 -3
- data/examples/blog/bin/rake +0 -3
- data/examples/blog/bin/rango +0 -3
- data/examples/blog/bin/sass +0 -3
- data/examples/blog/bin/shotgun +0 -3
- data/examples/blog/bin/simple-templater +0 -3
- data/examples/blog/bin/spec +0 -3
- data/examples/blog/bin/tt +0 -3
- data/examples/blog/blog/init.rb +0 -9
- data/examples/blog/blog/models.rb +0 -21
- data/examples/blog/blog/views.rb +0 -16
- data/examples/blog/config.ru +0 -19
- data/examples/blog/gems/cache/addressable-2.1.1.gem +0 -0
- data/examples/blog/gems/cache/builder-2.1.2.gem +0 -0
- data/examples/blog/gems/cache/bundler-0.7.0.gem +0 -0
- data/examples/blog/gems/cache/cli-0.0.1.gem +0 -0
- data/examples/blog/gems/cache/configuration-1.1.0.gem +0 -0
- data/examples/blog/gems/cache/cucumber-0.4.4.gem +0 -0
- data/examples/blog/gems/cache/data_objects-0.10.0.gem +0 -0
- data/examples/blog/gems/cache/diff-lcs-1.1.2.gem +0 -0
- data/examples/blog/gems/cache/dm-core-0.10.1.gem +0 -0
- data/examples/blog/gems/cache/dm-timestamps-0.10.1.gem +0 -0
- data/examples/blog/gems/cache/do_mysql-0.10.0.gem +0 -0
- data/examples/blog/gems/cache/do_sqlite3-0.10.0.gem +0 -0
- data/examples/blog/gems/cache/extlib-0.9.13.gem +0 -0
- data/examples/blog/gems/cache/fuzzyhash-0.0.9.gem +0 -0
- data/examples/blog/gems/cache/haml-2.2.14.gem +0 -0
- data/examples/blog/gems/cache/launchy-0.3.3.gem +0 -0
- data/examples/blog/gems/cache/media-path-0.1.gem +0 -0
- data/examples/blog/gems/cache/nokogiri-1.4.0.gem +0 -0
- data/examples/blog/gems/cache/polyglot-0.2.9.gem +0 -0
- data/examples/blog/gems/cache/rack-1.0.1.gem +0 -0
- data/examples/blog/gems/cache/rack-test-0.5.2.gem +0 -0
- data/examples/blog/gems/cache/racksh-0.9.4.2.gem +0 -0
- data/examples/blog/gems/cache/rake-0.8.7.gem +0 -0
- data/examples/blog/gems/cache/rango-0.1.0.gem +0 -0
- data/examples/blog/gems/cache/rspec-1.2.9.gem +0 -0
- data/examples/blog/gems/cache/rubyexts-0.0.1.gem +0 -0
- data/examples/blog/gems/cache/shotgun-0.4.gem +0 -0
- data/examples/blog/gems/cache/simple-templater-0.0.1.gem +0 -0
- data/examples/blog/gems/cache/term-ansicolor-1.0.4.gem +0 -0
- data/examples/blog/gems/cache/treetop-1.4.2.gem +0 -0
- data/examples/blog/gems/cache/usher-0.5.11.gem +0 -0
- data/examples/blog/gems/cache/webrat-0.5.3.gem +0 -0
- data/examples/blog/init.rb +0 -49
- data/examples/blog/settings.rb +0 -15
- data/examples/blog/settings_local.rb +0 -6
- data/examples/blog/spec/blog/init_spec.rb +0 -7
- data/examples/blog/spec/blog/models_spec.rb +0 -28
- data/examples/blog/spec/blog/views_spec.rb +0 -22
- data/examples/blog/spec/spec.opts +0 -5
- data/examples/blog/spec/spec_helper.rb +0 -27
- data/examples/blog/templates/base.html.haml +0 -16
- data/examples/blog/templates/index.html.haml +0 -12
- data/lib/rango/boot.rb +0 -55
- data/lib/rango/helpers/README +0 -179
- data/lib/rango/helpers/merb-helpers.rb +0 -3
- data/lib/rango/helpers/merb-helpers/core_ext.rb +0 -58
- data/lib/rango/helpers/merb-helpers/core_ext/numeric.rb +0 -389
- data/lib/rango/helpers/merb-helpers/date_time_formatting.rb +0 -146
- data/lib/rango/helpers/merb-helpers/date_time_helpers.rb +0 -191
- data/lib/rango/helpers/merb-helpers/form/builder.rb +0 -450
- data/lib/rango/helpers/merb-helpers/form/helpers.rb +0 -453
- data/lib/rango/helpers/merb-helpers/form_helpers.rb +0 -21
- data/lib/rango/helpers/merb-helpers/tag_helpers.rb +0 -63
- data/lib/rango/helpers/merb-helpers/text_helpers.rb +0 -73
- data/lib/rango/loggers/logger.rb +0 -100
- data/lib/rango/mixins/chainable.rb +0 -68
- data/lib/rango/mixins/hookable.rb +0 -32
- data/lib/rango/mixins/import.rb +0 -89
- data/lib/rango/mixins/mini.rb +0 -29
- data/lib/rango/mixins/strategy.rb +0 -28
- data/lib/rango/rango.rb +0 -93
- data/lib/rango/router/specification.txt +0 -11
- data/lib/rango/templates/adapter.rb +0 -19
- data/lib/rango/templates/adapters/erb.rb +0 -63
- data/lib/rango/templates/adapters/erubis.rb +0 -65
- data/lib/rango/templates/adapters/haml.rb +0 -26
- data/lib/rango/templates/templates.txt +0 -39
- data/spec/factories.rb +0 -22
- data/spec/rango/boot_spec.rb +0 -15
- data/spec/rango/helpers/merb-helpers/core_ext/numeric_spec.rb +0 -0
- data/spec/rango/helpers/merb-helpers/core_ext_spec.rb +0 -21
- data/spec/rango/helpers/merb-helpers/date_time_formatting_spec.rb +0 -0
- data/spec/rango/helpers/merb-helpers/date_time_helpers_spec.rb +0 -0
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/application.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/bound_check_box.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/bound_file_field.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/bound_hidden_field.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/bound_option_tag.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/bound_password_field.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/bound_radio_button.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/bound_radio_group.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/bound_select.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/bound_text_area.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/bound_text_field.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/button.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/check_box.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/custom_builder.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/delete_button.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/exceptions.rb +0 -25
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/field_set.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/fields_for.rb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/file_field.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/foo.rb +0 -23
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/form.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/form_for.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/hacker.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/hidden_field.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/label.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/numeric_ext.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/option_tag.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/password_field.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/radio_button.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/radio_group.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/relative_date.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/relative_date_span.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/select.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/specs_controller.rb +0 -13
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/submit.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/tag_helper.rb +0 -23
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/text_area.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/text_field.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/helpers/global_helpers.rb +0 -7
- data/spec/rango/helpers/merb-helpers/fixture/app/models/fake_dm_model.rb +0 -27
- data/spec/rango/helpers/merb-helpers/fixture/app/models/first_generic_fake_model.rb +0 -59
- data/spec/rango/helpers/merb-helpers/fixture/app/models/hacker_generic_model.rb +0 -7
- data/spec/rango/helpers/merb-helpers/fixture/app/models/second_generic_fake_model.rb +0 -20
- data/spec/rango/helpers/merb-helpers/fixture/app/models/third_generic_fake_model.rb +0 -5
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_check_box_specs/basic.html.erb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_check_box_specs/basic_unchecked.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_check_box_specs/checked.html.erb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_check_box_specs/errors.html.erb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_check_box_specs/label.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_check_box_specs/on_and_off.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_check_box_specs/raise_value_error.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_file_field_specs/additional_attributes.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_file_field_specs/takes_string.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_file_field_specs/with_label.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_hidden_field_specs/basic.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_hidden_field_specs/errors.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_hidden_field_specs/hidden_error.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_hidden_field_specs/label.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_option_tag_specs/grouped.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_option_tag_specs/nested.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_option_tag_specs/text_and_value.html.erb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_password_field_specs/attributes.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_password_field_specs/basic.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_password_field_specs/label.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_radio_button_specs/basic.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_radio_group_specs/basic.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_radio_group_specs/hashes.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_radio_group_specs/mixed.html.erb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_radio_group_specs/override_id.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_select_specs/basic.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_select_specs/blank.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_select_specs/label.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_select_specs/multiple.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_select_specs/prompt.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_select_specs/with_options.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_select_specs/with_options_with_blank.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_text_area_specs/basic.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_text_area_specs/label.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_text_field_specs/basic.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/button_specs/button_with_label.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/button_specs/button_with_values.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/button_specs/disabled_button.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/check_box_specs/basic.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/check_box_specs/boolean.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/check_box_specs/disabled.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/check_box_specs/label.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/check_box_specs/on_off_is_boolean.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/check_box_specs/raise_unless_both_on_and_off.html.erb +0 -2
- data/spec/rango/helpers/merb-helpers/fixture/app/views/check_box_specs/raises_error_if_not_boolean.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/check_box_specs/raises_error_if_on_off_and_boolean_false.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/check_box_specs/simple.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/check_box_specs/to_string.html.erb +0 -8
- data/spec/rango/helpers/merb-helpers/fixture/app/views/check_box_specs/unchecked.html.erb +0 -2
- data/spec/rango/helpers/merb-helpers/fixture/app/views/custom_builder_specs/everything.html.erb +0 -10
- data/spec/rango/helpers/merb-helpers/fixture/app/views/delete_button_specs/delete_with_explicit_url.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/delete_button_specs/delete_with_extra_params.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/delete_button_specs/delete_with_label.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/delete_button_specs/simple_delete.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/exeptions/client_error.html.erb +0 -37
- data/spec/rango/helpers/merb-helpers/fixture/app/views/exeptions/internal_server_error.html.erb +0 -216
- data/spec/rango/helpers/merb-helpers/fixture/app/views/exeptions/not_acceptable.html.erb +0 -38
- data/spec/rango/helpers/merb-helpers/fixture/app/views/exeptions/not_found.html.erb +0 -40
- data/spec/rango/helpers/merb-helpers/fixture/app/views/fields_for_specs/basic.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/fields_for_specs/midstream.html.erb +0 -7
- data/spec/rango/helpers/merb-helpers/fixture/app/views/fields_for_specs/nil.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/fieldset_specs/legend.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/file_field_specs/disabled.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/file_field_specs/makes_multipart.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/file_field_specs/with_label.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/file_field_specs/with_values.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/foo/bar.html.erb +0 -0
- data/spec/rango/helpers/merb-helpers/fixture/app/views/form_for_specs/basic.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/form_specs/create_a_form.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/form_specs/create_a_multipart_form.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/form_specs/fake_delete_if_set.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/form_specs/fake_put_if_set.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/form_specs/get_if_set.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/form_specs/post_by_default.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/form_specs/resourceful_form.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/hacker/file_field.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/hacker/hidden_field.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/hacker/option_tag.html.erb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/views/hacker/password_field.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/hacker/radio_button.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/hacker/radio_group.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/hacker/text_area.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/hacker/text_field.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/hidden_field_specs/basic.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/hidden_field_specs/disabled.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/hidden_field_specs/label.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/label_specs/basic.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/label_specs/basic_with_attributes.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/label_specs/basic_with_class.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/layout/application.html.erb +0 -11
- data/spec/rango/helpers/merb-helpers/fixture/app/views/numeric_ext_specs/minutes_to_hours.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/numeric_ext_specs/to_concurrency_default.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/numeric_ext_specs/two_digits.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/option_tag_specs/array.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/option_tag_specs/clean.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/option_tag_specs/collection.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/option_tag_specs/multiple_selects.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/option_tag_specs/no_extra_attributes.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/option_tag_specs/optgroups.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/option_tag_specs/selected.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/option_tag_specs/with_blank.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/option_tag_specs/with_prompt.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/password_field_specs/basic.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/password_field_specs/disabled.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/radio_button_specs/basic.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/radio_button_specs/checked.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/radio_button_specs/disabled.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/radio_button_specs/label.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/radio_button_specs/unchecked.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/radio_group_specs/attributes.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/radio_group_specs/basic.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/radio_group_specs/checked.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/radio_group_specs/hash.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/radio_group_specs/specific_attributes.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/relative_date_span_specs/date_span_on_same_day.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/relative_date_span_specs/date_span_on_same_day_on_different_year.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/relative_date_specs/relative_date_with_year.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/relative_date_specs/relative_date_without_year.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/relative_date_specs/relative_today.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/relative_date_specs/relative_tomorrow.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/relative_date_specs/relative_yesterday.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/select_specs/basic.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/select_specs/blank.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/select_specs/multiple.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/select_specs/selected.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/submit_specs/disabled_submit.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/submit_specs/submit_with_label.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/submit_specs/submit_with_values.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/tag_helper/nested_tags.html.erb +0 -5
- data/spec/rango/helpers/merb-helpers/fixture/app/views/tag_helper/tag_with_attributes.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/tag_helper/tag_with_content.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/tag_helper/tag_with_content_in_the_block.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/text_area_specs/basic.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/text_area_specs/disabled.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/text_area_specs/label.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/text_area_specs/nil.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/text_field_specs/basic.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/text_field_specs/class.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/text_field_specs/disabled.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/text_field_specs/label.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/text_field_specs/symbolized_name.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/config/environments/development.rb +0 -8
- data/spec/rango/helpers/merb-helpers/fixture/config/environments/production.rb +0 -7
- data/spec/rango/helpers/merb-helpers/fixture/config/environments/test.rb +0 -8
- data/spec/rango/helpers/merb-helpers/fixture/config/init.rb +0 -48
- data/spec/rango/helpers/merb-helpers/fixture/config/rack.rb +0 -13
- data/spec/rango/helpers/merb-helpers/fixture/config/router.rb +0 -40
- data/spec/rango/helpers/merb-helpers/fixture/public/images/merb.jpg +0 -0
- data/spec/rango/helpers/merb-helpers/fixture/public/merb.fcgi +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/public/stylesheets/master.css +0 -119
- data/spec/rango/helpers/merb-helpers/form/builder_spec.rb +0 -0
- data/spec/rango/helpers/merb-helpers/form/helpers_spec.rb +0 -0
- data/spec/rango/helpers/merb-helpers/form_helpers_spec.rb +0 -0
- data/spec/rango/helpers/merb-helpers/merb_helpers_config_spec.rb +0 -85
- data/spec/rango/helpers/merb-helpers/merb_helpers_date_time_spec.rb +0 -270
- data/spec/rango/helpers/merb-helpers/merb_helpers_form_spec.rb +0 -1372
- data/spec/rango/helpers/merb-helpers/merb_helpers_tag_helper_spec.rb +0 -46
- data/spec/rango/helpers/merb-helpers/merb_helpers_text_spec.rb +0 -71
- data/spec/rango/helpers/merb-helpers/numeric_extlib_spec.rb +0 -138
- data/spec/rango/helpers/merb-helpers/ordinalize_spec.rb +0 -55
- data/spec/rango/helpers/merb-helpers/tag_helpers_spec.rb +0 -0
- data/spec/rango/helpers/merb-helpers/text_helpers_spec.rb +0 -0
- data/spec/rango/helpers/merb-helpers_spec.rb +0 -0
- data/spec/rango/mixins/chainable_spec.rb +0 -0
- data/spec/rango/mixins/hookable_spec.rb +0 -0
- data/spec/rango/mixins/import_spec.rb +0 -0
- data/spec/rango/mixins/mini_spec.rb +0 -0
- data/spec/rango/mixins/strategy_spec.rb +0 -0
- data/spec/rango/rango_spec.rb +0 -0
- data/spec/rango/templates/adapter_spec.rb +0 -0
- data/spec/rango/templates/adapters/erb_spec.rb +0 -0
- data/spec/rango/templates/adapters/erubis_spec.rb +0 -117
- data/spec/rango/templates/adapters/haml_spec.rb +0 -0
- data/spec/rango/templates/adapters/template_helpers.rb +0 -38
@@ -1,453 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
# Form helpers provide a number of methods to simplify the creation of HTML forms.
|
4
|
-
# They can work directly with models (bound) or standalone (unbound).
|
5
|
-
module Rango
|
6
|
-
module Helpers
|
7
|
-
module Form
|
8
|
-
def _singleton_form_context
|
9
|
-
self._default_builder = Rango::Helpers::Form::Builder::ResourcefulFormWithErrors unless self._default_builder
|
10
|
-
@_singleton_form_context ||=
|
11
|
-
self._default_builder.new(nil, nil, self)
|
12
|
-
end
|
13
|
-
|
14
|
-
def form_contexts
|
15
|
-
@_form_contexts ||= []
|
16
|
-
end
|
17
|
-
|
18
|
-
def current_form_context
|
19
|
-
form_contexts.last || _singleton_form_context
|
20
|
-
end
|
21
|
-
|
22
|
-
def _new_form_context(name, builder)
|
23
|
-
if name.is_a?(String) || name.is_a?(Symbol)
|
24
|
-
ivar = instance_variable_get("@#{name}")
|
25
|
-
else
|
26
|
-
ivar, name = name, name.class.to_s.snake_case
|
27
|
-
end
|
28
|
-
builder ||= current_form_context.class if current_form_context
|
29
|
-
(builder || self._default_builder).new(ivar, name, self)
|
30
|
-
end
|
31
|
-
|
32
|
-
def with_form_context(name, builder)
|
33
|
-
form_contexts.push(_new_form_context(name, builder))
|
34
|
-
ret = yield
|
35
|
-
form_contexts.pop
|
36
|
-
ret
|
37
|
-
end
|
38
|
-
|
39
|
-
# Generates a form tag, which accepts a block that is not directly based on resource attributes
|
40
|
-
#
|
41
|
-
# ==== Parameters
|
42
|
-
# attrs<Hash>:: HTML attributes
|
43
|
-
#
|
44
|
-
# ==== Returns
|
45
|
-
# String:: HTML
|
46
|
-
#
|
47
|
-
# ==== Notes
|
48
|
-
# * Block helpers use the <%= =%> syntax
|
49
|
-
# * a multipart enctype is automatically set if the form contains a file upload field
|
50
|
-
#
|
51
|
-
# ==== Example
|
52
|
-
# <%= form :action => url(:controller => "foo", :action => "bar", :id => 1) do %>
|
53
|
-
# <%= text_field :name => "first_name", :label => "First Name" %>
|
54
|
-
# <%= submit "Create" %>
|
55
|
-
# <% end =%>
|
56
|
-
#
|
57
|
-
# Generates the HTML:
|
58
|
-
#
|
59
|
-
# <form action="/foo/bar/1" method="post">
|
60
|
-
# <label for="first_name">First Name</label>
|
61
|
-
# <input type="text" id="first_name" name="first_name" />
|
62
|
-
# <input type="submit" value="Create" />
|
63
|
-
# </form>
|
64
|
-
def form(*args, &block)
|
65
|
-
_singleton_form_context.form(*args, &block)
|
66
|
-
end
|
67
|
-
|
68
|
-
# Generates a resource specific form tag which accepts a block, this also provides automatic resource routing.
|
69
|
-
#
|
70
|
-
# ==== Parameters
|
71
|
-
# name<Symbol>:: Model or Resource
|
72
|
-
# attrs<Hash>:: HTML attributes
|
73
|
-
#
|
74
|
-
# ==== Returns
|
75
|
-
# String:: HTML
|
76
|
-
#
|
77
|
-
# ==== Notes
|
78
|
-
# * Block helpers use the <%= =%> syntax
|
79
|
-
#
|
80
|
-
# ==== Example
|
81
|
-
# <%= form_for @person do %>
|
82
|
-
# <%= text_field :first_name, :label => "First Name" %>
|
83
|
-
# <%= text_field :last_name, :label => "Last Name" %>
|
84
|
-
# <%= submit "Create" %>
|
85
|
-
# <% end =%>
|
86
|
-
#
|
87
|
-
# The HTML generated for this would be:
|
88
|
-
#
|
89
|
-
# <form action="/people" method="post">
|
90
|
-
# <label for="person_first_name">First Name</label>
|
91
|
-
# <input type="text" id="person_first_name" name="person[first_name]" />
|
92
|
-
# <label for="person_last_name">Last Name</label>
|
93
|
-
# <input type="text" id="person_last_name" name="person[last_name]" />
|
94
|
-
# <input type="submit" value="Create" />
|
95
|
-
# </form>
|
96
|
-
def form_for(name, attrs = {}, &block)
|
97
|
-
with_form_context(name, attrs.delete(:builder)) do
|
98
|
-
current_form_context.form(attrs, &block)
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
# Creates a scope around a specific resource object like form_for, but doesnt create the form tags themselves.
|
103
|
-
# This makes fields_for suitable for specifying additional resource objects in the same form.
|
104
|
-
#
|
105
|
-
# ==== Examples
|
106
|
-
# <%= form_for @person do %>
|
107
|
-
# <%= text_field :first_name, :label => "First Name" %>
|
108
|
-
# <%= text_field :last_name, :label => "Last Name" %>
|
109
|
-
# <%= fields_for @permission do %>
|
110
|
-
# <%= check_box :is_admin, :label => "Administrator" %>
|
111
|
-
# <% end =%>
|
112
|
-
# <%= submit "Create" %>
|
113
|
-
# <% end =%>
|
114
|
-
def fields_for(name, attrs = {}, &block)
|
115
|
-
attrs ||= {}
|
116
|
-
with_form_context(name, attrs.delete(:builder)) do
|
117
|
-
capture(&block)
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
# Provides the ability to create quick fieldsets as blocks for your forms.
|
122
|
-
#
|
123
|
-
# ==== Parameters
|
124
|
-
# attrs<Hash>:: HTML attributes and options
|
125
|
-
#
|
126
|
-
# ==== Options
|
127
|
-
# +legend+:: Adds a legend tag within the fieldset
|
128
|
-
#
|
129
|
-
# ==== Returns
|
130
|
-
# String:: HTML
|
131
|
-
#
|
132
|
-
# ==== Notes
|
133
|
-
# Block helpers use the <%= =%> syntax
|
134
|
-
#
|
135
|
-
# ==== Example
|
136
|
-
# <%= fieldset :legend => "Customer Options" do %>
|
137
|
-
# ...your form elements
|
138
|
-
# <% end =%>
|
139
|
-
#
|
140
|
-
# Generates the HTML:
|
141
|
-
#
|
142
|
-
# <fieldset>
|
143
|
-
# <legend>Customer Options</legend>
|
144
|
-
# ...your form elements
|
145
|
-
# </fieldset>
|
146
|
-
def fieldset(attrs = {}, &block)
|
147
|
-
_singleton_form_context.fieldset(attrs, &block)
|
148
|
-
end
|
149
|
-
|
150
|
-
def fieldset_for(name, attrs = {}, &block)
|
151
|
-
with_form_context(name, attrs.delete(:builder)) do
|
152
|
-
current_form_context.fieldset(attrs, &block)
|
153
|
-
end
|
154
|
-
end
|
155
|
-
|
156
|
-
# Provides a generic HTML checkbox input tag.
|
157
|
-
# There are two ways this tag can be generated, based on the
|
158
|
-
# option :boolean. If not set to true, a "magic" input is generated.
|
159
|
-
# Otherwise, an input is created that can be easily used for passing
|
160
|
-
# an array of values to the application.
|
161
|
-
#
|
162
|
-
# ==== Parameters
|
163
|
-
# method<Symbol>:: Resource attribute
|
164
|
-
# attrs<Hash>:: HTML attributes and options
|
165
|
-
#
|
166
|
-
# ==== Returns
|
167
|
-
# String:: HTML
|
168
|
-
#
|
169
|
-
# ==== Example
|
170
|
-
# <%= check_box :name => "is_activated", :value => "1" %>
|
171
|
-
# <%= check_box :name => "choices[]", :boolean => false, :value => "dog" %>
|
172
|
-
# <%= check_box :name => "choices[]", :boolean => false, :value => "cat" %>
|
173
|
-
# <%= check_box :name => "choices[]", :boolean => false, :value => "weasle" %>
|
174
|
-
#
|
175
|
-
# Used with a model:
|
176
|
-
#
|
177
|
-
# <%= check_box :is_activated, :label => "Activated?" %>
|
178
|
-
def check_box; end
|
179
|
-
|
180
|
-
# Provides a HTML file input
|
181
|
-
#
|
182
|
-
# ==== Parameters
|
183
|
-
# name<Symbol>:: Model or Resource
|
184
|
-
# attrs<Hash>:: HTML attributes
|
185
|
-
#
|
186
|
-
# ==== Returns
|
187
|
-
# String:: HTML
|
188
|
-
#
|
189
|
-
# ==== Example
|
190
|
-
# <%= file_field :name => "file", :label => "File" %>
|
191
|
-
#
|
192
|
-
# Used with a model:
|
193
|
-
#
|
194
|
-
# <%= file_field :file, :label => "Choose a file" %>
|
195
|
-
def file_field; end
|
196
|
-
|
197
|
-
# Provides a HTML hidden input field
|
198
|
-
#
|
199
|
-
# ==== Parameters
|
200
|
-
# name<Symbol>:: Model or Resource
|
201
|
-
# attrs<Hash>:: HTML attributes
|
202
|
-
#
|
203
|
-
# ==== Returns
|
204
|
-
# String:: HTML
|
205
|
-
#
|
206
|
-
# ==== Example
|
207
|
-
# <%= hidden_field :name => "secret", :value => "some secret value" %>
|
208
|
-
#
|
209
|
-
# Used with a model:
|
210
|
-
#
|
211
|
-
# <%= hidden_field :identifier %>
|
212
|
-
# # => <input type="hidden" id="person_identifier" name="person[identifier]" value="#{@person.identifier}" />
|
213
|
-
def hidden_field; end
|
214
|
-
|
215
|
-
# Provides a generic HTML label.
|
216
|
-
#
|
217
|
-
# ==== Parameters
|
218
|
-
# attrs<Hash>:: HTML attributes
|
219
|
-
#
|
220
|
-
# ==== Returns
|
221
|
-
# String:: HTML
|
222
|
-
#
|
223
|
-
# ==== Example
|
224
|
-
# <%= label "Full Name", :for => "name" %>
|
225
|
-
# => <label for="name">Full Name</label>
|
226
|
-
def label(*args)
|
227
|
-
current_form_context.label(*args)
|
228
|
-
end
|
229
|
-
|
230
|
-
# Provides a HTML password input.
|
231
|
-
#
|
232
|
-
# ==== Parameters
|
233
|
-
# name<Symbol>:: Model or Resource
|
234
|
-
# attrs<Hash>:: HTML attributes
|
235
|
-
#
|
236
|
-
# ==== Returns
|
237
|
-
# String:: HTML
|
238
|
-
#
|
239
|
-
# ==== Example
|
240
|
-
# <%= password_field :name => :password, :label => "Password" %>
|
241
|
-
# # => <label for="password">Password</label><input type="password" id="password" name="password" />
|
242
|
-
#
|
243
|
-
# Used with a model:
|
244
|
-
#
|
245
|
-
# <%= password_field :password, :label => 'New Password' %>
|
246
|
-
def password_field; end
|
247
|
-
|
248
|
-
# Provides a HTML radio input tag
|
249
|
-
#
|
250
|
-
# ==== Parameters
|
251
|
-
# method<Symbol>:: Resource attribute
|
252
|
-
# attrs<Hash>:: HTML attributes and options
|
253
|
-
#
|
254
|
-
# ==== Returns
|
255
|
-
# String:: HTML
|
256
|
-
#
|
257
|
-
# ==== Example
|
258
|
-
# <%= radio_button :name => "radio_options", :value => "1", :label => "One" %>
|
259
|
-
# <%= radio_button :name => "radio_options", :value => "2", :label => "Two" %>
|
260
|
-
# <%= radio_button :name => "radio_options", :value => "3", :label => "Three", :checked => true %>
|
261
|
-
#
|
262
|
-
# Used with a model:
|
263
|
-
#
|
264
|
-
# <%= form_for @person do %>
|
265
|
-
# <%= radio_button :first_name %>
|
266
|
-
# <% end =%>
|
267
|
-
def radio_button; end
|
268
|
-
|
269
|
-
# Provides a radio group based on a resource attribute.
|
270
|
-
# This is generally used within a resource block such as +form_for+.
|
271
|
-
#
|
272
|
-
# ==== Parameters
|
273
|
-
# method<Symbol>:: Resource attribute
|
274
|
-
# arr<Array>:: Choices
|
275
|
-
#
|
276
|
-
# ==== Returns
|
277
|
-
# String:: HTML
|
278
|
-
#
|
279
|
-
# ==== Examples
|
280
|
-
# <%# the labels are the options %>
|
281
|
-
# <%= radio_group :my_choice, [5,6,7] %>
|
282
|
-
#
|
283
|
-
# <%# custom labels %>
|
284
|
-
# <%= radio_group :my_choice, [{:value => 5, :label => "five"}] %>
|
285
|
-
def radio_group; end
|
286
|
-
|
287
|
-
# Provides a HTML select
|
288
|
-
#
|
289
|
-
# ==== Parameters
|
290
|
-
# method<Symbol>:: Resource attribute
|
291
|
-
# attrs<Hash>:: HTML attributes and options
|
292
|
-
#
|
293
|
-
# ==== Options
|
294
|
-
# +prompt+:: Adds an additional option tag with the provided string with no value.
|
295
|
-
# +selected+:: The value of a selected object, which may be either a string or an array.
|
296
|
-
# +include_blank+:: Adds an additional blank option tag with no value.
|
297
|
-
# +collection+:: The collection for the select options
|
298
|
-
# +text_method+:: Method to determine text of an option (as a symbol). Ex: :text_method => :name will call .name on your record object for what text to display.
|
299
|
-
# +value_method+:: Method to determine value of an option (as a symbol).
|
300
|
-
#
|
301
|
-
# ==== Returns
|
302
|
-
# String:: HTML
|
303
|
-
#
|
304
|
-
# ==== Example
|
305
|
-
# <%= select :name, :collection => %w(one two three) %>
|
306
|
-
def select; end
|
307
|
-
|
308
|
-
# Provides a HTML textarea tag
|
309
|
-
#
|
310
|
-
# ==== Parameters
|
311
|
-
# contents<String>:: Contents of the text area
|
312
|
-
# attrs<Hash>:: HTML attributes
|
313
|
-
#
|
314
|
-
# ==== Returns
|
315
|
-
# String:: HTML
|
316
|
-
#
|
317
|
-
# ==== Example
|
318
|
-
# <%= text_area "my comments", :name => "comments" %>
|
319
|
-
#
|
320
|
-
# Used with a model:
|
321
|
-
#
|
322
|
-
# <%= text_area :comments %>
|
323
|
-
def text_area; end
|
324
|
-
|
325
|
-
# Provides a HTML text input tag
|
326
|
-
#
|
327
|
-
# ==== Parameters
|
328
|
-
# name<Symbol>:: Model or Resource
|
329
|
-
# attrs<Hash>:: HTML attributes
|
330
|
-
#
|
331
|
-
# ==== Returns
|
332
|
-
# String:: HTML
|
333
|
-
#
|
334
|
-
# ==== Example
|
335
|
-
# <%= text_field :name => :fav_color, :label => "Your Favorite Color" %>
|
336
|
-
# # => <label for="fav_color">Your Favorite Color</label><input type="text" id="fav_color" name="fav_color" />
|
337
|
-
#
|
338
|
-
# Used with a model:
|
339
|
-
#
|
340
|
-
# <%= form_for @person do %>
|
341
|
-
# <%= text_field :first_name, :label => "First Name" %>
|
342
|
-
# <% end =%>
|
343
|
-
def text_field; end
|
344
|
-
|
345
|
-
# @todo radio_group helper still needs to be implemented
|
346
|
-
%w(text_field password_field hidden_field file_field
|
347
|
-
text_area select check_box radio_button radio_group).each do |kind|
|
348
|
-
self.class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
349
|
-
def #{kind}(*args)
|
350
|
-
if bound?(*args)
|
351
|
-
current_form_context.bound_#{kind}(*args)
|
352
|
-
else
|
353
|
-
current_form_context.unbound_#{kind}(*args)
|
354
|
-
end
|
355
|
-
end
|
356
|
-
RUBY
|
357
|
-
end
|
358
|
-
|
359
|
-
# Generates a HTML button.
|
360
|
-
#
|
361
|
-
# ==== Parameters
|
362
|
-
# contents<String>:: HTML contained within the button tag
|
363
|
-
# attrs<Hash>:: HTML attributes
|
364
|
-
#
|
365
|
-
# ==== Returns
|
366
|
-
# String:: HTML
|
367
|
-
#
|
368
|
-
# ==== Notes
|
369
|
-
# * Buttons do not always work as planned in IE
|
370
|
-
# http://www.peterbe.com/plog/button-tag-in-IE
|
371
|
-
# * Not all mobile browsers support buttons
|
372
|
-
# http://nickcowie.com/2007/time-to-stop-using-the-button-element/
|
373
|
-
#
|
374
|
-
# ==== Example
|
375
|
-
# <%= button "Initiate Launch Sequence" %>
|
376
|
-
def button(contents, attrs = {})
|
377
|
-
current_form_context.button(contents, attrs)
|
378
|
-
end
|
379
|
-
|
380
|
-
# Generates a HTML delete button.
|
381
|
-
#
|
382
|
-
# If an object is passed as first parameter, Rango will try to use the resource url for the object
|
383
|
-
# If the object doesn't have a resource view, pass a url
|
384
|
-
#
|
385
|
-
# ==== Parameters
|
386
|
-
# object_or_url<Object> or <String>:: Object to delete or URL to send the request to
|
387
|
-
# contents<String>:: HTML contained within the button tag
|
388
|
-
# attrs<Hash>:: HTML attributes
|
389
|
-
#
|
390
|
-
# ==== Returns
|
391
|
-
# String:: HTML
|
392
|
-
#
|
393
|
-
# ==== Example
|
394
|
-
# <%= delete_button @article, "Delete article now", :class => 'delete-btn' %>
|
395
|
-
# <%= delete_button url(:article, @article)%>
|
396
|
-
#
|
397
|
-
def delete_button(object_or_url, contents="Delete", attrs = {})
|
398
|
-
url = object_or_url.is_a?(String) ? object_or_url : resource(object_or_url)
|
399
|
-
button_text = (contents || 'Delete')
|
400
|
-
tag :form, :class => 'delete-btn', :action => url, :method => :post do
|
401
|
-
tag(:input, :type => :hidden, :name => "_method", :value => "DELETE") <<
|
402
|
-
tag(:input, attrs.merge(:value => button_text, :type => :submit))
|
403
|
-
end
|
404
|
-
end
|
405
|
-
|
406
|
-
# Generates a HTML submit button.
|
407
|
-
#
|
408
|
-
# ==== Parameters
|
409
|
-
# value<String>:: Sets the value="" attribute
|
410
|
-
# attrs<Hash>:: HTML attributes
|
411
|
-
#
|
412
|
-
# ==== Returns
|
413
|
-
# String:: HTML
|
414
|
-
#
|
415
|
-
# ==== Example
|
416
|
-
# <%= submit "Process" %>
|
417
|
-
def submit(contents, attrs = {})
|
418
|
-
current_form_context.submit(contents, attrs)
|
419
|
-
end
|
420
|
-
|
421
|
-
# Provides a HTML formatted display of resource errors in an unordered list with a h2 form submission error
|
422
|
-
#
|
423
|
-
# ==== Parameters
|
424
|
-
# obj<Object>:: Model or Resource
|
425
|
-
# error_class<String>:: CSS class to use for error container
|
426
|
-
# build_li<String>:: Custom li tag to wrap each error in
|
427
|
-
# header<String>:: Custom header text for the error container
|
428
|
-
# before<Boolean>:: Display the errors before or inside of the form
|
429
|
-
#
|
430
|
-
# ==== Returns
|
431
|
-
# String:: HTML
|
432
|
-
#
|
433
|
-
# ==== Examples
|
434
|
-
# <%= error_messages_for @person %>
|
435
|
-
# <%= error_messages_for @person {|errors| "You can has probs nao: #{errors.size} of em!"}
|
436
|
-
# <%= error_messages_for @person, lambda{|error| "<li class='aieeee'>#{error.join(' ')}"} %>
|
437
|
-
# <%= error_messages_for @person, nil, 'bad_mojo' %>
|
438
|
-
def error_messages_for(obj = nil, opts = {})
|
439
|
-
current_form_context.error_messages_for(obj, opts[:error_class] || "error",
|
440
|
-
opts[:build_li] || "<li>%s</li>",
|
441
|
-
opts[:header] || "<h2>Form submission failed because of %s problem%s</h2>",
|
442
|
-
opts.key?(:before) ? opts[:before] : true)
|
443
|
-
end
|
444
|
-
alias error_messages error_messages_for
|
445
|
-
|
446
|
-
private
|
447
|
-
|
448
|
-
def bound?(*args)
|
449
|
-
args.first.is_a?(Symbol)
|
450
|
-
end
|
451
|
-
end
|
452
|
-
end
|
453
|
-
end
|