fortitude 0.0.4-java
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.
- checksums.yaml +7 -0
- data/.gitignore +20 -0
- data/.rspec-local +4 -0
- data/.travis.yml +50 -0
- data/CHANGES.md +62 -0
- data/CONTRIBUTORS.md +6 -0
- data/Gemfile +5 -0
- data/LICENSE.txt +22 -0
- data/README-erector.md +246 -0
- data/README.md +15 -0
- data/Rakefile +67 -0
- data/ext/FortitudeJrubyNativeExtService.java +11 -0
- data/ext/com/fortituderuby/ext/fortitude/FortitudeNativeLibrary.java +223 -0
- data/ext/fortitude_native_ext/extconf.rb +4 -0
- data/ext/fortitude_native_ext/fortitude_native_ext.c +333 -0
- data/fortitude.gemspec +42 -0
- data/lib/fortitude.rb +7 -0
- data/lib/fortitude/doctypes.rb +48 -0
- data/lib/fortitude/doctypes/base.rb +42 -0
- data/lib/fortitude/doctypes/html4.rb +21 -0
- data/lib/fortitude/doctypes/html4_frameset.rb +20 -0
- data/lib/fortitude/doctypes/html4_strict.rb +18 -0
- data/lib/fortitude/doctypes/html4_tags_frameset.rb +53 -0
- data/lib/fortitude/doctypes/html4_tags_strict.rb +274 -0
- data/lib/fortitude/doctypes/html4_tags_transitional.rb +115 -0
- data/lib/fortitude/doctypes/html4_transitional.rb +19 -0
- data/lib/fortitude/doctypes/html5.rb +373 -0
- data/lib/fortitude/doctypes/unknown_doctype.rb +20 -0
- data/lib/fortitude/doctypes/xhtml10.rb +20 -0
- data/lib/fortitude/doctypes/xhtml10_frameset.rb +18 -0
- data/lib/fortitude/doctypes/xhtml10_strict.rb +18 -0
- data/lib/fortitude/doctypes/xhtml10_transitional.rb +18 -0
- data/lib/fortitude/doctypes/xhtml11.rb +30 -0
- data/lib/fortitude/errors.rb +153 -0
- data/lib/fortitude/extensions/fortitude_ruby_ext.rb +76 -0
- data/lib/fortitude/extensions/native_extensions.rb +33 -0
- data/lib/fortitude/method_templates/assign_locals_from_template.rb.smpl +22 -0
- data/lib/fortitude/method_templates/need_assignment_template.rb.smpl +16 -0
- data/lib/fortitude/method_templates/need_method_template.rb.smpl +4 -0
- data/lib/fortitude/method_templates/simple_template.rb +50 -0
- data/lib/fortitude/method_templates/tag_method_template.rb.smpl +68 -0
- data/lib/fortitude/method_templates/text_method_template.rb.smpl +17 -0
- data/lib/fortitude/rails.rb +26 -0
- data/lib/fortitude/rails/helpers.rb +153 -0
- data/lib/fortitude/rails/railtie.rb +256 -0
- data/lib/fortitude/rails/renderer.rb +43 -0
- data/lib/fortitude/rails/template_handler.rb +23 -0
- data/lib/fortitude/rails/widget_methods.rb +13 -0
- data/lib/fortitude/rails/yielded_object_outputter.rb +31 -0
- data/lib/fortitude/rendering_context.rb +205 -0
- data/lib/fortitude/support/assigns_proxy.rb +77 -0
- data/lib/fortitude/support/class_inheritable_attributes.rb +98 -0
- data/lib/fortitude/support/instance_variable_set.rb +76 -0
- data/lib/fortitude/support/staticized_method.rb +87 -0
- data/lib/fortitude/tags/partial_tag_placeholder.rb +19 -0
- data/lib/fortitude/tags/tag.rb +189 -0
- data/lib/fortitude/tags/tag_return_value.rb +13 -0
- data/lib/fortitude/tags/tag_store.rb +53 -0
- data/lib/fortitude/tags/tag_support.rb +51 -0
- data/lib/fortitude/tags/tags_module.rb +16 -0
- data/lib/fortitude/tilt.rb +17 -0
- data/lib/fortitude/tilt/fortitude_template.rb +169 -0
- data/lib/fortitude/version.rb +3 -0
- data/lib/fortitude/widget.rb +54 -0
- data/lib/fortitude/widget/around_content.rb +53 -0
- data/lib/fortitude/widget/capturing.rb +37 -0
- data/lib/fortitude/widget/content.rb +61 -0
- data/lib/fortitude/widget/doctypes.rb +53 -0
- data/lib/fortitude/widget/helpers.rb +62 -0
- data/lib/fortitude/widget/integration.rb +76 -0
- data/lib/fortitude/widget/localization.rb +63 -0
- data/lib/fortitude/widget/modules_and_subclasses.rb +58 -0
- data/lib/fortitude/widget/needs.rb +164 -0
- data/lib/fortitude/widget/non_rails_widget_methods.rb +13 -0
- data/lib/fortitude/widget/rendering.rb +98 -0
- data/lib/fortitude/widget/start_and_end_comments.rb +69 -0
- data/lib/fortitude/widget/staticization.rb +50 -0
- data/lib/fortitude/widget/tag_like_methods.rb +102 -0
- data/lib/fortitude/widget/tags.rb +55 -0
- data/lib/fortitude/widget/temporary_overrides.rb +28 -0
- data/lib/fortitude/widget/widget_class_inheritable_attributes.rb +35 -0
- data/lib/fortitude/widgets.rb +12 -0
- data/lib/fortitude/widgets/html4_frameset.rb +9 -0
- data/lib/fortitude/widgets/html4_strict.rb +9 -0
- data/lib/fortitude/widgets/html4_transitional.rb +9 -0
- data/lib/fortitude/widgets/html5.rb +9 -0
- data/lib/fortitude/widgets/xhtml10_frameset.rb +9 -0
- data/lib/fortitude/widgets/xhtml10_strict.rb +9 -0
- data/lib/fortitude/widgets/xhtml10_transitional.rb +9 -0
- data/lib/fortitude/widgets/xhtml11.rb +9 -0
- data/lib/fortitude_jruby_native_ext.jar +0 -0
- data/spec/helpers/global_helper.rb +8 -0
- data/spec/helpers/rails_helpers.rb +85 -0
- data/spec/helpers/rails_server.rb +386 -0
- data/spec/helpers/system_helpers.rb +117 -0
- data/spec/rails/basic_rails_system_spec.rb +7 -0
- data/spec/rails/capture_system_spec.rb +75 -0
- data/spec/rails/class_loading_system_spec.rb +63 -0
- data/spec/rails/complex_helpers_system_spec.rb +33 -0
- data/spec/rails/data_passing_system_spec.rb +96 -0
- data/spec/rails/default_layout_system_spec.rb +15 -0
- data/spec/rails/development_mode_system_spec.rb +67 -0
- data/spec/rails/erb_integration_system_spec.rb +23 -0
- data/spec/rails/helpers_include_all_off_system_spec.rb +7 -0
- data/spec/rails/helpers_system_spec.rb +79 -0
- data/spec/rails/helpers_unrefined_system_spec.rb +7 -0
- data/spec/rails/layouts_system_spec.rb +60 -0
- data/spec/rails/localization_system_spec.rb +38 -0
- data/spec/rails/production_mode_system_spec.rb +13 -0
- data/spec/rails/rendering_context_system_spec.rb +64 -0
- data/spec/rails/rendering_system_spec.rb +158 -0
- data/spec/rails/rules_system_spec.rb +23 -0
- data/spec/rails/static_method_system_spec.rb +12 -0
- data/spec/rails/templates/base/app/controllers/application_controller.rb +15 -0
- data/spec/rails/templates/base/app/controllers/working_controller.rb +5 -0
- data/spec/rails/templates/base/app/views/layouts/application.html.erb +11 -0
- data/spec/rails/templates/base/config/routes.rb +4 -0
- data/spec/rails/templates/base/config/secrets.yml +22 -0
- data/spec/rails/templates/basic_rails_system_spec/app/controllers/basic_rails_system_spec_controller.rb +8 -0
- data/spec/rails/templates/basic_rails_system_spec/app/views/basic_rails_system_spec/trivial_widget.rb +5 -0
- data/spec/rails/templates/capture_system_spec/app/controllers/capture_system_spec_controller.rb +37 -0
- data/spec/rails/templates/capture_system_spec/app/views/capture_system_spec/_some_erb_partial.html.erb +1 -0
- data/spec/rails/templates/capture_system_spec/app/views/capture_system_spec/another_widget.rb +7 -0
- data/spec/rails/templates/capture_system_spec/app/views/capture_system_spec/capture_erb_from_widget.rb +11 -0
- data/spec/rails/templates/capture_system_spec/app/views/capture_system_spec/capture_widget_from_erb.html.erb +9 -0
- data/spec/rails/templates/capture_system_spec/app/views/capture_system_spec/capture_widget_from_widget.rb +17 -0
- data/spec/rails/templates/capture_system_spec/app/views/capture_system_spec/some_widget.rb +5 -0
- data/spec/rails/templates/capture_system_spec/app/views/capture_system_spec/widget_content_for.rb +19 -0
- data/spec/rails/templates/capture_system_spec/app/views/capture_system_spec/widget_layout_needing_content_yield_with_erb.html.erb +13 -0
- data/spec/rails/templates/capture_system_spec/app/views/capture_system_spec/widget_provide.rb +13 -0
- data/spec/rails/templates/capture_system_spec/app/views/layouts/erb_layout_needing_content.html.erb +15 -0
- data/spec/rails/templates/capture_system_spec/app/views/layouts/widget_layout_needing_content_content_for.rb +23 -0
- data/spec/rails/templates/capture_system_spec/app/views/layouts/widget_layout_needing_content_yield.rb +23 -0
- data/spec/rails/templates/class_loading_system_spec/app/controllers/class_loading_system_spec_controller.rb +74 -0
- data/spec/rails/templates/class_loading_system_spec/app/models/views/app_models_helper.rb +5 -0
- data/spec/rails/templates/class_loading_system_spec/app/models/views/models_widget.rb +5 -0
- data/spec/rails/templates/class_loading_system_spec/app/views/autoload_namespace/autoload_widget.rb +11 -0
- data/spec/rails/templates/class_loading_system_spec/app/views/class_loading_system_spec/_loaded_underscore_widget.rb +11 -0
- data/spec/rails/templates/class_loading_system_spec/app/views/class_loading_system_spec/_underscore_view.rb +5 -0
- data/spec/rails/templates/class_loading_system_spec/app/views/class_loading_system_spec/_underscore_widget.rb +11 -0
- data/spec/rails/templates/class_loading_system_spec/app/views/class_loading_system_spec/app_models.rb +6 -0
- data/spec/rails/templates/class_loading_system_spec/app/views/class_loading_system_spec/autoload_one_widget_from_another.rb +7 -0
- data/spec/rails/templates/class_loading_system_spec/app/views/class_loading_system_spec/class_should_not_load.rb +9 -0
- data/spec/rails/templates/class_loading_system_spec/app/views/class_loading_system_spec/lib_views.rb +8 -0
- data/spec/rails/templates/class_loading_system_spec/app/views/class_loading_system_spec/use_lib_widget_from_view_widget.rb +9 -0
- data/spec/rails/templates/class_loading_system_spec/app/views/class_loading_system_spec/use_models_widget_from_view_widget.rb +7 -0
- data/spec/rails/templates/class_loading_system_spec/app/views/some_namespace/some_other_namespace/.git_keep +0 -0
- data/spec/rails/templates/class_loading_system_spec/app/views/sub_widget.rb +5 -0
- data/spec/rails/templates/class_loading_system_spec/lib/arbitrary_name/some_widget.rb +7 -0
- data/spec/rails/templates/class_loading_system_spec/lib/views/class_loading_system_spec/lib_views_helper.rb +5 -0
- data/spec/rails/templates/class_loading_system_spec/lib/views/class_loading_system_spec/widget_defined_outside_app_views.rb +5 -0
- data/spec/rails/templates/class_loading_system_spec/lib/views/lib_widget.rb +5 -0
- data/spec/rails/templates/complex_helpers_system_spec/app/controllers/complex_helpers_system_spec_controller.rb +14 -0
- data/spec/rails/templates/complex_helpers_system_spec/app/views/complex_helpers_system_spec/cache_test.rb +12 -0
- data/spec/rails/templates/complex_helpers_system_spec/app/views/complex_helpers_system_spec/fields_for_test.rb +14 -0
- data/spec/rails/templates/complex_helpers_system_spec/app/views/complex_helpers_system_spec/form_for_test.rb +14 -0
- data/spec/rails/templates/complex_helpers_system_spec/config/environments/development.rb +31 -0
- data/spec/rails/templates/data_passing_system_spec/app/controllers/data_passing_system_spec_controller.rb +101 -0
- data/spec/rails/templates/data_passing_system_spec/app/views/data_passing_system_spec/_erb_to_parallel_widget_handoff_erb.html.erb +3 -0
- data/spec/rails/templates/data_passing_system_spec/app/views/data_passing_system_spec/_implicit_erb_to_widget_handoff_erb.html.erb +3 -0
- data/spec/rails/templates/data_passing_system_spec/app/views/data_passing_system_spec/_implicit_variable_write_erb.html.erb +1 -0
- data/spec/rails/templates/data_passing_system_spec/app/views/data_passing_system_spec/_widget_to_parallel_erb_handoff_erb.html.erb +1 -0
- data/spec/rails/templates/data_passing_system_spec/app/views/data_passing_system_spec/erb_copied_variables.html.erb +1 -0
- data/spec/rails/templates/data_passing_system_spec/app/views/data_passing_system_spec/erb_to_parallel_widget_handoff.html.erb +2 -0
- data/spec/rails/templates/data_passing_system_spec/app/views/data_passing_system_spec/erb_to_parallel_widget_handoff_widget.rb +5 -0
- data/spec/rails/templates/data_passing_system_spec/app/views/data_passing_system_spec/explicit_controller_variable_read.rb +6 -0
- data/spec/rails/templates/data_passing_system_spec/app/views/data_passing_system_spec/extra_variables.rb +23 -0
- data/spec/rails/templates/data_passing_system_spec/app/views/data_passing_system_spec/extra_variables_requested.rb +24 -0
- data/spec/rails/templates/data_passing_system_spec/app/views/data_passing_system_spec/implicit_erb_to_widget_handoff.html.erb +2 -0
- data/spec/rails/templates/data_passing_system_spec/app/views/data_passing_system_spec/implicit_erb_to_widget_handoff_widget.rb +7 -0
- data/spec/rails/templates/data_passing_system_spec/app/views/data_passing_system_spec/implicit_shared_variable_access.rb +5 -0
- data/spec/rails/templates/data_passing_system_spec/app/views/data_passing_system_spec/implicit_shared_variable_access_inheritance.rb +6 -0
- data/spec/rails/templates/data_passing_system_spec/app/views/data_passing_system_spec/implicit_shared_variable_access_inheritance_child_one.rb +7 -0
- data/spec/rails/templates/data_passing_system_spec/app/views/data_passing_system_spec/implicit_shared_variable_access_inheritance_child_two.rb +5 -0
- data/spec/rails/templates/data_passing_system_spec/app/views/data_passing_system_spec/implicit_shared_variable_access_inheritance_parent.rb +3 -0
- data/spec/rails/templates/data_passing_system_spec/app/views/data_passing_system_spec/implicit_shared_variable_access_inner.rb +8 -0
- data/spec/rails/templates/data_passing_system_spec/app/views/data_passing_system_spec/implicit_variable_read.rb +5 -0
- data/spec/rails/templates/data_passing_system_spec/app/views/data_passing_system_spec/implicit_variable_read_inner.rb +7 -0
- data/spec/rails/templates/data_passing_system_spec/app/views/data_passing_system_spec/implicit_variable_write.html.erb +2 -0
- data/spec/rails/templates/data_passing_system_spec/app/views/data_passing_system_spec/implicit_variable_write_widget.rb +7 -0
- data/spec/rails/templates/data_passing_system_spec/app/views/data_passing_system_spec/parent_to_child_passing.rb +7 -0
- data/spec/rails/templates/data_passing_system_spec/app/views/data_passing_system_spec/parent_to_child_passing_child.rb +7 -0
- data/spec/rails/templates/data_passing_system_spec/app/views/data_passing_system_spec/parent_to_child_passing_partial.rb +7 -0
- data/spec/rails/templates/data_passing_system_spec/app/views/data_passing_system_spec/parent_to_child_passing_partial_child.rb +7 -0
- data/spec/rails/templates/data_passing_system_spec/app/views/data_passing_system_spec/passing_data_widget.rb +8 -0
- data/spec/rails/templates/data_passing_system_spec/app/views/data_passing_system_spec/passing_locals_and_controller_variables_widget.rb +9 -0
- data/spec/rails/templates/data_passing_system_spec/app/views/data_passing_system_spec/passing_locals_widget.rb +8 -0
- data/spec/rails/templates/data_passing_system_spec/app/views/data_passing_system_spec/variables_to_layout.rb +7 -0
- data/spec/rails/templates/data_passing_system_spec/app/views/data_passing_system_spec/widget_copied_variables.rb +9 -0
- data/spec/rails/templates/data_passing_system_spec/app/views/data_passing_system_spec/widget_to_parallel_erb_handoff.html.erb +2 -0
- data/spec/rails/templates/data_passing_system_spec/app/views/data_passing_system_spec/widget_to_parallel_erb_handoff_widget.rb +5 -0
- data/spec/rails/templates/data_passing_system_spec/app/views/layouts/data_layout.rb +14 -0
- data/spec/rails/templates/default_layout_system_spec/app/controllers/default_layout_system_spec_controller.rb +9 -0
- data/spec/rails/templates/default_layout_system_spec/app/views/default_layout_system_spec/erb_with_widget_default_layout.html.erb +1 -0
- data/spec/rails/templates/default_layout_system_spec/app/views/default_layout_system_spec/widget_with_widget_default_layout.rb +5 -0
- data/spec/rails/templates/default_layout_system_spec/app/views/layouts/application.rb +12 -0
- data/spec/rails/templates/development_mode_system_spec/app/controllers/development_mode_system_spec_controller.rb +9 -0
- data/spec/rails/templates/development_mode_system_spec/app/views/development_mode_system_spec/reload_widget.rb +7 -0
- data/spec/rails/templates/development_mode_system_spec/app/views/development_mode_system_spec/sample_output.rb +9 -0
- data/spec/rails/templates/erb_integration_system_spec/app/controllers/erb_integration_system_spec_controller.rb +10 -0
- data/spec/rails/templates/erb_integration_system_spec/app/views/erb_integration_system_spec/_erb_partial_from_widget_partial.html.erb +1 -0
- data/spec/rails/templates/erb_integration_system_spec/app/views/erb_integration_system_spec/_fortitude_partial_with_underscore_partial.rb +5 -0
- data/spec/rails/templates/erb_integration_system_spec/app/views/erb_integration_system_spec/_prefers_erb_partial_partial.html.erb +1 -0
- data/spec/rails/templates/erb_integration_system_spec/app/views/erb_integration_system_spec/erb_partial_from_widget.rb +7 -0
- data/spec/rails/templates/erb_integration_system_spec/app/views/erb_integration_system_spec/erb_to_widget_with_render_partial.html.erb +3 -0
- data/spec/rails/templates/erb_integration_system_spec/app/views/erb_integration_system_spec/erb_to_widget_with_render_partial_widget.rb +5 -0
- data/spec/rails/templates/erb_integration_system_spec/app/views/erb_integration_system_spec/fortitude_partial_with_underscore.html.erb +3 -0
- data/spec/rails/templates/erb_integration_system_spec/app/views/erb_integration_system_spec/prefers_erb_partial.html.erb +3 -0
- data/spec/rails/templates/erb_integration_system_spec/app/views/erb_integration_system_spec/prefers_erb_partial_partial.rb +5 -0
- data/spec/rails/templates/helpers_include_all_off_system_spec/app/controllers/helpers_include_all_off_system_spec_controller.rb +13 -0
- data/spec/rails/templates/helpers_include_all_off_system_spec/app/helpers/application_helper.rb +5 -0
- data/spec/rails/templates/helpers_include_all_off_system_spec/app/helpers/some_helper.rb +5 -0
- data/spec/rails/templates/helpers_include_all_off_system_spec/app/views/helpers_include_all_off_system_spec/include_all_off.rb +23 -0
- data/spec/rails/templates/helpers_include_all_off_system_spec/config/application.rb +28 -0
- data/spec/rails/templates/helpers_system_spec/app/controllers/helpers_system_spec_controller.rb +86 -0
- data/spec/rails/templates/helpers_system_spec/app/helpers/some_helper.rb +21 -0
- data/spec/rails/templates/helpers_system_spec/app/views/helpers_system_spec/automatic_helpers_disabled.rb +37 -0
- data/spec/rails/templates/helpers_system_spec/app/views/helpers_system_spec/automatic_helpers_inheritance.rb +6 -0
- data/spec/rails/templates/helpers_system_spec/app/views/helpers_system_spec/automatic_helpers_inheritance_child_one.rb +34 -0
- data/spec/rails/templates/helpers_system_spec/app/views/helpers_system_spec/automatic_helpers_inheritance_child_two.rb +36 -0
- data/spec/rails/templates/helpers_system_spec/app/views/helpers_system_spec/automatic_helpers_inheritance_parent.rb +4 -0
- data/spec/rails/templates/helpers_system_spec/app/views/helpers_system_spec/basic_helpers.rb +13 -0
- data/spec/rails/templates/helpers_system_spec/app/views/helpers_system_spec/block_helpers.rb +7 -0
- data/spec/rails/templates/helpers_system_spec/app/views/helpers_system_spec/built_in_outputting_helpers.rb +13 -0
- data/spec/rails/templates/helpers_system_spec/app/views/helpers_system_spec/built_in_outputting_to_returning.rb +8 -0
- data/spec/rails/templates/helpers_system_spec/app/views/helpers_system_spec/built_in_returning_to_outputting.rb +10 -0
- data/spec/rails/templates/helpers_system_spec/app/views/helpers_system_spec/controller_helper_method.rb +5 -0
- data/spec/rails/templates/helpers_system_spec/app/views/helpers_system_spec/controller_helper_module.rb +5 -0
- data/spec/rails/templates/helpers_system_spec/app/views/helpers_system_spec/custom_helper_outputs.rb +6 -0
- data/spec/rails/templates/helpers_system_spec/app/views/helpers_system_spec/custom_helpers_basic.rb +5 -0
- data/spec/rails/templates/helpers_system_spec/app/views/helpers_system_spec/custom_helpers_with_a_block.rb +6 -0
- data/spec/rails/templates/helpers_system_spec/app/views/helpers_system_spec/custom_outputting_to_returning.rb +7 -0
- data/spec/rails/templates/helpers_system_spec/app/views/helpers_system_spec/custom_returning_to_outputting.rb +10 -0
- data/spec/rails/templates/helpers_system_spec/app/views/helpers_system_spec/helper_settings_inheritance.rb +10 -0
- data/spec/rails/templates/helpers_system_spec/app/views/helpers_system_spec/helper_settings_inheritance_parent.rb +4 -0
- data/spec/rails/templates/helpers_system_spec/app/views/helpers_system_spec/helpers_that_output_when_refined.rb +9 -0
- data/spec/rails/templates/helpers_system_spec/app/views/helpers_system_spec/private_helper_erb.html.erb +1 -0
- data/spec/rails/templates/helpers_system_spec/app/views/helpers_system_spec/private_helper_fortitude.rb +5 -0
- data/spec/rails/templates/helpers_system_spec/lib/some_stuff.rb +5 -0
- data/spec/rails/templates/helpers_unrefined_system_spec/app/controllers/helpers_unrefined_system_spec_controller.rb +7 -0
- data/spec/rails/templates/helpers_unrefined_system_spec/app/views/helpers_unrefined_system_spec/helpers_that_output_when_refined.rb +9 -0
- data/spec/rails/templates/helpers_unrefined_system_spec/config/environments/production.rb +31 -0
- data/spec/rails/templates/layouts_system_spec/app/controllers/layouts_system_spec_controller.rb +31 -0
- data/spec/rails/templates/layouts_system_spec/app/views/layouts/alternate.html.erb +11 -0
- data/spec/rails/templates/layouts_system_spec/app/views/layouts/application.html.erb +26 -0
- data/spec/rails/templates/layouts_system_spec/app/views/layouts/explicit_yield.rb +12 -0
- data/spec/rails/templates/layouts_system_spec/app/views/layouts/widget_layout.rb +22 -0
- data/spec/rails/templates/layouts_system_spec/app/views/layouts_system_spec/erb_inside_widget_layout.html.erb +8 -0
- data/spec/rails/templates/layouts_system_spec/app/views/layouts_system_spec/the_render_widget.rb +5 -0
- data/spec/rails/templates/layouts_system_spec/app/views/layouts_system_spec/widget_inside_erb_layout.rb +8 -0
- data/spec/rails/templates/layouts_system_spec/app/views/layouts_system_spec/widget_inside_widget_layout.rb +8 -0
- data/spec/rails/templates/layouts_system_spec/app/views/layouts_system_spec/yield_from_widget_explicitly.rb +5 -0
- data/spec/rails/templates/localization_system_spec/app/controllers/localization_system_spec_controller.rb +31 -0
- data/spec/rails/templates/localization_system_spec/app/views/localization_system_spec/content_method.rb +13 -0
- data/spec/rails/templates/localization_system_spec/app/views/localization_system_spec/dot_notation.rb +5 -0
- data/spec/rails/templates/localization_system_spec/app/views/localization_system_spec/explicit_html.rb +13 -0
- data/spec/rails/templates/localization_system_spec/app/views/localization_system_spec/i18n_t.rb +5 -0
- data/spec/rails/templates/localization_system_spec/app/views/localization_system_spec/native_support.rb +7 -0
- data/spec/rails/templates/localization_system_spec/app/views/localization_system_spec/readjust_base.rb +7 -0
- data/spec/rails/templates/localization_system_spec/app/views/localization_system_spec/t.rb +5 -0
- data/spec/rails/templates/localization_system_spec/config/locales/en.yml +21 -0
- data/spec/rails/templates/localization_system_spec/config/locales/fr.yml +14 -0
- data/spec/rails/templates/localization_system_spec/config/locales/pt.yml +2 -0
- data/spec/rails/templates/production_mode_system_spec/app/controllers/production_mode_system_spec_controller.rb +5 -0
- data/spec/rails/templates/production_mode_system_spec/app/views/production_mode_system_spec/sample_output.rb +9 -0
- data/spec/rails/templates/rendering_context_system_spec/app/controllers/rendering_context_system_spec_controller.rb +72 -0
- data/spec/rails/templates/rendering_context_system_spec/app/views/rendering_context_system_spec/_start_end_widget_through_partials_partial.html.erb +1 -0
- data/spec/rails/templates/rendering_context_system_spec/app/views/rendering_context_system_spec/_uses_direct_context_for_all_widgets_partial.html.erb +1 -0
- data/spec/rails/templates/rendering_context_system_spec/app/views/rendering_context_system_spec/_uses_specified_context_through_nesting_partial.html.erb +2 -0
- data/spec/rails/templates/rendering_context_system_spec/app/views/rendering_context_system_spec/render_widget.rb +5 -0
- data/spec/rails/templates/rendering_context_system_spec/app/views/rendering_context_system_spec/start_end_widget_basic.rb +12 -0
- data/spec/rails/templates/rendering_context_system_spec/app/views/rendering_context_system_spec/start_end_widget_basic_inner.rb +7 -0
- data/spec/rails/templates/rendering_context_system_spec/app/views/rendering_context_system_spec/start_end_widget_through_partials.rb +16 -0
- data/spec/rails/templates/rendering_context_system_spec/app/views/rendering_context_system_spec/start_end_widget_through_partials_partial_widget.rb +7 -0
- data/spec/rails/templates/rendering_context_system_spec/app/views/rendering_context_system_spec/uses_direct_context_for_all_widgets.rb +7 -0
- data/spec/rails/templates/rendering_context_system_spec/app/views/rendering_context_system_spec/uses_direct_context_for_all_widgets_widget.rb +5 -0
- data/spec/rails/templates/rendering_context_system_spec/app/views/rendering_context_system_spec/uses_direct_context_in_view.rb +5 -0
- data/spec/rails/templates/rendering_context_system_spec/app/views/rendering_context_system_spec/uses_specified_context_in_partials.html.erb +3 -0
- data/spec/rails/templates/rendering_context_system_spec/app/views/rendering_context_system_spec/uses_specified_context_in_partials_partial.rb +5 -0
- data/spec/rails/templates/rendering_context_system_spec/app/views/rendering_context_system_spec/uses_specified_context_in_view.rb +5 -0
- data/spec/rails/templates/rendering_context_system_spec/app/views/rendering_context_system_spec/uses_specified_context_through_nesting.rb +6 -0
- data/spec/rails/templates/rendering_context_system_spec/app/views/rendering_context_system_spec/uses_specified_context_through_nesting_inner_partial.rb +5 -0
- data/spec/rails/templates/rendering_context_system_spec/lib/simple_rc.rb +17 -0
- data/spec/rails/templates/rendering_system_spec/app/controllers/rendering_system_spec_controller.rb +111 -0
- data/spec/rails/templates/rendering_system_spec/app/views/layouts/application.html.erb +19 -0
- data/spec/rails/templates/rendering_system_spec/app/views/rendering_system_spec/_layout_for_partial.html.erb +3 -0
- data/spec/rails/templates/rendering_system_spec/app/views/rendering_system_spec/_the_partial.html.erb +1 -0
- data/spec/rails/templates/rendering_system_spec/app/views/rendering_system_spec/partial_with_layout.rb +5 -0
- data/spec/rails/templates/rendering_system_spec/app/views/rendering_system_spec/render_collection.html.erb +3 -0
- data/spec/rails/templates/rendering_system_spec/app/views/rendering_system_spec/render_collection_as.html.erb +3 -0
- data/spec/rails/templates/rendering_system_spec/app/views/rendering_system_spec/render_file_from_widget.rb +7 -0
- data/spec/rails/templates/rendering_system_spec/app/views/rendering_system_spec/render_html_safe_strings.rb +16 -0
- data/spec/rails/templates/rendering_system_spec/app/views/rendering_system_spec/render_inline_from_widget.rb +11 -0
- data/spec/rails/templates/rendering_system_spec/app/views/rendering_system_spec/render_object.html.erb +3 -0
- data/spec/rails/templates/rendering_system_spec/app/views/rendering_system_spec/render_partial_from_widget.rb +7 -0
- data/spec/rails/templates/rendering_system_spec/app/views/rendering_system_spec/render_partial_with_layout.html.erb +3 -0
- data/spec/rails/templates/rendering_system_spec/app/views/rendering_system_spec/render_partial_with_widget_layout.html.erb +3 -0
- data/spec/rails/templates/rendering_system_spec/app/views/rendering_system_spec/render_template_from_widget.rb +7 -0
- data/spec/rails/templates/rendering_system_spec/app/views/rendering_system_spec/render_text_from_widget.rb +7 -0
- data/spec/rails/templates/rendering_system_spec/app/views/rendering_system_spec/stream_widget.rb +13 -0
- data/spec/rails/templates/rendering_system_spec/app/views/rendering_system_spec/trivial_widget.rb +5 -0
- data/spec/rails/templates/rendering_system_spec/app/views/rendering_system_spec/widget_layout_for_partial.rb +7 -0
- data/spec/rails/templates/rendering_system_spec/app/views/rendering_system_spec/widget_with_name.rb +7 -0
- data/spec/rails/templates/rendering_system_spec/app/views/rendering_system_spec/word.rb +7 -0
- data/spec/rails/templates/rendering_system_spec/app/views/widget_to_render.rb +7 -0
- data/spec/rails/templates/rules_system_spec/app/controllers/rules_system_spec_controller.rb +22 -0
- data/spec/rails/templates/rules_system_spec/app/views/layouts/fortitude_layout_with_p.rb +19 -0
- data/spec/rails/templates/rules_system_spec/app/views/rules_system_spec/_intervening_partial_erb_partial.html.erb +1 -0
- data/spec/rails/templates/rules_system_spec/app/views/rules_system_spec/intervening_partial.rb +9 -0
- data/spec/rails/templates/rules_system_spec/app/views/rules_system_spec/intervening_partial_fortitude_partial.rb +9 -0
- data/spec/rails/templates/rules_system_spec/app/views/rules_system_spec/invalid_start_tag_in_partial.html.erb +3 -0
- data/spec/rails/templates/rules_system_spec/app/views/rules_system_spec/invalid_start_tag_in_partial_partial.rb +9 -0
- data/spec/rails/templates/rules_system_spec/app/views/rules_system_spec/invalid_start_tag_in_view.rb +9 -0
- data/spec/rails/templates/rules_system_spec/app/views/rules_system_spec/invalidly_nested_tag.rb +11 -0
- data/spec/rails/templates/rules_system_spec/app/views/rules_system_spec/invalidly_nested_tag_in_partial.html.erb +3 -0
- data/spec/rails/templates/rules_system_spec/app/views/rules_system_spec/invalidly_nested_tag_in_partial_partial.rb +11 -0
- data/spec/rails/templates/static_method_system_spec/app/controllers/static_method_system_spec_controller.rb +15 -0
- data/spec/rails/templates/static_method_system_spec/app/helpers/some_helper.rb +10 -0
- data/spec/rails/templates/static_method_system_spec/app/views/static_method_system_spec/allows_helper_access.rb +8 -0
- data/spec/rails/templates/static_method_system_spec/app/views/static_method_system_spec/localization.rb +7 -0
- data/spec/rails/templates/static_method_system_spec/config/locales/en.yml +4 -0
- data/spec/rails/templates/static_method_system_spec/config/locales/fr.yml +4 -0
- data/spec/system/around_content_system_spec.rb +399 -0
- data/spec/system/assigns_system_spec.rb +316 -0
- data/spec/system/attribute_rules_system_spec.rb +227 -0
- data/spec/system/basic_system_spec.rb +9 -0
- data/spec/system/content_inheritance_system_spec.rb +13 -0
- data/spec/system/convenience_methods_system_spec.rb +30 -0
- data/spec/system/doctypes_system_spec.rb +228 -0
- data/spec/system/erector_compatibility_system_spec.rb +84 -0
- data/spec/system/escaping_system_spec.rb +43 -0
- data/spec/system/formatting_system_spec.rb +63 -0
- data/spec/system/helpers_system_spec.rb +235 -0
- data/spec/system/id_uniqueness_system_spec.rb +205 -0
- data/spec/system/inline_system_spec.rb +58 -0
- data/spec/system/localization_system_spec.rb +94 -0
- data/spec/system/method_precedence_system_spec.rb +48 -0
- data/spec/system/needs_system_spec.rb +381 -0
- data/spec/system/other_outputters_system_spec.rb +117 -0
- data/spec/system/rails_not_available_spec.rb +11 -0
- data/spec/system/rebuild_notifications_system_spec.rb +208 -0
- data/spec/system/rendering_context_system_spec.rb +83 -0
- data/spec/system/setting_inheritance_system_spec.rb +585 -0
- data/spec/system/shared_variable_system_spec.rb +120 -0
- data/spec/system/start_end_comments_system_spec.rb +363 -0
- data/spec/system/static_method_system_spec.rb +348 -0
- data/spec/system/tag_rendering_system_spec.rb +260 -0
- data/spec/system/tag_return_value_system_spec.rb +41 -0
- data/spec/system/tag_rules_system_spec.rb +196 -0
- data/spec/system/tag_updating_system_spec.rb +171 -0
- data/spec/system/tilt_system_spec.rb +382 -0
- data/spec/system/unparsed_data_system_spec.rb +16 -0
- data/spec/system/void_tags_system_spec.rb +90 -0
- data/spec/system/widget_return_values_system_spec.rb +107 -0
- metadata +759 -0
@@ -0,0 +1,68 @@
|
|
1
|
+
def #{method_name}(content_or_attributes = nil, attributes = nil)
|
2
|
+
o = @_fortitude_output_buffer_holder.output_buffer
|
3
|
+
rc = @_fortitude_rendering_context # :if needs_element_rules || needs_formatting
|
4
|
+
|
5
|
+
this_tag = #{tag_object_const} # :if needs_element_rules || needs_attribute_rules || needs_id_uniqueness
|
6
|
+
rc.record_tag(self, this_tag) do # :if needs_element_rules
|
7
|
+
format_output = rc.format_output? # :if needs_formatting
|
8
|
+
if format_output # :if needs_formatting
|
9
|
+
rc.needs_newline! # :if needs_formatting && newline_before
|
10
|
+
rc.about_to_output_non_whitespace! # :if needs_formatting
|
11
|
+
end # :if needs_formatting
|
12
|
+
|
13
|
+
if (! content_or_attributes)
|
14
|
+
if block_given?
|
15
|
+
_fortitude_raise_no_content_allowed_error(#{tag_object_const}) # :if ! content_allowed
|
16
|
+
o.#{concat_method}(#{open_const})
|
17
|
+
#{yield_call}
|
18
|
+
o.#{concat_method}(#{close_const})
|
19
|
+
else
|
20
|
+
o.#{concat_method}(#{alone_const})
|
21
|
+
end
|
22
|
+
elsif content_or_attributes.kind_of?(Hash)
|
23
|
+
this_tag.validate_attributes(self, content_or_attributes) # :if needs_attribute_rules
|
24
|
+
this_tag.validate_id_uniqueness(self, content_or_attributes) # :if needs_id_uniqueness
|
25
|
+
o.#{concat_method}(#{partial_open_const})
|
26
|
+
content_or_attributes.fortitude_append_as_attributes(o, nil)
|
27
|
+
|
28
|
+
if block_given?
|
29
|
+
_fortitude_raise_no_content_allowed_error(#{tag_object_const}) # :if ! content_allowed
|
30
|
+
o.#{concat_method}(#{partial_open_end_const})
|
31
|
+
#{yield_call}
|
32
|
+
o.#{concat_method}(#{close_const})
|
33
|
+
else
|
34
|
+
o.#{concat_method}(#{partial_open_alone_end_const})
|
35
|
+
end
|
36
|
+
elsif (! attributes)
|
37
|
+
_fortitude_raise_no_content_allowed_error(#{tag_object_const}) # :if ! content_allowed
|
38
|
+
o.#{concat_method}(#{open_const})
|
39
|
+
rc.record_tag(self, FORTITUDE_TEXT_PSEUDOTAG) { } unless content_or_attributes.instance_variable_get("@html_safe") # :if needs_element_rules
|
40
|
+
content_or_attributes.to_s.fortitude_append_escaped_string(o) # :if escape_direct_content
|
41
|
+
o.#{concat_method}(content_or_attributes.to_s) # :if ! escape_direct_content
|
42
|
+
if block_given?
|
43
|
+
_fortitude_raise_no_content_allowed_error(#{tag_object_const}) # :if ! content_allowed
|
44
|
+
#{yield_call}
|
45
|
+
end
|
46
|
+
o.#{concat_method}(#{close_const})
|
47
|
+
else
|
48
|
+
_fortitude_raise_no_content_allowed_error(#{tag_object_const}) # :if ! content_allowed
|
49
|
+
this_tag.validate_attributes(self, attributes) # :if needs_attribute_rules
|
50
|
+
this_tag.validate_id_uniqueness(self, attributes) # :if needs_id_uniqueness
|
51
|
+
o.#{concat_method}(#{partial_open_const})
|
52
|
+
attributes.fortitude_append_as_attributes(o, nil)
|
53
|
+
o.#{concat_method}(#{partial_open_end_const})
|
54
|
+
|
55
|
+
rc.record_tag(self, FORTITUDE_TEXT_PSEUDOTAG) { } unless content_or_attributes.instance_variable_get("@html_safe") # :if needs_element_rules
|
56
|
+
content_or_attributes.to_s.fortitude_append_escaped_string(o) # :if escape_direct_content
|
57
|
+
o.#{concat_method}(content_or_attributes.to_s) # :if ! escape_direct_content
|
58
|
+
if block_given?
|
59
|
+
_fortitude_raise_no_content_allowed_error(#{tag_object_const}) # :if ! content_allowed
|
60
|
+
#{yield_call}
|
61
|
+
end
|
62
|
+
o.#{concat_method}(#{close_const})
|
63
|
+
end
|
64
|
+
rc.needs_newline! if format_output # :if needs_formatting && newline_before
|
65
|
+
end # :if needs_element_rules
|
66
|
+
|
67
|
+
FORTITUDE_NO_RETURN_VALUE_FROM_TAGS
|
68
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
def tag_text(s)
|
2
|
+
@_fortitude_rendering_context.about_to_output_non_whitespace! # :if format_output
|
3
|
+
|
4
|
+
unless s.instance_variable_get("@html_safe") # :if needs_element_rules
|
5
|
+
@_fortitude_rendering_context.record_tag(self, FORTITUDE_TEXT_PSEUDOTAG) { } # :if needs_element_rules
|
6
|
+
end # :if needs_element_rules
|
7
|
+
|
8
|
+
s.to_s.fortitude_append_escaped_string(@_fortitude_output_buffer_holder.output_buffer)
|
9
|
+
end
|
10
|
+
|
11
|
+
def tag_rawtext(s)
|
12
|
+
@_fortitude_rendering_context.about_to_output_non_whitespace! # :if format_output
|
13
|
+
@_fortitude_output_buffer_holder.output_buffer.original_concat(s)
|
14
|
+
end
|
15
|
+
|
16
|
+
alias_method :text, :tag_text
|
17
|
+
alias_method :rawtext, :tag_rawtext
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# See if we can load Rails -- but don't fail if we can't; we'll just use this to decide whether we should
|
2
|
+
# load the Railtie or not.
|
3
|
+
begin
|
4
|
+
gem 'rails'
|
5
|
+
rescue Gem::LoadError => le
|
6
|
+
# ok
|
7
|
+
end
|
8
|
+
|
9
|
+
begin
|
10
|
+
require 'rails'
|
11
|
+
rescue LoadError => le
|
12
|
+
# ok
|
13
|
+
end
|
14
|
+
|
15
|
+
if defined?(::Rails)
|
16
|
+
require 'action_view'
|
17
|
+
|
18
|
+
require 'fortitude/rails/widget_methods'
|
19
|
+
require 'fortitude/rails/renderer'
|
20
|
+
require 'fortitude/rails/template_handler'
|
21
|
+
require 'fortitude/rails/railtie'
|
22
|
+
else
|
23
|
+
::String.class_eval do
|
24
|
+
alias_method :original_concat, :concat
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,153 @@
|
|
1
|
+
module Fortitude
|
2
|
+
module Rails
|
3
|
+
module Helpers
|
4
|
+
class << self
|
5
|
+
def helper(name, options = { })
|
6
|
+
@helpers ||= { }
|
7
|
+
@helpers[name] = options
|
8
|
+
end
|
9
|
+
|
10
|
+
def helper_options(name)
|
11
|
+
@helpers[name.to_s.strip.downcase.to_sym]
|
12
|
+
end
|
13
|
+
|
14
|
+
def apply_refined_helpers_to!(o)
|
15
|
+
@helpers.each do |name, options|
|
16
|
+
o.helper(name, options)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# tags/
|
22
|
+
# active_model_helper
|
23
|
+
# asset_tag_helper
|
24
|
+
helper :javascript_include_tag, :transform => :output_return_value
|
25
|
+
helper :stylesheet_link_tag, :transform => :output_return_value
|
26
|
+
helper :auto_discovery_link_tag, :transform => :output_return_value
|
27
|
+
helper :favicon_link_tag, :transform => :output_return_value
|
28
|
+
helper :image_tag, :transform => :output_return_value
|
29
|
+
helper :video_tag, :transform => :output_return_value
|
30
|
+
helper :audio_tag, :transform => :output_return_value
|
31
|
+
|
32
|
+
# asset_url_helper
|
33
|
+
# atom_feed_helper
|
34
|
+
# cache_helper
|
35
|
+
# capture_helper
|
36
|
+
# controller_helper
|
37
|
+
# csrf_helper
|
38
|
+
helper :csrf_meta_tags, :transform => :output_return_value
|
39
|
+
helper :csrf_meta_tag, :transform => :output_return_value
|
40
|
+
|
41
|
+
# date_helper
|
42
|
+
helper :date_select, :transform => :output_return_value
|
43
|
+
helper :time_select, :transform => :output_return_value
|
44
|
+
helper :datetime_select, :transform => :output_return_value
|
45
|
+
helper :select_datetime, :transform => :output_return_value
|
46
|
+
helper :select_date, :transform => :output_return_value
|
47
|
+
helper :select_time, :transform => :output_return_value
|
48
|
+
helper :select_second, :transform => :output_return_value
|
49
|
+
helper :select_minute, :transform => :output_return_value
|
50
|
+
helper :select_hour, :transform => :output_return_value
|
51
|
+
helper :select_day, :transform => :output_return_value
|
52
|
+
helper :select_month, :transform => :output_return_value
|
53
|
+
helper :select_year, :transform => :output_return_value
|
54
|
+
helper :time_tag, :transform => :output_return_value
|
55
|
+
|
56
|
+
# debug_helper
|
57
|
+
helper :debug, :transform => :output_return_value
|
58
|
+
|
59
|
+
# form_helper
|
60
|
+
FORM_FOR_YIELDED_METHODS_TO_OUTPUT =
|
61
|
+
# Directly from form_helper
|
62
|
+
%w{check_box color_field date_field datetime_field datetime_local_field} +
|
63
|
+
%w{email_field file_field hidden_field label month_field number_field password_field phone_field} +
|
64
|
+
%w{radio_button range_field search_field telephone_field text_area text_field time_field url_field} +
|
65
|
+
%w{week_field} +
|
66
|
+
|
67
|
+
# From form_options_helper
|
68
|
+
%w{select collection_select grouped_collection_select time_zone_select options_for_select} +
|
69
|
+
%w{options_from_collection_for_select option_groups_from_collection_for_select grouped_options_for_select} +
|
70
|
+
%w{time_zone_options_for_select collection_radio_buttons collection_check_boxes}
|
71
|
+
|
72
|
+
helper :form_for, :transform => :output_return_value, :output_yielded_methods => FORM_FOR_YIELDED_METHODS_TO_OUTPUT
|
73
|
+
helper :fields_for, :transform => :output_return_value, :output_yielded_methods => FORM_FOR_YIELDED_METHODS_TO_OUTPUT
|
74
|
+
|
75
|
+
# form_options_helper
|
76
|
+
# helper :select, :transform => :output_return_value # conflicts with HTML <select> tag
|
77
|
+
helper :collection_select, :transform => :output_return_value
|
78
|
+
helper :grouped_collection_select, :transform => :output_return_value
|
79
|
+
helper :time_zone_select, :transform => :output_return_value
|
80
|
+
helper :options_for_select, :transform => :output_return_value
|
81
|
+
helper :options_from_collection_for_select, :transform => :output_return_value
|
82
|
+
helper :option_groups_from_collection_for_select, :transform => :output_return_value
|
83
|
+
helper :grouped_options_for_select, :transform => :output_return_value
|
84
|
+
helper :time_zone_options_for_select, :transform => :output_return_value
|
85
|
+
helper :collection_radio_buttons, :transform => :output_return_value
|
86
|
+
helper :collection_check_boxes, :transform => :output_return_value
|
87
|
+
|
88
|
+
# form_tag_helper
|
89
|
+
helper :form_tag, :transform => :output_return_value
|
90
|
+
helper :select_tag, :transform => :output_return_value
|
91
|
+
helper :text_field_tag, :transform => :output_return_value
|
92
|
+
helper :label_tag, :transform => :output_return_value
|
93
|
+
helper :hidden_field_tag, :transform => :output_return_value
|
94
|
+
helper :file_field_tag, :transform => :output_return_value
|
95
|
+
helper :password_field_tag, :transform => :output_return_value
|
96
|
+
helper :text_area_tag, :transform => :output_return_value
|
97
|
+
helper :check_box_tag, :transform => :output_return_value
|
98
|
+
helper :radio_button_tag, :transform => :output_return_value
|
99
|
+
helper :submit_tag, :transform => :output_return_value
|
100
|
+
helper :button_tag, :transform => :output_return_value
|
101
|
+
helper :image_submit_tag, :transform => :output_return_value
|
102
|
+
helper :field_set_tag, :transform => :output_return_value
|
103
|
+
helper :color_field_tag, :transform => :output_return_value
|
104
|
+
helper :search_field_tag, :transform => :output_return_value
|
105
|
+
helper :telephone_field_tag, :transform => :output_return_value
|
106
|
+
helper :phone_field_tag, :transform => :output_return_value
|
107
|
+
helper :date_field_tag, :transform => :output_return_value
|
108
|
+
helper :time_field_tag, :transform => :output_return_value
|
109
|
+
helper :datetime_field_tag, :transform => :output_return_value
|
110
|
+
helper :datetime_local_field_tag, :transform => :output_return_value
|
111
|
+
helper :month_field_tag, :transform => :output_return_value
|
112
|
+
helper :week_field_tag, :transform => :output_return_value
|
113
|
+
helper :url_field_tag, :transform => :output_return_value
|
114
|
+
helper :email_field_tag, :transform => :output_return_value
|
115
|
+
helper :number_field_tag, :transform => :output_return_value
|
116
|
+
helper :range_field_tag, :transform => :output_return_value
|
117
|
+
helper :utf8_enforcer_tag, :transform => :output_return_value
|
118
|
+
|
119
|
+
# javascript_helper
|
120
|
+
helper :javascript_tag, :transform => :output_return_value
|
121
|
+
helper :javascript_cdata_section, :transform => :output_return_value
|
122
|
+
helper :button_to_function, :transform => :output_return_value
|
123
|
+
helper :link_to_function, :transform => :output_return_value
|
124
|
+
|
125
|
+
# number_helper
|
126
|
+
# output_safety_helper
|
127
|
+
# record_tag_helper
|
128
|
+
helper :div_for, :transform => :output_return_value
|
129
|
+
helper :content_tag_for, :transform => :output_return_value
|
130
|
+
|
131
|
+
# rendering_helper
|
132
|
+
# #render is special-cased; Widget implements it directly
|
133
|
+
|
134
|
+
# sanitize_helper
|
135
|
+
# tag_helper
|
136
|
+
# #tag conflicts with Widget's #tag method, and probably isn't something you want anyway
|
137
|
+
helper :content_tag, :transform => :output_return_value
|
138
|
+
helper :cdata_section, :transform => :output_return_value
|
139
|
+
|
140
|
+
# text_helper
|
141
|
+
# translation_helper
|
142
|
+
# url_helper
|
143
|
+
helper :link_to, :transform => :output_return_value
|
144
|
+
helper :button_to, :transform => :output_return_value
|
145
|
+
helper :link_to_unless_current, :transform => :output_return_value
|
146
|
+
helper :link_to_unless, :transform => :output_return_value
|
147
|
+
helper :link_to_if, :transform => :output_return_value
|
148
|
+
helper :mail_to, :transform => :output_return_value
|
149
|
+
|
150
|
+
helper :capture
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
@@ -0,0 +1,256 @@
|
|
1
|
+
require 'fortitude/rendering_context'
|
2
|
+
|
3
|
+
if defined?(ActiveSupport)
|
4
|
+
ActiveSupport.on_load(:before_initialize) do
|
5
|
+
ActiveSupport.on_load(:action_view) do
|
6
|
+
require "fortitude/rails/template_handler"
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
module Fortitude
|
12
|
+
class << self
|
13
|
+
def refine_rails_helpers(on_or_off = :not_specified)
|
14
|
+
@refine_rails_helpers = !! on_or_off unless on_or_off == :not_specified
|
15
|
+
!! @refine_rails_helpers
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
refine_rails_helpers true
|
20
|
+
end
|
21
|
+
|
22
|
+
module Fortitude
|
23
|
+
module Rails
|
24
|
+
class Railtie < ::Rails::Railtie
|
25
|
+
config.after_initialize do
|
26
|
+
if Fortitude.refine_rails_helpers
|
27
|
+
require 'fortitude/rails/helpers'
|
28
|
+
Fortitude::Rails::Helpers.apply_refined_helpers_to!(Fortitude::Widget)
|
29
|
+
end
|
30
|
+
|
31
|
+
if ::Rails.env.development?
|
32
|
+
::Fortitude::Widget.class_eval do
|
33
|
+
format_output true
|
34
|
+
start_and_end_comments true
|
35
|
+
debug true
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
initializer :fortitude, :before => :set_autoload_paths do |app|
|
41
|
+
# All of this code is involved in setting up autoload_paths to work with Fortitude.
|
42
|
+
# Why so hard?
|
43
|
+
#
|
44
|
+
# We're trying to do something that ActiveSupport::Dependencies -- which is what Rails uses for
|
45
|
+
# class autoloading -- doesn't really support. We want app/views to be on the autoload path,
|
46
|
+
# because there are now Ruby classes living there. (It usually isn't just because all that's there
|
47
|
+
# are template source files, not actual Ruby code.) That isn't an issue, though -- adding it
|
48
|
+
# is trivial (just do
|
49
|
+
# <tt>ActiveSupport::Dependencies.autoload_paths << File.join(Rails.root, 'app/views')</tt>).
|
50
|
+
#
|
51
|
+
# The real issue is that we want the class <tt>app/views/foo/bar.rb</tt> to define a class called
|
52
|
+
# <tt>Views::Foo::Bar</tt>, not just plain <tt>Foo::Bar</tt>. This is what's different from what
|
53
|
+
# ActiveSupport::Dependencies normally supports; it expects the filesystem path underneath the
|
54
|
+
# root to be exactly identical to the fully-qualified class name.
|
55
|
+
#
|
56
|
+
# Why are we doing this crazy thing? Because we want you to be able to have a view called
|
57
|
+
# <tt>app/views/user/password.rb</tt>, and _not_ have that conflict with a module you just happen to define
|
58
|
+
# elsewhere called <tt>User::Password</tt>. If we don't prefix view classes with anything at all, then the
|
59
|
+
# potential for conflicts is enormous.
|
60
|
+
#
|
61
|
+
# As such, we have this code. We'll walk through it step-by-step; note that at the end we *do*
|
62
|
+
# add app/views/ to the autoload path, so all this code is doing is just dealing with the fact that
|
63
|
+
# the fully-qualified classname (<tt>Views::Foo::Bar</tt>) has one extra component on the front of it
|
64
|
+
# (<tt>Views::</tt>) when compared to the subpath (<tt>foo/bar.rb</tt>) underneath what's on the autoload
|
65
|
+
# path (<tt>app/views</tt>).
|
66
|
+
|
67
|
+
# Go compute our views root.
|
68
|
+
views_root = File.expand_path(File.join(::Rails.root, 'app', 'views'))
|
69
|
+
|
70
|
+
# Now, do all this work inside ::ActiveSupport::Dependencies...
|
71
|
+
::ActiveSupport::Dependencies.module_eval do
|
72
|
+
@@_fortitude_views_root = views_root
|
73
|
+
|
74
|
+
# This is the method that gets called to auto-generate namespacing empty
|
75
|
+
# modules (_e.g._, the toplevel <tt>Views::</tt> module) for directories
|
76
|
+
# under an autoload path.
|
77
|
+
#
|
78
|
+
# The original method says:
|
79
|
+
#
|
80
|
+
# "Does the provided path_suffix correspond to an autoloadable module?
|
81
|
+
# Instead of returning a boolean, the autoload base for this module is
|
82
|
+
# returned."
|
83
|
+
#
|
84
|
+
# So, we just need to strip off the leading +views/+ from the +path_suffix+,
|
85
|
+
# and see if that maps to a directory underneath <tt>app/views/</tt>; if so,
|
86
|
+
# we'll return the path to <tt>.../app/views/</tt>. Otherwise, we just
|
87
|
+
# delegate back to the superclass method.
|
88
|
+
def autoloadable_module_with_fortitude?(path_suffix)
|
89
|
+
if path_suffix =~ %r{^views(/.*)?$}i
|
90
|
+
# If we got here, then we were passed a subpath of views/....
|
91
|
+
subpath = $1
|
92
|
+
|
93
|
+
if subpath.blank? || File.directory?(File.join(@@_fortitude_views_root, subpath))
|
94
|
+
return @@_fortitude_views_root
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
with_fortitude_views_removed_from_autoload_path do
|
99
|
+
autoloadable_module_without_fortitude?(path_suffix)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
alias_method_chain :autoloadable_module?, :fortitude
|
104
|
+
|
105
|
+
# When we delegate back to original methods, we want them to act as if
|
106
|
+
# <tt>app/views/</tt> is _not_ on the autoload path. In order to be thread-safe
|
107
|
+
# about that, we couple this method with our override of the writer side of the
|
108
|
+
# <tt>mattr_accessor :autoload_paths</tt>, which simply prefers the thread-local
|
109
|
+
# that we set to the actual underlying variable.
|
110
|
+
def with_fortitude_views_removed_from_autoload_path
|
111
|
+
begin
|
112
|
+
Thread.current[:_fortitude_autoload_paths_override] = autoload_paths - [ @@_fortitude_views_root ]
|
113
|
+
yield
|
114
|
+
ensure
|
115
|
+
Thread.current[:_fortitude_autoload_paths_override] = nil
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
# The use of 'class_eval' here may seem funny, and I think it is, but, without it,
|
120
|
+
# the +@@autoload_paths+ gets interpreted as a class variable for this *Railtie*,
|
121
|
+
# rather than for ::ActiveSupport::Dependencies. (Why is that? Got me...)
|
122
|
+
class_eval <<-EOS
|
123
|
+
def self.autoload_paths
|
124
|
+
Thread.current[:_fortitude_autoload_paths_override] || @@autoload_paths
|
125
|
+
end
|
126
|
+
EOS
|
127
|
+
|
128
|
+
# The original method says:
|
129
|
+
#
|
130
|
+
# "Search for a file in autoload_paths matching the provided suffix."
|
131
|
+
#
|
132
|
+
# So, we just look to see if the given +path_suffix+ is specifying something like
|
133
|
+
# <tt>views/foo/bar</tt>; if so, we glue it together properly, removing the initial
|
134
|
+
# <tt>views/</tt> first. (Otherwise, the mechanism would expect
|
135
|
+
# <tt>Views::Foo::Bar</tt> to show up in <tt>app/views/views/foo/bar</tt> (yes, a double
|
136
|
+
# +views+), since <tt>app/views</tt> is on the autoload path.)
|
137
|
+
def search_for_file_with_fortitude(path_suffix)
|
138
|
+
# This just makes sure our path always ends in exactly one ".rb", whether it started
|
139
|
+
# with one or not.
|
140
|
+
new_path_suffix = path_suffix.sub(/(\.rb)?$/, ".rb")
|
141
|
+
|
142
|
+
if new_path_suffix =~ %r{^views(/.*)$}i
|
143
|
+
path = File.join(@@_fortitude_views_root, $1)
|
144
|
+
return path if File.file?(path)
|
145
|
+
end
|
146
|
+
|
147
|
+
# Make sure that we remove the views autoload path before letting the rest of
|
148
|
+
# the dependency mechanism go searching for files, or else <tt>app/views/foo/bar.rb</tt>
|
149
|
+
# *will* be found when looking for just <tt>::Foo::Bar</tt>.
|
150
|
+
with_fortitude_views_removed_from_autoload_path { search_for_file_without_fortitude(path_suffix) }
|
151
|
+
end
|
152
|
+
|
153
|
+
alias_method_chain :search_for_file, :fortitude
|
154
|
+
end
|
155
|
+
|
156
|
+
# And, finally, this is where we add our root to the set of autoload paths.
|
157
|
+
::ActiveSupport::Dependencies.autoload_paths << views_root
|
158
|
+
|
159
|
+
# This is our support for partials. Fortitude doesn't really have a distinction between
|
160
|
+
# partials and "full" templates -- everything is just a widget, which is much more elegant --
|
161
|
+
# but we still want you to be able to render a widget <tt>Views::Foo::Bar</tt> by saying
|
162
|
+
# <tt>render :partial => 'foo/bar'</tt> (from ERb, although you can do it from Fortitude if
|
163
|
+
# you want for some reason, too).
|
164
|
+
#
|
165
|
+
# Normally, ActionView only looks for partials in files starting with an underscore. We
|
166
|
+
# do want to allow this, too (in the above case, if you define the widget in the file
|
167
|
+
# <tt>app/views/foo/_bar.rb</tt>, it will still work fine); however, we also want to allow
|
168
|
+
# you to define it in a file that does _not_ start with an underscore ('cause these are
|
169
|
+
# Ruby classes, and that's just plain weird).
|
170
|
+
#
|
171
|
+
# So, we patch #find_templates: if it's looking for a partial, doesn't find one, and is
|
172
|
+
# searching Fortitude templates (the +.rb+ handler), then we try again, turning off the
|
173
|
+
# +partial+ flag, and return that instead.
|
174
|
+
::ActionView::PathResolver.class_eval do
|
175
|
+
def find_templates_with_fortitude(name, prefix, partial, details)
|
176
|
+
templates = find_templates_without_fortitude(name, prefix, partial, details)
|
177
|
+
if partial && templates.empty? && details[:handlers] && details[:handlers].include?(:rb)
|
178
|
+
templates = find_templates_without_fortitude(name, prefix, false, details.merge(:handlers => [ :rb ]))
|
179
|
+
end
|
180
|
+
templates
|
181
|
+
end
|
182
|
+
|
183
|
+
alias_method_chain :find_templates, :fortitude
|
184
|
+
end
|
185
|
+
|
186
|
+
require "fortitude/rails/template_handler"
|
187
|
+
|
188
|
+
# This is our support for render :widget. Although, originally, it looked like creating a new subclass
|
189
|
+
# of ActionView::Template was going to be the correct thing to do here, it turns out it isn't: the entire
|
190
|
+
# template system is predicated around the idea that you have a template, which is compiled to output
|
191
|
+
# Ruby source code, and then that gets evaluated to actually generate output.
|
192
|
+
#
|
193
|
+
# Because <tt>render :widget => ...</tt> takes an already-instantiated widget as input, this simply isn't
|
194
|
+
# possible: you can't reverse-engineer an arbitrary Ruby object into source code, and, without source code,
|
195
|
+
# the whole templating paradigm doesn't make sense.
|
196
|
+
#
|
197
|
+
# So, instead, we simply transform <tt>render :widget => ...</tt> into a <tt>render :text => ...</tt> of the
|
198
|
+
# widget's output, and let Rails take it away from there.
|
199
|
+
::ActionController::Base.class_eval do
|
200
|
+
def fortitude_rendering_context(options)
|
201
|
+
@_fortitude_rendering_context ||= create_fortitude_rendering_context(options)
|
202
|
+
end
|
203
|
+
|
204
|
+
def create_fortitude_rendering_context(options)
|
205
|
+
::Fortitude::RenderingContext.new(options)
|
206
|
+
end
|
207
|
+
|
208
|
+
def render_with_fortitude(*args, &block)
|
209
|
+
if (options = args[0]).kind_of?(Hash)
|
210
|
+
if (widget = options[:widget])
|
211
|
+
rendering_context = fortitude_rendering_context(:delegate_object => self)
|
212
|
+
widget.render_to(rendering_context)
|
213
|
+
|
214
|
+
options = options.dup
|
215
|
+
options[:text] = rendering_context.output_buffer_holder.output_buffer.html_safe
|
216
|
+
options[:layout] = true unless options.has_key?(:layout)
|
217
|
+
|
218
|
+
new_args = [ options ] + args[1..-1]
|
219
|
+
return render_without_fortitude(*new_args, &block)
|
220
|
+
elsif (widget_block = options[:inline]) && (options[:type] == :fortitude)
|
221
|
+
options.delete(:inline)
|
222
|
+
|
223
|
+
rendering_context = fortitude_rendering_context(:delegate_object => self)
|
224
|
+
widget_class = Class.new(Fortitude::Widgets::Html5)
|
225
|
+
widget_class.use_instance_variables_for_assigns(true)
|
226
|
+
widget_class.extra_assigns(:use)
|
227
|
+
widget_class.send(:define_method, :content, &widget_block)
|
228
|
+
|
229
|
+
assigns = { }
|
230
|
+
instance_variables.each do |ivar_name|
|
231
|
+
value = instance_variable_get(ivar_name)
|
232
|
+
assigns[$1.to_sym] = value if ivar_name =~ /^@(.*)$/
|
233
|
+
end
|
234
|
+
assigns = assigns.merge(options[:locals] || { })
|
235
|
+
|
236
|
+
widget = widget_class.new(assigns)
|
237
|
+
widget.render_to(rendering_context)
|
238
|
+
|
239
|
+
options = options.dup
|
240
|
+
options[:text] = rendering_context.output_buffer_holder.output_buffer.html_safe
|
241
|
+
options[:layout] = true unless options.has_key?(:layout)
|
242
|
+
|
243
|
+
new_args = [ options ] + args[1..-1]
|
244
|
+
return render_without_fortitude(*new_args, &block)
|
245
|
+
end
|
246
|
+
end
|
247
|
+
|
248
|
+
return render_without_fortitude(*args, &block)
|
249
|
+
end
|
250
|
+
|
251
|
+
alias_method_chain :render, :fortitude
|
252
|
+
end
|
253
|
+
end
|
254
|
+
end
|
255
|
+
end
|
256
|
+
end
|