middleman-core 3.0.0.alpha.7
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.
- data/Rakefile +5 -0
- data/bin/middleman +52 -0
- data/features/3rd_party_cli.feature +5 -0
- data/features/asset_host.feature +7 -0
- data/features/auto_layout.feature +36 -0
- data/features/automatic_image_sizes.feature +16 -0
- data/features/builder.feature +50 -0
- data/features/chained_templates.feature +19 -0
- data/features/clean_build.feature +31 -0
- data/features/cli.feature +120 -0
- data/features/content_for.feature +6 -0
- data/features/current_page_request_path_backwards.feature +6 -0
- data/features/custom_layout_engines.feature +8 -0
- data/features/custom_layouts.feature +44 -0
- data/features/data.feature +22 -0
- data/features/directory_index.feature +36 -0
- data/features/dynamic_pages.feature +95 -0
- data/features/feature_params.feature +6 -0
- data/features/former_padrino_helpers.feature +10 -0
- data/features/front-matter.feature +35 -0
- data/features/helpers_auto_javascript_include_tag.feature +27 -0
- data/features/helpers_auto_stylesheet_link_tag.feature +27 -0
- data/features/helpers_external.feature +6 -0
- data/features/helpers_lorem.feature +6 -0
- data/features/helpers_page_classes.feature +17 -0
- data/features/instance_vars.feature +20 -0
- data/features/mount_rack.feature +8 -0
- data/features/nested_layouts.feature +24 -0
- data/features/partials.feature +41 -0
- data/features/preview_changes.feature +18 -0
- data/features/sitemap_traversal.features +73 -0
- data/features/static_server.feature +6 -0
- data/features/step_definitions/page_layout_steps.rb +15 -0
- data/features/support/env.rb +3 -0
- data/features/wildcard_page_helper.feature +19 -0
- data/fixtures/3rd-party-command/config.rb +10 -0
- data/fixtures/asset-host-app/config.rb +6 -0
- data/fixtures/asset-host-app/source/.htaccess +1 -0
- data/fixtures/asset-host-app/source/asset_host.html.erb +1 -0
- data/fixtures/asset-host-app/source/images/blank.gif +0 -0
- data/fixtures/auto-css-app/config.rb +11 -0
- data/fixtures/auto-css-app/source/auto-css.html.erb +1 -0
- data/fixtures/auto-css-app/source/auto-css/auto-css.html.erb +1 -0
- data/fixtures/auto-css-app/source/auto-css/index.html.erb +1 -0
- data/fixtures/auto-css-app/source/auto-css/sub/auto-css.html.erb +1 -0
- data/fixtures/auto-css-app/source/stylesheets/auto-css.css +3 -0
- data/fixtures/auto-css-app/source/stylesheets/auto-css/auto-css.css +3 -0
- data/fixtures/auto-css-app/source/stylesheets/auto-css/index.css +0 -0
- data/fixtures/auto-css-app/source/stylesheets/auto-css/sub/auto-css.css +3 -0
- data/fixtures/auto-js-app/config.rb +11 -0
- data/fixtures/auto-js-app/source/auto-js.html.erb +1 -0
- data/fixtures/auto-js-app/source/auto-js/auto-js.html.erb +1 -0
- data/fixtures/auto-js-app/source/auto-js/index.html.erb +1 -0
- data/fixtures/auto-js-app/source/auto-js/sub/auto-js.html.erb +1 -0
- data/fixtures/auto-js-app/source/javascripts/auto-js.js +1 -0
- data/fixtures/auto-js-app/source/javascripts/auto-js/auto-js.js +1 -0
- data/fixtures/auto-js-app/source/javascripts/auto-js/index.js +1 -0
- data/fixtures/auto-js-app/source/javascripts/auto-js/sub/auto-js.js +1 -0
- data/fixtures/automatic-image-size-app/config.rb +0 -0
- data/fixtures/automatic-image-size-app/source/auto-image-sizes.html.erb +1 -0
- data/fixtures/automatic-image-size-app/source/images/blank.gif +0 -0
- data/fixtures/basic-data-app/config.rb +4 -0
- data/fixtures/basic-data-app/data/test.yml +4 -0
- data/fixtures/basic-data-app/data/test2.json +4 -0
- data/fixtures/basic-data-app/source/data.html.erb +1 -0
- data/fixtures/basic-data-app/source/data3.html.erb +1 -0
- data/fixtures/build-with-errors-app/config.rb +1 -0
- data/fixtures/build-with-errors-app/source/index.html.erb +1 -0
- data/fixtures/chained-app/config.rb +0 -0
- data/fixtures/chained-app/data/article.yml +2 -0
- data/fixtures/chained-app/source/index.html.str.erb +8 -0
- data/fixtures/clean-app/config-complications.rb +11 -0
- data/fixtures/clean-app/config-empty.rb +0 -0
- data/fixtures/clean-app/config.rb +11 -0
- data/fixtures/clean-app/source/index.html.erb +1 -0
- data/fixtures/clean-app/source/layout.erb +9 -0
- data/fixtures/clean-app/source/layouts/custom.erb +8 -0
- data/fixtures/clean-app/source/real.html +1 -0
- data/fixtures/clean-app/source/real/index.html.erb +5 -0
- data/fixtures/clean-app/source/should_be_ignored.html +1 -0
- data/fixtures/clean-app/source/should_be_ignored2.html +1 -0
- data/fixtures/clean-app/source/should_be_ignored3.html +1 -0
- data/fixtures/clean-app/source/static.html +1 -0
- data/fixtures/clean-dir-app/config.rb +1 -0
- data/fixtures/clean-dir-app/source/about.html +1 -0
- data/fixtures/content-for-app/config.rb +3 -0
- data/fixtures/content-for-app/source/content_for_erb.html.erb +5 -0
- data/fixtures/content-for-app/source/layouts/content_for.erb +4 -0
- data/fixtures/current-page-app/config.rb +3 -0
- data/fixtures/current-page-app/source/request-path.html.erb +1 -0
- data/fixtures/custom-layout-app/config.rb +1 -0
- data/fixtures/custom-layout-app/source/index.html.erb +1 -0
- data/fixtures/custom-layout-app/source/layout.str +9 -0
- data/fixtures/custom-layout-app2/config.rb +0 -0
- data/fixtures/custom-layout-app2/source/custom-layout-dir/index.html.erb +1 -0
- data/fixtures/custom-layout-app2/source/custom-layout.html.erb +1 -0
- data/fixtures/custom-layout-app2/source/layouts/custom.erb +8 -0
- data/fixtures/data-app/config.rb +3 -0
- data/fixtures/data-app/data/pages.yml +6 -0
- data/fixtures/data-app/source/index.html.erb +1 -0
- data/fixtures/data-app/source/layout.erb +5 -0
- data/fixtures/different-engine-layout/config.rb +0 -0
- data/fixtures/different-engine-layout/source/index.html.str +1 -0
- data/fixtures/different-engine-layout/source/layout.erb +9 -0
- data/fixtures/different-engine-partial/config.rb +0 -0
- data/fixtures/different-engine-partial/source/index.html.erb +1 -0
- data/fixtures/different-engine-partial/source/layouts/layout.erb +7 -0
- data/fixtures/different-engine-partial/source/shared/_footer.str +1 -0
- data/fixtures/different-engine-partial/source/shared/_header.erb +1 -0
- data/fixtures/dynamic-pages-app/config.rb +29 -0
- data/fixtures/dynamic-pages-app/source/real.html +1 -0
- data/fixtures/dynamic-pages-app/source/real/index.html.erb +5 -0
- data/fixtures/dynamic-pages-app/source/should_be_ignored.html +1 -0
- data/fixtures/dynamic-pages-app/source/should_be_ignored2.html +1 -0
- data/fixtures/dynamic-pages-app/source/should_be_ignored3.html +1 -0
- data/fixtures/dynamic-pages-app/source/should_be_ignored4.html +1 -0
- data/fixtures/dynamic-pages-app/source/should_be_ignored5.html +1 -0
- data/fixtures/dynamic-pages-app/source/should_be_ignored6.html +1 -0
- data/fixtures/dynamic-pages-app/source/should_be_ignored7.html +1 -0
- data/fixtures/dynamic-pages-app/source/should_be_ignored8.html +1 -0
- data/fixtures/empty-app/not-config.rb +0 -0
- data/fixtures/engine-matching-layout/config.rb +0 -0
- data/fixtures/engine-matching-layout/source/index.html.erb +1 -0
- data/fixtures/engine-matching-layout/source/layout.erb +9 -0
- data/fixtures/external-helpers/config.rb +4 -0
- data/fixtures/external-helpers/lib/hello_helper.rb +5 -0
- data/fixtures/external-helpers/source/index.html.erb +1 -0
- data/fixtures/feature-params-app/config.rb +12 -0
- data/fixtures/feature-params-app/source/index.html.erb +3 -0
- data/fixtures/frontmatter-app/config.rb +0 -0
- data/fixtures/frontmatter-app/source/front-matter-2.php.erb +7 -0
- data/fixtures/frontmatter-app/source/front-matter-change.html.erb +5 -0
- data/fixtures/frontmatter-app/source/front-matter.html.erb +6 -0
- data/fixtures/generator-test/config.rb +80 -0
- data/fixtures/generator-test/source/index.html.erb +10 -0
- data/fixtures/glob-app/config.rb +1 -0
- data/fixtures/glob-app/source/index.html.erb +4 -0
- data/fixtures/glob-app/source/stylesheets/site.css.str +3 -0
- data/fixtures/ignore-app/config.rb +2 -0
- data/fixtures/ignore-app/source/articles/template.html.erb +1 -0
- data/fixtures/ignore-app/source/template.html.erb +1 -0
- data/fixtures/indexable-app/config.rb +2 -0
- data/fixtures/indexable-app/source/.htaccess +1 -0
- data/fixtures/indexable-app/source/a_folder/needs_index.html +1 -0
- data/fixtures/indexable-app/source/leave_me_alone.html +1 -0
- data/fixtures/indexable-app/source/needs_index.html +1 -0
- data/fixtures/indexable-app/source/regular/index.html +1 -0
- data/fixtures/instance-vars-app/config.rb +0 -0
- data/fixtures/instance-vars-app/source/_vartial.erb +5 -0
- data/fixtures/instance-vars-app/source/instance-var-set.html.erb +2 -0
- data/fixtures/instance-vars-app/source/layout.erb +3 -0
- data/fixtures/instance-vars-app/source/no-instance-var.html.erb +1 -0
- data/fixtures/large-build-app/config.rb +3 -0
- data/fixtures/large-build-app/source/.htaccess +1 -0
- data/fixtures/large-build-app/source/_partial.erb +1 -0
- data/fixtures/large-build-app/source/images/Child folder/regular_file(example).txt +1 -0
- data/fixtures/large-build-app/source/images/Read me (example).txt +1 -0
- data/fixtures/large-build-app/source/images/blank.gif +0 -0
- data/fixtures/large-build-app/source/index.html.erb +1 -0
- data/fixtures/large-build-app/source/layout.erb +9 -0
- data/fixtures/large-build-app/source/layouts/content_for.erb +4 -0
- data/fixtures/large-build-app/source/layouts/custom.erb +8 -0
- data/fixtures/large-build-app/source/other_layout.erb +1 -0
- data/fixtures/large-build-app/source/services/index.html.erb +1 -0
- data/fixtures/large-build-app/source/spaces in file.html.erb +1 -0
- data/fixtures/large-build-app/source/static.html +1 -0
- data/fixtures/large-build-app/source/stylesheets/static.css +2 -0
- data/fixtures/lorem-app/config.rb +0 -0
- data/fixtures/lorem-app/source/lorem.html.erb +13 -0
- data/fixtures/manual-layout-missing/config.rb +1 -0
- data/fixtures/manual-layout-missing/source/index.html.erb +1 -0
- data/fixtures/manual-layout-override/config.rb +3 -0
- data/fixtures/manual-layout-override/source/index.html.erb +1 -0
- data/fixtures/manual-layout-override/source/layouts/another.erb +9 -0
- data/fixtures/manual-layout-override/source/layouts/custom.erb +9 -0
- data/fixtures/manual-layout/config.rb +1 -0
- data/fixtures/manual-layout/source/index.html.erb +1 -0
- data/fixtures/manual-layout/source/layouts/custom.erb +9 -0
- data/fixtures/multiple-layouts/config.rb +0 -0
- data/fixtures/multiple-layouts/source/index.html.erb +1 -0
- data/fixtures/multiple-layouts/source/layout.erb +9 -0
- data/fixtures/multiple-layouts/source/layout.str +9 -0
- data/fixtures/nested-layout-app/config.rb +1 -0
- data/fixtures/nested-layout-app/source/data-one.html.erb +5 -0
- data/fixtures/nested-layout-app/source/data-two.html.erb +5 -0
- data/fixtures/nested-layout-app/source/index.html.erb +1 -0
- data/fixtures/nested-layout-app/source/layouts/inner.erb +4 -0
- data/fixtures/nested-layout-app/source/layouts/master.erb +3 -0
- data/fixtures/nested-layout-app/source/layouts/outer.erb +4 -0
- data/fixtures/no-layout/config.rb +0 -0
- data/fixtures/no-layout/source/index.html.erb +1 -0
- data/fixtures/padrino-helpers-app/config.rb +0 -0
- data/fixtures/padrino-helpers-app/source/former_padrino_test.html.erb +4 -0
- data/fixtures/page-classes-app/config.rb +4 -0
- data/fixtures/page-classes-app/source/page-classes.html.erb +1 -0
- data/fixtures/page-classes-app/source/sub1/page-classes.html.erb +1 -0
- data/fixtures/page-classes-app/source/sub1/sub2/page-classes.html.erb +1 -0
- data/fixtures/partials-app/config.rb +0 -0
- data/fixtures/partials-app/source/_locals.erb +1 -0
- data/fixtures/partials-app/source/_main.erb +1 -0
- data/fixtures/partials-app/source/_main.str +1 -0
- data/fixtures/partials-app/source/index.html.erb +3 -0
- data/fixtures/partials-app/source/locals.html.erb +1 -0
- data/fixtures/partials-app/source/second.html.str +3 -0
- data/fixtures/partials-app/source/shared/_footer.erb +1 -0
- data/fixtures/partials-app/source/shared/_header.erb +1 -0
- data/fixtures/partials-app/source/sub/_local.erb +1 -0
- data/fixtures/partials-app/source/sub/index.html.erb +3 -0
- data/fixtures/plain-app/index.html +1 -0
- data/fixtures/preview-app/config.rb +0 -0
- data/fixtures/preview-app/source/content.html.erb +1 -0
- data/fixtures/preview-app/source/layout.erb +1 -0
- data/fixtures/sinatra-app/config.rb +11 -0
- data/fixtures/sinatra-app/source/index.html.erb +5 -0
- data/fixtures/traversal-app/config.rb +7 -0
- data/fixtures/traversal-app/source/directory-indexed.html.erb +0 -0
- data/fixtures/traversal-app/source/directory-indexed/sibling.html.erb +3 -0
- data/fixtures/traversal-app/source/directory-indexed/sibling2.html.erb +3 -0
- data/fixtures/traversal-app/source/directory-indexed/sub2/index.html.erb +0 -0
- data/fixtures/traversal-app/source/directory-indexed/sub3/deep.html.erb +0 -0
- data/fixtures/traversal-app/source/index.html.erb +0 -0
- data/fixtures/traversal-app/source/layout.erb +19 -0
- data/fixtures/traversal-app/source/proxied.html.erb +0 -0
- data/fixtures/traversal-app/source/root.html.erb +0 -0
- data/fixtures/traversal-app/source/sub/index.html.erb +0 -0
- data/fixtures/traversal-app/source/sub/sibling.html.erb +0 -0
- data/fixtures/traversal-app/source/sub/sibling2.html.erb +0 -0
- data/fixtures/traversal-app/source/sub/sub2/index.html.erb +0 -0
- data/fixtures/traversal-app/source/sub/sub3/deep.html.erb +0 -0
- data/fixtures/wildcard-app/config.rb +1 -0
- data/fixtures/wildcard-app/source/admin/index.html.erb +1 -0
- data/fixtures/wildcard-app/source/admin/page.html.erb +1 -0
- data/fixtures/wildcard-app/source/index.html.erb +1 -0
- data/fixtures/wildcard-app/source/layouts/admin.erb +2 -0
- data/fixtures/wildcard-app/source/layouts/layout.erb +2 -0
- data/fixtures/wildcard-directory-index-app/config.rb +2 -0
- data/fixtures/wildcard-directory-index-app/source/admin/index.html.erb +1 -0
- data/fixtures/wildcard-directory-index-app/source/admin/page.html.erb +1 -0
- data/fixtures/wildcard-directory-index-app/source/index.html.erb +1 -0
- data/fixtures/wildcard-directory-index-app/source/layouts/admin.erb +2 -0
- data/fixtures/wildcard-directory-index-app/source/layouts/layout.erb +2 -0
- data/lib/middleman-core.rb +259 -0
- data/lib/middleman-core/base.rb +494 -0
- data/lib/middleman-core/cache.rb +57 -0
- data/lib/middleman-core/cli.rb +57 -0
- data/lib/middleman-core/cli/build.rb +229 -0
- data/lib/middleman-core/cli/init.rb +52 -0
- data/lib/middleman-core/cli/server.rb +52 -0
- data/lib/middleman-core/core_extensions/assets.rb +30 -0
- data/lib/middleman-core/core_extensions/builder.rb +49 -0
- data/lib/middleman-core/core_extensions/data.rb +193 -0
- data/lib/middleman-core/core_extensions/default_helpers.rb +119 -0
- data/lib/middleman-core/core_extensions/extensions.rb +148 -0
- data/lib/middleman-core/core_extensions/file_watcher.rb +83 -0
- data/lib/middleman-core/core_extensions/front_matter.rb +145 -0
- data/lib/middleman-core/core_extensions/rendering.rb +247 -0
- data/lib/middleman-core/core_extensions/routing.rb +69 -0
- data/lib/middleman-core/core_extensions/show_exceptions.rb +16 -0
- data/lib/middleman-core/core_extensions/sitemap.rb +72 -0
- data/lib/middleman-core/extensions/asset_host.rb +29 -0
- data/lib/middleman-core/extensions/automatic_image_sizes.rb +38 -0
- data/lib/middleman-core/extensions/automatic_image_sizes/fastimage.rb +287 -0
- data/lib/middleman-core/extensions/directory_indexes.rb +62 -0
- data/lib/middleman-core/extensions/lorem.rb +140 -0
- data/lib/middleman-core/guard.rb +148 -0
- data/lib/middleman-core/renderers/erb.rb +19 -0
- data/lib/middleman-core/sitemap/page.rb +186 -0
- data/lib/middleman-core/sitemap/store.rb +139 -0
- data/lib/middleman-core/sitemap/template.rb +82 -0
- data/lib/middleman-core/step_definitions.rb +12 -0
- data/lib/middleman-core/step_definitions/builder_steps.rb +42 -0
- data/lib/middleman-core/step_definitions/middleman_steps.rb +15 -0
- data/lib/middleman-core/step_definitions/server_steps.rb +73 -0
- data/lib/middleman-core/templates.rb +82 -0
- data/lib/middleman-core/templates/default.rb +29 -0
- data/lib/middleman-core/templates/default/source/images/background.png +0 -0
- data/lib/middleman-core/templates/default/source/images/middleman.png +0 -0
- data/lib/middleman-core/templates/default/source/index.html.erb +10 -0
- data/lib/middleman-core/templates/default/source/javascripts/all.js +1 -0
- data/lib/middleman-core/templates/default/source/layouts/layout.erb +19 -0
- data/lib/middleman-core/templates/default/source/stylesheets/_animate.scss +23 -0
- data/lib/middleman-core/templates/default/source/stylesheets/_normalize.scss +431 -0
- data/lib/middleman-core/templates/default/source/stylesheets/all.css.scss +40 -0
- data/lib/middleman-core/templates/html5.rb +25 -0
- data/lib/middleman-core/templates/html5/source/404.html +38 -0
- data/lib/middleman-core/templates/html5/source/README.md +388 -0
- data/lib/middleman-core/templates/html5/source/apple-touch-icon-114x114-precomposed.png +0 -0
- data/lib/middleman-core/templates/html5/source/apple-touch-icon-57x57-precomposed.png +0 -0
- data/lib/middleman-core/templates/html5/source/apple-touch-icon-72x72-precomposed.png +0 -0
- data/lib/middleman-core/templates/html5/source/apple-touch-icon-precomposed.png +0 -0
- data/lib/middleman-core/templates/html5/source/apple-touch-icon.png +0 -0
- data/lib/middleman-core/templates/html5/source/crossdomain.xml +25 -0
- data/lib/middleman-core/templates/html5/source/css/style.css +293 -0
- data/lib/middleman-core/templates/html5/source/favicon.ico +0 -0
- data/lib/middleman-core/templates/html5/source/humans.txt +43 -0
- data/lib/middleman-core/templates/html5/source/img/.gitignore +2 -0
- data/lib/middleman-core/templates/html5/source/index.html +79 -0
- data/lib/middleman-core/templates/html5/source/js/libs/jquery-1.6.2.js +8981 -0
- data/lib/middleman-core/templates/html5/source/js/libs/jquery-1.6.2.min.js +18 -0
- data/lib/middleman-core/templates/html5/source/js/libs/modernizr-2.0.6.min.js +4 -0
- data/lib/middleman-core/templates/html5/source/js/mylibs/.gitignore +2 -0
- data/lib/middleman-core/templates/html5/source/js/plugins.js +20 -0
- data/lib/middleman-core/templates/html5/source/js/script.js +8 -0
- data/lib/middleman-core/templates/html5/source/robots.txt +5 -0
- data/lib/middleman-core/templates/html5/source/test/index.html +31 -0
- data/lib/middleman-core/templates/html5/source/test/qunit/qunit.css +148 -0
- data/lib/middleman-core/templates/html5/source/test/qunit/qunit.js +1265 -0
- data/lib/middleman-core/templates/html5/source/test/tests.js +24 -0
- data/lib/middleman-core/templates/local.rb +21 -0
- data/lib/middleman-core/templates/mobile.rb +25 -0
- data/lib/middleman-core/templates/mobile/source/404.html +37 -0
- data/lib/middleman-core/templates/mobile/source/README.markdown +21 -0
- data/lib/middleman-core/templates/mobile/source/crossdomain.xml +25 -0
- data/lib/middleman-core/templates/mobile/source/css/style.css +315 -0
- data/lib/middleman-core/templates/mobile/source/humans.txt +43 -0
- data/lib/middleman-core/templates/mobile/source/img/h/apple-touch-icon.png +0 -0
- data/lib/middleman-core/templates/mobile/source/img/h/splash.png +0 -0
- data/lib/middleman-core/templates/mobile/source/img/l/apple-touch-icon-precomposed.png +0 -0
- data/lib/middleman-core/templates/mobile/source/img/l/apple-touch-icon.png +0 -0
- data/lib/middleman-core/templates/mobile/source/img/l/splash.png +0 -0
- data/lib/middleman-core/templates/mobile/source/img/m/apple-touch-icon.png +0 -0
- data/lib/middleman-core/templates/mobile/source/index.html +92 -0
- data/lib/middleman-core/templates/mobile/source/js/libs/modernizr-custom.js +14 -0
- data/lib/middleman-core/templates/mobile/source/js/libs/respond.min.js +7 -0
- data/lib/middleman-core/templates/mobile/source/js/mylibs/helper.js +171 -0
- data/lib/middleman-core/templates/mobile/source/js/plugins.js +20 -0
- data/lib/middleman-core/templates/mobile/source/js/script.js +0 -0
- data/lib/middleman-core/templates/mobile/source/robots.txt +4 -0
- data/lib/middleman-core/templates/mobile/source/sitemap.xml +9 -0
- data/lib/middleman-core/templates/mobile/source/test/index.html +31 -0
- data/lib/middleman-core/templates/mobile/source/test/qunit/qunit.css +148 -0
- data/lib/middleman-core/templates/mobile/source/test/qunit/qunit.js +1265 -0
- data/lib/middleman-core/templates/mobile/source/test/tests.js +21 -0
- data/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/Readme.PDF +0 -0
- data/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/aspx/aspx1.snippet +31 -0
- data/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/aspx/aspx2.snippet +2 -0
- data/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/aspx/ga.aspx +195 -0
- data/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/aspx/sample.aspx +44 -0
- data/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/jsp/ga.jsp +225 -0
- data/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/jsp/jsp1.snippet +35 -0
- data/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/jsp/jsp2.snippet +2 -0
- data/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/jsp/sample.jsp +51 -0
- data/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/php/ga.php +176 -0
- data/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/php/php1.snippet +30 -0
- data/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/php/php2.snippet +4 -0
- data/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/php/sample.php +44 -0
- data/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/pl/ga.pl +195 -0
- data/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/pl/perl1.snippet +27 -0
- data/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/pl/perl2.snippet +1 -0
- data/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/pl/sample.pl +38 -0
- data/lib/middleman-core/templates/mobile/source/tools/mobile-bookmark-bubble/COPYING +202 -0
- data/lib/middleman-core/templates/mobile/source/tools/mobile-bookmark-bubble/bookmark_bubble.js +559 -0
- data/lib/middleman-core/templates/mobile/source/tools/mobile-bookmark-bubble/example/example.html +43 -0
- data/lib/middleman-core/templates/mobile/source/tools/mobile-bookmark-bubble/example/example.js +57 -0
- data/lib/middleman-core/templates/mobile/source/tools/mobile-bookmark-bubble/images/arrow.png +0 -0
- data/lib/middleman-core/templates/mobile/source/tools/mobile-bookmark-bubble/images/close.png +0 -0
- data/lib/middleman-core/templates/mobile/source/tools/mobile-bookmark-bubble/images/generate_base64_images +33 -0
- data/lib/middleman-core/templates/mobile/source/tools/mobile-bookmark-bubble/images/icon_calendar.png +0 -0
- data/lib/middleman-core/templates/mobile/source/tools/wspl/README +27 -0
- data/lib/middleman-core/templates/mobile/source/tools/wspl/databasefactory.js +45 -0
- data/lib/middleman-core/templates/mobile/source/tools/wspl/dbworker.js +324 -0
- data/lib/middleman-core/templates/mobile/source/tools/wspl/dbworker_test.html +393 -0
- data/lib/middleman-core/templates/mobile/source/tools/wspl/dbworkerstarter.js +32 -0
- data/lib/middleman-core/templates/mobile/source/tools/wspl/dbwrapper_gears.js +595 -0
- data/lib/middleman-core/templates/mobile/source/tools/wspl/dbwrapper_gears_test.html +404 -0
- data/lib/middleman-core/templates/mobile/source/tools/wspl/dbwrapper_html5.js +203 -0
- data/lib/middleman-core/templates/mobile/source/tools/wspl/dbwrapper_html5_test.html +468 -0
- data/lib/middleman-core/templates/mobile/source/tools/wspl/dbwrapperapi.js +202 -0
- data/lib/middleman-core/templates/mobile/source/tools/wspl/dbwrapperapi_test.html +51 -0
- data/lib/middleman-core/templates/mobile/source/tools/wspl/gears_resultset.js +71 -0
- data/lib/middleman-core/templates/mobile/source/tools/wspl/gears_resultset_test.html +86 -0
- data/lib/middleman-core/templates/mobile/source/tools/wspl/gears_transaction.js +196 -0
- data/lib/middleman-core/templates/mobile/source/tools/wspl/gears_transaction_test.html +221 -0
- data/lib/middleman-core/templates/mobile/source/tools/wspl/gearsutils.js +94 -0
- data/lib/middleman-core/templates/mobile/source/tools/wspl/gearsutils_test.html +84 -0
- data/lib/middleman-core/templates/mobile/source/tools/wspl/global_functions.js +72 -0
- data/lib/middleman-core/templates/mobile/source/tools/wspl/simplenotes/index.html +347 -0
- data/lib/middleman-core/templates/mobile/source/tools/wspl/simplenotes/simplenotes.js +503 -0
- data/lib/middleman-core/templates/mobile/source/tools/wspl/simplenotes/styles.css +66 -0
- data/lib/middleman-core/templates/mobile/source/tools/wspl/simplenotes/template.js +75 -0
- data/lib/middleman-core/templates/shared/Gemfile.tt +3 -0
- data/lib/middleman-core/templates/shared/config.ru +4 -0
- data/lib/middleman-core/templates/shared/config.tt +92 -0
- data/lib/middleman-core/vendor/hooks-0.2.0/CHANGES.textile +9 -0
- data/lib/middleman-core/vendor/hooks-0.2.0/Gemfile +3 -0
- data/lib/middleman-core/vendor/hooks-0.2.0/README.rdoc +107 -0
- data/lib/middleman-core/vendor/hooks-0.2.0/Rakefile +12 -0
- data/lib/middleman-core/vendor/hooks-0.2.0/hooks.gemspec +22 -0
- data/lib/middleman-core/vendor/hooks-0.2.0/lib/hooks.rb +109 -0
- data/lib/middleman-core/vendor/hooks-0.2.0/lib/hooks/inheritable_attribute.rb +33 -0
- data/lib/middleman-core/vendor/hooks-0.2.0/test/hooks_test.rb +141 -0
- data/lib/middleman-core/vendor/hooks-0.2.0/test/inheritable_attribute_test.rb +55 -0
- data/lib/middleman-core/vendor/hooks-0.2.0/test/test_helper.rb +10 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/.document +5 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/.gitignore +22 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/.yardopts +1 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/LICENSE.txt +20 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/README.rdoc +294 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/Rakefile +5 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/bin/padrino +9 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/lib/padrino-core.rb +167 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/lib/padrino-core/application.rb +270 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/lib/padrino-core/application/rendering.rb +292 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/lib/padrino-core/application/routing.rb +934 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/lib/padrino-core/application/showexceptions.rb +20 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/lib/padrino-core/caller.rb +53 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/lib/padrino-core/cli/adapter.rb +24 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/lib/padrino-core/cli/base.rb +151 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/lib/padrino-core/cli/console.rb +20 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/lib/padrino-core/cli/rake.rb +24 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/lib/padrino-core/cli/rake_tasks.rb +59 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/lib/padrino-core/command.rb +38 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/lib/padrino-core/images/404.png +0 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/lib/padrino-core/images/500.png +0 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/lib/padrino-core/loader.rb +210 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/lib/padrino-core/locale/cs.yml +34 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/lib/padrino-core/locale/da.yml +34 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/lib/padrino-core/locale/de.yml +34 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/lib/padrino-core/locale/en.yml +34 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/lib/padrino-core/locale/es.yml +34 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/lib/padrino-core/locale/fr.yml +34 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/lib/padrino-core/locale/hu.yml +34 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/lib/padrino-core/locale/it.yml +40 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/lib/padrino-core/locale/ja.yml +34 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/lib/padrino-core/locale/lv.yml +34 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/lib/padrino-core/locale/nl.yml +34 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/lib/padrino-core/locale/no.yml +35 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/lib/padrino-core/locale/pl.yml +34 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/lib/padrino-core/locale/pt_br.yml +40 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/lib/padrino-core/locale/ru.yml +35 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/lib/padrino-core/locale/tr.yml +34 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/lib/padrino-core/locale/uk.yml +34 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/lib/padrino-core/locale/zh_cn.yml +34 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/lib/padrino-core/locale/zh_tw.yml +34 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/lib/padrino-core/logger.rb +345 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/lib/padrino-core/mounter.rb +224 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/lib/padrino-core/reloader.rb +254 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/lib/padrino-core/router.rb +98 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/lib/padrino-core/server.rb +79 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/lib/padrino-core/support_lite.rb +200 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/lib/padrino-core/tasks.rb +21 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/lib/padrino-core/version.rb +20 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/padrino-core.gemspec +38 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/test/fixtures/apps/.components +6 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/test/fixtures/apps/.gitignore +7 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/test/fixtures/apps/complex.rb +32 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/test/fixtures/apps/simple.rb +33 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/test/fixtures/dependencies/a.rb +9 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/test/fixtures/dependencies/b.rb +4 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/test/fixtures/dependencies/c.rb +1 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/test/fixtures/dependencies/circular/e.rb +13 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/test/fixtures/dependencies/circular/f.rb +2 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/test/fixtures/dependencies/circular/g.rb +2 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/test/fixtures/dependencies/d.rb +4 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/test/helper.rb +81 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/test/mini_shoulda.rb +45 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/test/test_application.rb +108 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/test/test_core.rb +79 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/test/test_dependencies.rb +44 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/test/test_filters.rb +278 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/test/test_locale.rb +21 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/test/test_logger.rb +100 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/test/test_mounter.rb +177 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/test/test_reloader_complex.rb +75 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/test/test_reloader_simple.rb +98 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/test/test_rendering.rb +461 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/test/test_restful_routing.rb +33 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/test/test_router.rb +146 -0
- data/lib/middleman-core/vendor/padrino-core-0.10.5/test/test_routing.rb +1673 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/.document +5 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/.gitignore +21 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/.yardopts +1 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/LICENSE.txt +20 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/README.rdoc +239 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/Rakefile +5 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/lib/padrino-helpers.rb +58 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/asset_tag_helpers.rb +420 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/form_builder/abstract_form_builder.rb +220 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/form_builder/standard_form_builder.rb +43 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/form_helpers.rb +602 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/format_helpers.rb +381 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/cs.yml +103 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/da.yml +91 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/de.yml +81 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/en.yml +103 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/es.yml +103 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/fr.yml +80 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/hu.yml +103 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/it.yml +89 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/ja.yml +103 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/lv.yml +103 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/nl.yml +82 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/no.yml +91 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/pl.yml +95 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/pt_br.yml +103 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/ru.yml +103 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/tr.yml +103 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/uk.yml +103 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/zh_cn.yml +104 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/zh_tw.yml +103 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/number_helpers.rb +288 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/output_helpers.rb +175 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/output_helpers/abstract_handler.rb +98 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/output_helpers/erb_handler.rb +79 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/output_helpers/haml_handler.rb +63 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/output_helpers/slim_handler.rb +81 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/render_helpers.rb +60 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/tag_helpers.rb +103 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/translation_helpers.rb +38 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/padrino-helpers.gemspec +27 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/app.rb +73 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/capture_concat.erb +14 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/capture_concat.haml +12 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/capture_concat.slim +13 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/content_for.erb +14 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/content_for.haml +12 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/content_for.slim +12 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/content_tag.erb +11 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/content_tag.haml +9 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/content_tag.slim +9 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/current_engine.erb +5 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/current_engine.haml +5 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/current_engine.slim +5 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/fields_for.erb +20 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/fields_for.haml +15 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/fields_for.slim +15 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/form_for.erb +56 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/form_for.haml +47 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/form_for.slim +47 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/form_tag.erb +56 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/form_tag.haml +45 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/form_tag.slim +45 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/link_to.erb +5 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/link_to.haml +4 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/link_to.slim +4 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/mail_to.erb +3 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/mail_to.haml +3 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/mail_to.slim +3 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/meta_tag.erb +3 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/meta_tag.haml +3 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/meta_tag.slim +3 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/partials/_erb.erb +1 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/partials/_haml.haml +1 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/partials/_slim.slim +1 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/simple_partial.erb +1 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/simple_partial.haml +1 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/simple_partial.slim +1 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/fixtures/render_app/app.rb +50 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/fixtures/render_app/views/current_engine.haml +5 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/fixtures/render_app/views/current_engines/_erb.erb +1 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/fixtures/render_app/views/current_engines/_haml.haml +1 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/fixtures/render_app/views/current_engines/_slim.slim +1 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/fixtures/render_app/views/erb/test.erb +1 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/fixtures/render_app/views/explicit_engine.haml +5 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/fixtures/render_app/views/haml/test.haml +1 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/fixtures/render_app/views/template/_user.haml +7 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/fixtures/render_app/views/template/haml_template.haml +1 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/fixtures/render_app/views/template/some_template.haml +2 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/helper.rb +66 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/test_asset_tag_helpers.rb +320 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/test_form_builder.rb +996 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/test_form_helpers.rb +645 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/test_format_helpers.rb +227 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/test_locale.rb +20 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/test_number_helpers.rb +136 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/test_output_helpers.rb +153 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/test_render_helpers.rb +76 -0
- data/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/test_tag_helpers.rb +105 -0
- data/lib/middleman-core/version.rb +13 -0
- data/middleman-core.gemspec +41 -0
- metadata +974 -0
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
module Padrino
|
|
2
|
+
module Helpers
|
|
3
|
+
module FormBuilder # @private
|
|
4
|
+
class AbstractFormBuilder # @private
|
|
5
|
+
attr_accessor :template, :object
|
|
6
|
+
|
|
7
|
+
def initialize(template, object, options={})
|
|
8
|
+
@template = template
|
|
9
|
+
@object = build_object(object)
|
|
10
|
+
@options = options
|
|
11
|
+
raise "FormBuilder template must be initialized!" unless template
|
|
12
|
+
raise "FormBuilder object must not be a nil value. If there's no object, use a symbol instead! (i.e :user)" unless object
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# f.error_messages
|
|
16
|
+
def error_messages(*params)
|
|
17
|
+
params.unshift object
|
|
18
|
+
@template.error_messages_for(*params)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# f.error_message_on(field)
|
|
22
|
+
def error_message_on(field, options={})
|
|
23
|
+
@template.error_message_on(object, field, options)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# f.label :username, :caption => "Nickname"
|
|
27
|
+
def label(field, options={})
|
|
28
|
+
options.reverse_merge!(:caption => "#{field_human_name(field)}: ")
|
|
29
|
+
@template.label_tag(field_id(field), options)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# f.hidden_field :session_id, :value => "45"
|
|
33
|
+
def hidden_field(field, options={})
|
|
34
|
+
options.reverse_merge!(:value => field_value(field), :id => field_id(field))
|
|
35
|
+
@template.hidden_field_tag field_name(field), options
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# f.text_field :username, :value => "(blank)", :id => 'username'
|
|
39
|
+
def text_field(field, options={})
|
|
40
|
+
options.reverse_merge!(:value => field_value(field), :id => field_id(field))
|
|
41
|
+
options.merge!(:class => field_error(field, options))
|
|
42
|
+
@template.text_field_tag field_name(field), options
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# f.text_area :summary, :value => "(enter summary)", :id => 'summary'
|
|
46
|
+
def text_area(field, options={})
|
|
47
|
+
options.reverse_merge!(:value => field_value(field), :id => field_id(field))
|
|
48
|
+
options.merge!(:class => field_error(field, options))
|
|
49
|
+
@template.text_area_tag field_name(field), options
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# f.password_field :password, :id => 'password'
|
|
53
|
+
def password_field(field, options={})
|
|
54
|
+
options.reverse_merge!(:value => field_value(field), :id => field_id(field))
|
|
55
|
+
options.merge!(:class => field_error(field, options))
|
|
56
|
+
@template.password_field_tag field_name(field), options
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# f.select :color, :options => ['red', 'green'], :include_blank => true
|
|
60
|
+
# f.select :color, :collection => @colors, :fields => [:name, :id]
|
|
61
|
+
def select(field, options={})
|
|
62
|
+
options.reverse_merge!(:id => field_id(field), :selected => field_value(field))
|
|
63
|
+
options.merge!(:class => field_error(field, options))
|
|
64
|
+
@template.select_tag field_name(field), options
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
# f.check_box :remember_me, :value => 'true', :uncheck_value => '0'
|
|
68
|
+
def check_box(field, options={})
|
|
69
|
+
unchecked_value = options.delete(:uncheck_value) || '0'
|
|
70
|
+
options.reverse_merge!(:id => field_id(field), :value => '1')
|
|
71
|
+
options.reverse_merge!(:checked => true) if values_matches_field?(field, options[:value])
|
|
72
|
+
html = @template.hidden_field_tag(options[:name] || field_name(field), :value => unchecked_value, :id => nil)
|
|
73
|
+
html << @template.check_box_tag(field_name(field), options)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# f.radio_button :gender, :value => 'male'
|
|
77
|
+
def radio_button(field, options={})
|
|
78
|
+
options.reverse_merge!(:id => field_id(field, options[:value]))
|
|
79
|
+
options.reverse_merge!(:checked => true) if values_matches_field?(field, options[:value])
|
|
80
|
+
@template.radio_button_tag field_name(field), options
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
# f.file_field :photo, :class => 'avatar'
|
|
84
|
+
def file_field(field, options={})
|
|
85
|
+
options.reverse_merge!(:id => field_id(field))
|
|
86
|
+
options.merge!(:class => field_error(field, options))
|
|
87
|
+
@template.file_field_tag field_name(field), options
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
# f.submit "Update", :class => 'large'
|
|
91
|
+
def submit(caption="Submit", options={})
|
|
92
|
+
@template.submit_tag caption, options
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
# f.image_submit "buttons/submit.png", :class => 'large'
|
|
96
|
+
def image_submit(source, options={})
|
|
97
|
+
@template.image_submit_tag source, options
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
# Supports nested fields for a child model within a form
|
|
101
|
+
# f.fields_for :addresses
|
|
102
|
+
# f.fields_for :addresses, address
|
|
103
|
+
# f.fields_for :addresses, @addresses
|
|
104
|
+
def fields_for(child_association, instance_or_collection=nil, &block)
|
|
105
|
+
default_collection = self.object.send(child_association)
|
|
106
|
+
include_index = default_collection.respond_to?(:each)
|
|
107
|
+
nested_options = { :parent => self, :association => child_association }
|
|
108
|
+
nested_objects = instance_or_collection ? Array(instance_or_collection) : Array(default_collection)
|
|
109
|
+
result = nested_objects.each_with_index.map do |child_instance, index|
|
|
110
|
+
nested_options[:index] = include_index ? index : nil
|
|
111
|
+
@template.fields_for(child_instance, { :nested => nested_options }, &block)
|
|
112
|
+
end.join("\n")
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
protected
|
|
116
|
+
# Returns the known field types for a formbuilder
|
|
117
|
+
def self.field_types
|
|
118
|
+
[:hidden_field, :text_field, :text_area, :password_field, :file_field, :radio_button, :check_box, :select]
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
# Returns true if the value matches the value in the field
|
|
122
|
+
# field_has_value?(:gender, 'male')
|
|
123
|
+
def values_matches_field?(field, value)
|
|
124
|
+
value.present? && (field_value(field).to_s == value.to_s || field_value(field).to_s == 'true')
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
# Add a :invalid css class to the field if it contain an error
|
|
128
|
+
def field_error(field, options)
|
|
129
|
+
error = @object.errors[field] rescue nil
|
|
130
|
+
error.blank? ? options[:class] : [options[:class], :invalid].flatten.compact.join(" ")
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
# Returns the human name of the field. Look that use builtin I18n.
|
|
134
|
+
def field_human_name(field)
|
|
135
|
+
I18n.translate("#{object_model_name}.attributes.#{field}", :count => 1, :default => field.to_s.humanize, :scope => :models)
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
# Returns the name for the given field
|
|
139
|
+
# field_name(:username) => "user[username]"
|
|
140
|
+
# field_name(:number) => "user[telephone_attributes][number]"
|
|
141
|
+
# field_name(:street) => "user[addresses_attributes][0][street]"
|
|
142
|
+
def field_name(field=nil)
|
|
143
|
+
result = []
|
|
144
|
+
if root_form?
|
|
145
|
+
result << object_model_name
|
|
146
|
+
elsif nested_form?
|
|
147
|
+
parent_form = @options[:nested][:parent]
|
|
148
|
+
attributes_name = "#{@options[:nested][:association]}_attributes"
|
|
149
|
+
nested_index = @options[:nested][:index]
|
|
150
|
+
fragment = [parent_form.field_name, "[#{attributes_name}", "]"]
|
|
151
|
+
fragment.insert(2, "][#{nested_index}") if nested_index
|
|
152
|
+
result << fragment
|
|
153
|
+
end
|
|
154
|
+
result << "[#{field}]" unless field.blank?
|
|
155
|
+
result.flatten.join
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
# Returns the id for the given field
|
|
159
|
+
# field_id(:username) => "user_username"
|
|
160
|
+
# field_id(:gender, :male) => "user_gender_male"
|
|
161
|
+
# field_name(:number) => "user_telephone_attributes_number"
|
|
162
|
+
# field_name(:street) => "user_addresses_attributes_0_street"
|
|
163
|
+
def field_id(field=nil, value=nil)
|
|
164
|
+
result = []
|
|
165
|
+
if root_form?
|
|
166
|
+
result << object_model_name
|
|
167
|
+
elsif nested_form?
|
|
168
|
+
parent_form = @options[:nested][:parent]
|
|
169
|
+
attributes_name = "#{@options[:nested][:association]}_attributes"
|
|
170
|
+
nested_index = @options[:nested][:index]
|
|
171
|
+
fragment = [parent_form.field_id, "_#{attributes_name}"]
|
|
172
|
+
fragment.push("_#{nested_index}") if nested_index
|
|
173
|
+
result << fragment
|
|
174
|
+
end
|
|
175
|
+
result << "_#{field}" unless field.blank?
|
|
176
|
+
result << "_#{value}" unless value.blank?
|
|
177
|
+
result.flatten.join
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
# Returns the child object if it exists
|
|
181
|
+
def nested_object_id
|
|
182
|
+
nested_form? && object.respond_to?(:new_record?) && !object.new_record? && object.id
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
# Returns true if this form object is nested in a parent form
|
|
186
|
+
def nested_form?
|
|
187
|
+
@options[:nested] && @options[:nested][:parent] && @options[:nested][:parent].respond_to?(:object)
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
# Returns the value for the object's field
|
|
191
|
+
# field_value(:username) => "Joey"
|
|
192
|
+
def field_value(field)
|
|
193
|
+
@object && @object.respond_to?(field) ? @object.send(field) : ""
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
# explicit_object is either a symbol or a record
|
|
197
|
+
# Returns a new record of the type specified in the object
|
|
198
|
+
def build_object(object_or_symbol)
|
|
199
|
+
object_or_symbol.is_a?(Symbol) ? @template.instance_variable_get("@#{object_or_symbol}") || object_class(object_or_symbol).new : object_or_symbol
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
# Returns the object's models name
|
|
203
|
+
# => user_assignment
|
|
204
|
+
def object_model_name(explicit_object=object)
|
|
205
|
+
explicit_object.is_a?(Symbol) ? explicit_object : explicit_object.class.to_s.underscore.gsub(/\//, '_')
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
# Returns the class type for the given object
|
|
209
|
+
def object_class(explicit_object)
|
|
210
|
+
explicit_object.is_a?(Symbol) ? explicit_object.to_s.camelize.constantize : explicit_object.class
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
# Returns true if this form is the top-level (not nested)
|
|
214
|
+
def root_form?
|
|
215
|
+
!nested_form?
|
|
216
|
+
end
|
|
217
|
+
end # AbstractFormBuilder
|
|
218
|
+
end # FormBuilder
|
|
219
|
+
end # Helpers
|
|
220
|
+
end # Padrino
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/abstract_form_builder') unless defined?(AbstractFormBuilder)
|
|
2
|
+
|
|
3
|
+
module Padrino
|
|
4
|
+
module Helpers
|
|
5
|
+
module FormBuilder # @private
|
|
6
|
+
class StandardFormBuilder < AbstractFormBuilder # @private
|
|
7
|
+
|
|
8
|
+
##
|
|
9
|
+
# StandardFormBuilder
|
|
10
|
+
#
|
|
11
|
+
# text_field_block(:username, { :class => 'long' }, { :class => 'wide-label' })
|
|
12
|
+
# text_area_block(:summary, { :class => 'long' }, { :class => 'wide-label' })
|
|
13
|
+
# password_field_block(:password, { :class => 'long' }, { :class => 'wide-label' })
|
|
14
|
+
# file_field_block(:photo, { :class => 'long' }, { :class => 'wide-label' })
|
|
15
|
+
# check_box_block(:remember_me, { :class => 'long' }, { :class => 'wide-label' })
|
|
16
|
+
# select_block(:color, :options => ['green', 'black'])
|
|
17
|
+
#
|
|
18
|
+
(self.field_types - [ :hidden_field, :radio_button ]).each do |field_type|
|
|
19
|
+
class_eval <<-EOF
|
|
20
|
+
def #{field_type}_block(field, options={}, label_options={})
|
|
21
|
+
label_options.reverse_merge!(:caption => options.delete(:caption)) if options[:caption]
|
|
22
|
+
field_html = label(field, label_options)
|
|
23
|
+
field_html << #{field_type}(field, options)
|
|
24
|
+
@template.content_tag(:p, field_html)
|
|
25
|
+
end
|
|
26
|
+
EOF
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# submit_block("Update")
|
|
30
|
+
def submit_block(caption, options={})
|
|
31
|
+
submit_html = self.submit(caption, options)
|
|
32
|
+
@template.content_tag(:p, submit_html)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# image_submit_block("submit.png")
|
|
36
|
+
def image_submit_block(source, options={})
|
|
37
|
+
submit_html = self.image_submit(source, options)
|
|
38
|
+
@template.content_tag(:p, submit_html)
|
|
39
|
+
end
|
|
40
|
+
end # StandardFormBuilder
|
|
41
|
+
end # FormBuilder
|
|
42
|
+
end # Helpers
|
|
43
|
+
end # Padrino
|
|
@@ -0,0 +1,602 @@
|
|
|
1
|
+
module Padrino
|
|
2
|
+
module Helpers
|
|
3
|
+
##
|
|
4
|
+
# Helpers related to producing form related tags and inputs into templates.
|
|
5
|
+
#
|
|
6
|
+
module FormHelpers
|
|
7
|
+
##
|
|
8
|
+
# Constructs a form for object using given or default form_builder
|
|
9
|
+
#
|
|
10
|
+
# @param [Object] object
|
|
11
|
+
# The object for which the form is being built.
|
|
12
|
+
# @param [String] url
|
|
13
|
+
# The url this form will submit to.
|
|
14
|
+
# @param [Hash] settings
|
|
15
|
+
# The settings associated with this form. Accepts html options.
|
|
16
|
+
# @option settings [String] :builder ("StandardFormBuilder")
|
|
17
|
+
# The FormBuilder class to use such as StandardFormBuilder.
|
|
18
|
+
# @param [Proc] block
|
|
19
|
+
# The fields and content inside this form.
|
|
20
|
+
#
|
|
21
|
+
# @yield [AbstractFormBuilder] The form builder used to compose fields.
|
|
22
|
+
#
|
|
23
|
+
# @return [String] The html object-backed form with the specified options and input fields.
|
|
24
|
+
#
|
|
25
|
+
# @example
|
|
26
|
+
# form_for :user, '/register' do |f| ... end
|
|
27
|
+
# form_for @user, '/register', :id => 'register' do |f| ... end
|
|
28
|
+
#
|
|
29
|
+
# @api public
|
|
30
|
+
def form_for(object, url, settings={}, &block)
|
|
31
|
+
form_html = capture_html(builder_instance(object, settings), &block)
|
|
32
|
+
form_tag(url, settings) { form_html }
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
##
|
|
36
|
+
# Constructs form fields for an object using given or default form_builder
|
|
37
|
+
# Used within an existing form to allow alternate objects within one form
|
|
38
|
+
#
|
|
39
|
+
# @param [Object] object
|
|
40
|
+
# The object for which the fields are being built.
|
|
41
|
+
# @param [Hash] settings
|
|
42
|
+
# The settings associated with these fields. Accepts html options.
|
|
43
|
+
# @param [Proc] block
|
|
44
|
+
# The content inside this set of fields.
|
|
45
|
+
#
|
|
46
|
+
# @return [String] The html fields with the specified options.
|
|
47
|
+
#
|
|
48
|
+
# @example
|
|
49
|
+
# fields_for @user.assignment do |assignment| ... end
|
|
50
|
+
# fields_for :assignment do |assigment| ... end
|
|
51
|
+
#
|
|
52
|
+
# @api public
|
|
53
|
+
def fields_for(object, settings={}, &block)
|
|
54
|
+
instance = builder_instance(object, settings)
|
|
55
|
+
fields_html = capture_html(instance, &block)
|
|
56
|
+
fields_html << instance.hidden_field(:id) if instance.send(:nested_object_id)
|
|
57
|
+
concat_content fields_html
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
##
|
|
61
|
+
# Constructs a form without object based on options
|
|
62
|
+
#
|
|
63
|
+
# @param [String] url
|
|
64
|
+
# The url this form will submit to.
|
|
65
|
+
# @param [Hash] options
|
|
66
|
+
# The html options associated with this form.
|
|
67
|
+
# @param [Proc] block
|
|
68
|
+
# The fields and content inside this form.
|
|
69
|
+
#
|
|
70
|
+
# @return [String] The html form with the specified options and input fields.
|
|
71
|
+
#
|
|
72
|
+
# @example
|
|
73
|
+
# form_tag '/register', :class => "registration_form" do ... end
|
|
74
|
+
#
|
|
75
|
+
# @api public
|
|
76
|
+
def form_tag(url, options={}, &block)
|
|
77
|
+
desired_method = options[:method]
|
|
78
|
+
data_method = options.delete(:method) if options[:method].to_s !~ /get|post/i
|
|
79
|
+
options.reverse_merge!(:method => "post", :action => url)
|
|
80
|
+
options[:enctype] = "multipart/form-data" if options.delete(:multipart)
|
|
81
|
+
options["data-remote"] = "true" if options.delete(:remote)
|
|
82
|
+
options["data-method"] = data_method if data_method
|
|
83
|
+
options["accept-charset"] ||= "UTF-8"
|
|
84
|
+
inner_form_html = hidden_form_method_field(desired_method)
|
|
85
|
+
inner_form_html += capture_html(&block)
|
|
86
|
+
concat_content content_tag(:form, inner_form_html, options)
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
##
|
|
90
|
+
# Returns the hidden method field for 'put' and 'delete' forms
|
|
91
|
+
# Only 'get' and 'post' are allowed within browsers;
|
|
92
|
+
# 'put' and 'delete' are just specified using hidden fields with form action still 'put'.
|
|
93
|
+
#
|
|
94
|
+
# @param [String] desired_method
|
|
95
|
+
# The method this hidden field represents (i.e put or delete))
|
|
96
|
+
#
|
|
97
|
+
# @return [String] The hidden field representing the +desired_method+ for the form.
|
|
98
|
+
#
|
|
99
|
+
# @example
|
|
100
|
+
# # Generate: <input name="_method" value="delete" />
|
|
101
|
+
# hidden_form_method_field('delete')
|
|
102
|
+
#
|
|
103
|
+
# @api semipublic
|
|
104
|
+
def hidden_form_method_field(desired_method)
|
|
105
|
+
return '' if desired_method.blank? || desired_method.to_s =~ /get|post/i
|
|
106
|
+
hidden_field_tag(:_method, :value => desired_method)
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
##
|
|
110
|
+
# Constructs a field_set to group fields with given options
|
|
111
|
+
#
|
|
112
|
+
# @overload field_set_tag(legend=nil, options={}, &block)
|
|
113
|
+
# @param [String] legend The legend caption for the fieldset
|
|
114
|
+
# @param [Hash] options The html options for the fieldset.
|
|
115
|
+
# @param [Proc] block The content inside the fieldset.
|
|
116
|
+
# @overload field_set_tag(options={}, &block)
|
|
117
|
+
# @param [Hash] options The html options for the fieldset.
|
|
118
|
+
# @param [Proc] block The content inside the fieldset.
|
|
119
|
+
#
|
|
120
|
+
# @return [String] The html for the fieldset tag based on given +options+.
|
|
121
|
+
#
|
|
122
|
+
# @example
|
|
123
|
+
# field_set_tag(:class => "office-set") { }
|
|
124
|
+
# field_set_tag("Office", :class => 'office-set') { }
|
|
125
|
+
#
|
|
126
|
+
# @api public
|
|
127
|
+
def field_set_tag(*args, &block)
|
|
128
|
+
options = args.extract_options!
|
|
129
|
+
legend_text = args[0].is_a?(String) ? args.first : nil
|
|
130
|
+
legend_html = legend_text.blank? ? '' : content_tag(:legend, legend_text)
|
|
131
|
+
field_set_content = legend_html + capture_html(&block)
|
|
132
|
+
concat_content content_tag(:fieldset, field_set_content, options)
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
##
|
|
136
|
+
# Constructs list html for the errors for a given symbol
|
|
137
|
+
#
|
|
138
|
+
# @overload error_messages_for(*objects, options = {})
|
|
139
|
+
# @param [Array<Object>] object Splat of objects to display errors for.
|
|
140
|
+
# @param [Hash] options Error message display options.
|
|
141
|
+
# @option options [String] :header_tag ("h2")
|
|
142
|
+
# Used for the header of the error div
|
|
143
|
+
# @option options [String] :id ("errorExplanation")
|
|
144
|
+
# The id of the error div.
|
|
145
|
+
# @option options [String] :class ("errorExplanation")
|
|
146
|
+
# The class of the error div.
|
|
147
|
+
# @option options [Array<Object>] :object
|
|
148
|
+
# The object (or array of objects) for which to display errors,
|
|
149
|
+
# if you need to escape the instance variable convention.
|
|
150
|
+
# @option options [String] :object_name
|
|
151
|
+
# The object name to use in the header, or any text that you prefer.
|
|
152
|
+
# If +:object_name+ is not set, the name of the first object will be used.
|
|
153
|
+
# @option options [String] :header_message ("X errors prohibited this object from being saved")
|
|
154
|
+
# The message in the header of the error div. Pass +nil+ or an empty string
|
|
155
|
+
# to avoid the header message altogether.
|
|
156
|
+
# @option options [String] :message ("There were problems with the following fields:")
|
|
157
|
+
# The explanation message after the header message and before
|
|
158
|
+
# the error list. Pass +nil+ or an empty string to avoid the explanation message
|
|
159
|
+
# altogether.
|
|
160
|
+
#
|
|
161
|
+
# @return [String] The html section with all errors for the specified +objects+
|
|
162
|
+
#
|
|
163
|
+
# @example
|
|
164
|
+
# error_messages_for :user
|
|
165
|
+
#
|
|
166
|
+
# @api public
|
|
167
|
+
def error_messages_for(*objects)
|
|
168
|
+
options = objects.extract_options!.symbolize_keys
|
|
169
|
+
objects = objects.map { |object_name|
|
|
170
|
+
object_name.is_a?(Symbol) ? instance_variable_get("@#{object_name}") : object_name
|
|
171
|
+
}.compact
|
|
172
|
+
count = objects.inject(0) { |sum, object| sum + object.errors.size }
|
|
173
|
+
|
|
174
|
+
unless count.zero?
|
|
175
|
+
html = {}
|
|
176
|
+
[:id, :class, :style].each do |key|
|
|
177
|
+
if options.include?(key)
|
|
178
|
+
value = options[key]
|
|
179
|
+
html[key] = value unless value.blank?
|
|
180
|
+
else
|
|
181
|
+
html[key] = 'field-errors' unless key == :style
|
|
182
|
+
end
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
options[:object_name] ||= objects.first.class
|
|
186
|
+
|
|
187
|
+
I18n.with_options :locale => options[:locale], :scope => [:models, :errors, :template] do |locale|
|
|
188
|
+
header_message = if options.include?(:header_message)
|
|
189
|
+
options[:header_message]
|
|
190
|
+
else
|
|
191
|
+
object_name = options[:object_name].to_s.underscore.gsub(/\//, ' ')
|
|
192
|
+
object_name = I18n.t(:name, :default => object_name.humanize, :scope => [:models, object_name], :count => 1)
|
|
193
|
+
locale.t :header, :count => count, :model => object_name
|
|
194
|
+
end
|
|
195
|
+
message = options.include?(:message) ? options[:message] : locale.t(:body)
|
|
196
|
+
error_messages = objects.map { |object|
|
|
197
|
+
object_name = options[:object_name].to_s.underscore.gsub(/\//, ' ')
|
|
198
|
+
object.errors.map { |f, msg|
|
|
199
|
+
field = I18n.t(f, :default => f.to_s.humanize, :scope => [:models, object_name, :attributes])
|
|
200
|
+
content_tag(:li, "%s %s" % [field, msg])
|
|
201
|
+
}
|
|
202
|
+
}.join
|
|
203
|
+
|
|
204
|
+
contents = ''
|
|
205
|
+
contents << content_tag(options[:header_tag] || :h2, header_message) unless header_message.blank?
|
|
206
|
+
contents << content_tag(:p, message) unless message.blank?
|
|
207
|
+
contents << content_tag(:ul, error_messages)
|
|
208
|
+
|
|
209
|
+
content_tag(:div, contents, html)
|
|
210
|
+
end
|
|
211
|
+
else
|
|
212
|
+
''
|
|
213
|
+
end
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
##
|
|
217
|
+
# Returns a string containing the error message attached to the +method+ on the +object+ if one exists.
|
|
218
|
+
#
|
|
219
|
+
# @param [Object] object
|
|
220
|
+
# The object to display the error for.
|
|
221
|
+
# @param [Symbol] field
|
|
222
|
+
# The field on the +object+ to display the error for.
|
|
223
|
+
# @param [Hash] options
|
|
224
|
+
# The options to control the error display.
|
|
225
|
+
# @option options [String] :tag ("div")
|
|
226
|
+
# The tag that encloses the error.
|
|
227
|
+
# @option options [String] :prepend ("")
|
|
228
|
+
# The text to prepend before the field error.
|
|
229
|
+
# @option options [String] :append ("")
|
|
230
|
+
# The text to append after the field error.
|
|
231
|
+
#
|
|
232
|
+
# @example
|
|
233
|
+
# # => <span class="error">can't be blank</div>
|
|
234
|
+
# error_message_on :post, :title
|
|
235
|
+
# error_message_on @post, :title
|
|
236
|
+
#
|
|
237
|
+
# # => <div class="custom" style="border:1px solid red">can't be blank</div>
|
|
238
|
+
# error_message_on :post, :title, :tag => :id, :class => :custom, :style => "border:1px solid red"
|
|
239
|
+
#
|
|
240
|
+
# # => <div class="error">This title can't be blank (or it won't work)</div>
|
|
241
|
+
# error_message_on :post, :title, :prepend => "This title", :append => "(or it won't work)"
|
|
242
|
+
#
|
|
243
|
+
# @return [String] The html display of an error for a particular +object+ and +field+.
|
|
244
|
+
#
|
|
245
|
+
# @api public
|
|
246
|
+
def error_message_on(object, field, options={})
|
|
247
|
+
object = object.is_a?(Symbol) ? instance_variable_get("@#{object}") : object
|
|
248
|
+
error = object.errors[field] rescue nil
|
|
249
|
+
if error
|
|
250
|
+
options.reverse_merge!(:tag => :span, :class => :error)
|
|
251
|
+
tag = options.delete(:tag)
|
|
252
|
+
# Array(error).first is necessary because some orm give us an array others directly a value
|
|
253
|
+
error = [options.delete(:prepend), Array(error).first, options.delete(:append)].compact.join(" ")
|
|
254
|
+
content_tag(tag, error, options)
|
|
255
|
+
else
|
|
256
|
+
''
|
|
257
|
+
end
|
|
258
|
+
end
|
|
259
|
+
|
|
260
|
+
##
|
|
261
|
+
# Constructs a label tag from the given options
|
|
262
|
+
#
|
|
263
|
+
# @param [String] name
|
|
264
|
+
# The name of the field to label.
|
|
265
|
+
# @param [Hash] options
|
|
266
|
+
# The html options for this label.
|
|
267
|
+
# @option options :caption
|
|
268
|
+
# The caption for this label.
|
|
269
|
+
# @param [Proc] block
|
|
270
|
+
# The content to be inserted into the label.
|
|
271
|
+
#
|
|
272
|
+
# @return [String] The html for this label with the given +options+.
|
|
273
|
+
#
|
|
274
|
+
# @example
|
|
275
|
+
# label_tag :username, :class => 'long-label'
|
|
276
|
+
# label_tag :username, :class => 'long-label' do ... end
|
|
277
|
+
#
|
|
278
|
+
# @api public
|
|
279
|
+
def label_tag(name, options={}, &block)
|
|
280
|
+
options.reverse_merge!(:caption => "#{name.to_s.humanize}: ", :for => name)
|
|
281
|
+
caption_text = options.delete(:caption)
|
|
282
|
+
caption_text << "<span class='required'>*</span> " if options.delete(:required)
|
|
283
|
+
if block_given? # label with inner content
|
|
284
|
+
label_content = caption_text + capture_html(&block)
|
|
285
|
+
concat_content(content_tag(:label, label_content, options))
|
|
286
|
+
else # regular label
|
|
287
|
+
content_tag(:label, caption_text, options)
|
|
288
|
+
end
|
|
289
|
+
end
|
|
290
|
+
|
|
291
|
+
##
|
|
292
|
+
# Constructs a text field input from the given options
|
|
293
|
+
#
|
|
294
|
+
# @macro [new] input_field_doc
|
|
295
|
+
# @param [String] name
|
|
296
|
+
# The name of the input field.
|
|
297
|
+
# @param [Hash] options
|
|
298
|
+
# The html options for the input field.
|
|
299
|
+
#
|
|
300
|
+
# @return [String] The html input field based on the +options+ specified
|
|
301
|
+
#
|
|
302
|
+
# @example
|
|
303
|
+
# text_field_tag :username, :class => 'long'
|
|
304
|
+
#
|
|
305
|
+
# @api public
|
|
306
|
+
def text_field_tag(name, options={})
|
|
307
|
+
options.reverse_merge!(:name => name)
|
|
308
|
+
input_tag(:text, options)
|
|
309
|
+
end
|
|
310
|
+
|
|
311
|
+
##
|
|
312
|
+
# Constructs a hidden field input from the given options
|
|
313
|
+
#
|
|
314
|
+
# @macro input_field_doc
|
|
315
|
+
#
|
|
316
|
+
# @example
|
|
317
|
+
# hidden_field_tag :session_key, :value => "__secret__"
|
|
318
|
+
#
|
|
319
|
+
# @api public
|
|
320
|
+
def hidden_field_tag(name, options={})
|
|
321
|
+
options.reverse_merge!(:name => name)
|
|
322
|
+
input_tag(:hidden, options)
|
|
323
|
+
end
|
|
324
|
+
|
|
325
|
+
##
|
|
326
|
+
# Constructs a text area input from the given options
|
|
327
|
+
#
|
|
328
|
+
# @macro input_field_doc
|
|
329
|
+
#
|
|
330
|
+
# @example
|
|
331
|
+
# text_area_tag :username, :class => 'long', :value => "Demo?"
|
|
332
|
+
#
|
|
333
|
+
# @api public
|
|
334
|
+
def text_area_tag(name, options={})
|
|
335
|
+
options.reverse_merge!(:name => name, :rows => "", :cols => "")
|
|
336
|
+
content_tag(:textarea, options.delete(:value).to_s, options)
|
|
337
|
+
end
|
|
338
|
+
|
|
339
|
+
##
|
|
340
|
+
# Constructs a password field input from the given options
|
|
341
|
+
#
|
|
342
|
+
# @macro input_field_doc
|
|
343
|
+
#
|
|
344
|
+
# @example
|
|
345
|
+
# password_field_tag :password, :class => 'long'
|
|
346
|
+
#
|
|
347
|
+
# @api public
|
|
348
|
+
def password_field_tag(name, options={})
|
|
349
|
+
options.reverse_merge!(:name => name)
|
|
350
|
+
input_tag(:password, options)
|
|
351
|
+
end
|
|
352
|
+
|
|
353
|
+
##
|
|
354
|
+
# Constructs a check_box from the given options
|
|
355
|
+
#
|
|
356
|
+
# @macro input_field_doc
|
|
357
|
+
#
|
|
358
|
+
# @example
|
|
359
|
+
# check_box_tag :remember_me, :value => 'Yes'
|
|
360
|
+
#
|
|
361
|
+
# @api public
|
|
362
|
+
def check_box_tag(name, options={})
|
|
363
|
+
options.reverse_merge!(:name => name, :value => '1')
|
|
364
|
+
input_tag(:checkbox, options)
|
|
365
|
+
end
|
|
366
|
+
|
|
367
|
+
##
|
|
368
|
+
# Constructs a radio_button from the given options
|
|
369
|
+
#
|
|
370
|
+
# @macro input_field_doc
|
|
371
|
+
#
|
|
372
|
+
# @example
|
|
373
|
+
# radio_button_tag :remember_me, :value => 'true'
|
|
374
|
+
#
|
|
375
|
+
# @api public
|
|
376
|
+
def radio_button_tag(name, options={})
|
|
377
|
+
options.reverse_merge!(:name => name)
|
|
378
|
+
input_tag(:radio, options)
|
|
379
|
+
end
|
|
380
|
+
|
|
381
|
+
##
|
|
382
|
+
# Constructs a file field input from the given options
|
|
383
|
+
#
|
|
384
|
+
# @macro input_field_doc
|
|
385
|
+
#
|
|
386
|
+
# @example
|
|
387
|
+
# file_field_tag :photo, :class => 'long'
|
|
388
|
+
#
|
|
389
|
+
# @api public
|
|
390
|
+
def file_field_tag(name, options={})
|
|
391
|
+
options.reverse_merge!(:name => name)
|
|
392
|
+
input_tag(:file, options)
|
|
393
|
+
end
|
|
394
|
+
|
|
395
|
+
##
|
|
396
|
+
# Constructs a select from the given options
|
|
397
|
+
#
|
|
398
|
+
# @example
|
|
399
|
+
# options = [['caption', 'value'], ['Green', 'green1'], ['Blue', 'blue1'], ['Black', "black1"]]
|
|
400
|
+
# options = ['option', 'red', 'yellow' ]
|
|
401
|
+
# select_tag(:favorite_color, :options => ['red', 'yellow'], :selected => 'green1')
|
|
402
|
+
# select_tag(:country, :collection => @countries, :fields => [:name, :code], :include_blank => 'None')
|
|
403
|
+
#
|
|
404
|
+
# # Optgroups can be generated using :grouped_options => (Hash or nested Array)
|
|
405
|
+
# grouped_options = [['Friends',['Yoda',['Obiwan',1]]],['Enemies',['Palpatine',['Darth Vader',3]]]]
|
|
406
|
+
# grouped_options = {'Friends' => ['Yoda',['Obiwan',1]],'Enemies' => ['Palpatine',['Darth Vader',3]]}
|
|
407
|
+
# select_tag(:color, :grouped_options => [['warm',['red','yellow']],['cool',['blue', 'purple']]])
|
|
408
|
+
#
|
|
409
|
+
# # Optgroups can be generated using :grouped_options => (Hash or nested Array)
|
|
410
|
+
# grouped_options = [['Friends',['Yoda',['Obiwan',1]]],['Enemies',['Palpatine',['Darth Vader',3]]]]
|
|
411
|
+
# grouped_options = {'Friends' => ['Yoda',['Obiwan',1]],'Enemies' => ['Palpatine',['Darth Vader',3]]}
|
|
412
|
+
# select_tag(:color, :grouped_options => [['warm',['red','yellow']],['cool',['blue', 'purple']]])
|
|
413
|
+
#
|
|
414
|
+
# @param [String] name
|
|
415
|
+
# The name of the input field.
|
|
416
|
+
# @param [Hash] options
|
|
417
|
+
# The html options for the input field.
|
|
418
|
+
# @option options [Array<String, Array>] :options
|
|
419
|
+
# Explicit options to display in the select. Can be strings or string tuples.
|
|
420
|
+
# @option options [Array<Array>] :grouped_options
|
|
421
|
+
# List of options for each group in the select. See examples for details.
|
|
422
|
+
# @option options [Array<Object>] :collection
|
|
423
|
+
# Collection of objects used as options in the select.
|
|
424
|
+
# @option options [Array<Symbol>] :fields
|
|
425
|
+
# The attributes used as "label" and "value" for each +collection+ object.
|
|
426
|
+
# @option options [String] :selected (nil)
|
|
427
|
+
# The option value initially selected.
|
|
428
|
+
# @option options [Boolean] :include_blank (false)
|
|
429
|
+
# Include a blank option in the select.
|
|
430
|
+
# @option options [Boolean] :multiple (false)
|
|
431
|
+
# Allow multiple options to be selected at once.
|
|
432
|
+
#
|
|
433
|
+
# @return [String] The html input field based on the +options+ specified
|
|
434
|
+
#
|
|
435
|
+
# @api public
|
|
436
|
+
def select_tag(name, options={})
|
|
437
|
+
options.reverse_merge!(:name => name)
|
|
438
|
+
collection, fields = options.delete(:collection), options.delete(:fields)
|
|
439
|
+
options[:options] = options_from_collection(collection, fields) if collection
|
|
440
|
+
prompt = options.delete(:include_blank)
|
|
441
|
+
select_options_html = if options[:options]
|
|
442
|
+
options_for_select(options.delete(:options), options.delete(:selected))
|
|
443
|
+
elsif options[:grouped_options]
|
|
444
|
+
grouped_options_for_select(options.delete(:grouped_options), options.delete(:selected), prompt)
|
|
445
|
+
end
|
|
446
|
+
select_options_html = select_options_html.unshift(blank_option(prompt)) if select_options_html.is_a?(Array)
|
|
447
|
+
options.merge!(:name => "#{options[:name]}[]") if options[:multiple]
|
|
448
|
+
content_tag(:select, select_options_html, options)
|
|
449
|
+
end
|
|
450
|
+
|
|
451
|
+
##
|
|
452
|
+
# Constructs a button input from the given options
|
|
453
|
+
#
|
|
454
|
+
# @param [String] caption
|
|
455
|
+
# The caption for the button.
|
|
456
|
+
# @param [Hash] options
|
|
457
|
+
# The html options for the input field.
|
|
458
|
+
#
|
|
459
|
+
# @return [String] The html button based on the +options+ specified.
|
|
460
|
+
#
|
|
461
|
+
# @example
|
|
462
|
+
# button_tag "Cancel", :class => 'clear'
|
|
463
|
+
#
|
|
464
|
+
# @api public
|
|
465
|
+
def button_tag(caption, options = {})
|
|
466
|
+
options.reverse_merge!(:value => caption)
|
|
467
|
+
input_tag(:button, options)
|
|
468
|
+
end
|
|
469
|
+
|
|
470
|
+
##
|
|
471
|
+
# Constructs a submit button from the given options
|
|
472
|
+
#
|
|
473
|
+
# @param [String] caption
|
|
474
|
+
# The caption for the submit button.
|
|
475
|
+
# @param [Hash] options
|
|
476
|
+
# The html options for the input field.
|
|
477
|
+
#
|
|
478
|
+
# @return [String] The html submit button based on the +options+ specified.
|
|
479
|
+
#
|
|
480
|
+
# @example
|
|
481
|
+
# submit_tag "Create", :class => 'success'
|
|
482
|
+
#
|
|
483
|
+
# @api public
|
|
484
|
+
def submit_tag(caption="Submit", options={})
|
|
485
|
+
options.reverse_merge!(:value => caption)
|
|
486
|
+
input_tag(:submit, options)
|
|
487
|
+
end
|
|
488
|
+
|
|
489
|
+
# Constructs a submit button from the given options
|
|
490
|
+
#
|
|
491
|
+
# @param [String] source
|
|
492
|
+
# The source image path for the button.
|
|
493
|
+
# @param [Hash] options
|
|
494
|
+
# The html options for the input field.
|
|
495
|
+
#
|
|
496
|
+
# @return [String] The html image button based on the +options+ specified.
|
|
497
|
+
#
|
|
498
|
+
# @example
|
|
499
|
+
# submit_tag "Create", :class => 'success'
|
|
500
|
+
#
|
|
501
|
+
# @api public
|
|
502
|
+
def image_submit_tag(source, options={})
|
|
503
|
+
options.reverse_merge!(:src => image_path(source))
|
|
504
|
+
input_tag(:image, options)
|
|
505
|
+
end
|
|
506
|
+
|
|
507
|
+
protected
|
|
508
|
+
|
|
509
|
+
##
|
|
510
|
+
# Returns an array of option items for a select field based on the given collection
|
|
511
|
+
# fields is an array containing the fields to display from each item in the collection
|
|
512
|
+
#
|
|
513
|
+
def options_from_collection(collection, fields)
|
|
514
|
+
collection.map { |item| [ item.send(fields.first), item.send(fields.last) ] }
|
|
515
|
+
end
|
|
516
|
+
|
|
517
|
+
#
|
|
518
|
+
# Returns the options tags for a select based on the given option items
|
|
519
|
+
#
|
|
520
|
+
def options_for_select(option_items, selected_value=nil)
|
|
521
|
+
return '' if option_items.blank?
|
|
522
|
+
option_items.map do |caption, value|
|
|
523
|
+
value ||= caption
|
|
524
|
+
content_tag(:option, caption, :value => value, :selected => option_is_selected?(value, caption, selected_value))
|
|
525
|
+
end
|
|
526
|
+
end
|
|
527
|
+
|
|
528
|
+
#
|
|
529
|
+
# Returns the optgroups with options tags for a select based on the given :grouped_options items
|
|
530
|
+
#
|
|
531
|
+
def grouped_options_for_select(collection, selected=nil, prompt=false)
|
|
532
|
+
if collection.is_a?(Hash)
|
|
533
|
+
collection.map do |key, value|
|
|
534
|
+
content_tag :optgroup, :label => key do
|
|
535
|
+
options_for_select(value, selected)
|
|
536
|
+
end
|
|
537
|
+
end
|
|
538
|
+
elsif collection.is_a?(Array)
|
|
539
|
+
collection.map do |optgroup|
|
|
540
|
+
content_tag :optgroup, :label => optgroup.first do
|
|
541
|
+
options_for_select(optgroup.last, selected)
|
|
542
|
+
end
|
|
543
|
+
end
|
|
544
|
+
end
|
|
545
|
+
end
|
|
546
|
+
|
|
547
|
+
#
|
|
548
|
+
# Returns the blank option serving as a prompt if passed
|
|
549
|
+
#
|
|
550
|
+
def blank_option(prompt)
|
|
551
|
+
return unless prompt
|
|
552
|
+
case prompt
|
|
553
|
+
when String then content_tag(:option, prompt, :value => '')
|
|
554
|
+
when Array then content_tag(:option, prompt.first, :value => prompt.last)
|
|
555
|
+
else content_tag(:option, '', :value => '')
|
|
556
|
+
end
|
|
557
|
+
end
|
|
558
|
+
|
|
559
|
+
private
|
|
560
|
+
##
|
|
561
|
+
# Returns the FormBuilder class to use based on all available setting sources
|
|
562
|
+
# If explicitly defined, returns that, otherwise returns defaults.
|
|
563
|
+
#
|
|
564
|
+
# @example
|
|
565
|
+
# configured_form_builder_class(nil) => StandardFormBuilder
|
|
566
|
+
#
|
|
567
|
+
# @api private
|
|
568
|
+
def configured_form_builder_class(explicit_builder=nil)
|
|
569
|
+
default_builder = self.respond_to?(:settings) && self.settings.default_builder
|
|
570
|
+
configured_builder = explicit_builder || default_builder || 'StandardFormBuilder'
|
|
571
|
+
configured_builder = "Padrino::Helpers::FormBuilder::#{configured_builder}".constantize if configured_builder.is_a?(String)
|
|
572
|
+
configured_builder
|
|
573
|
+
end
|
|
574
|
+
|
|
575
|
+
##
|
|
576
|
+
# Returns an initialized builder instance for the given object and settings
|
|
577
|
+
#
|
|
578
|
+
# @example
|
|
579
|
+
# builder_instance(@account, :nested => { ... }) => <FormBuilder>
|
|
580
|
+
#
|
|
581
|
+
# @api private
|
|
582
|
+
def builder_instance(object, settings={})
|
|
583
|
+
builder_class = configured_form_builder_class(settings.delete(:builder))
|
|
584
|
+
builder_class.new(self, object, settings)
|
|
585
|
+
end
|
|
586
|
+
|
|
587
|
+
##
|
|
588
|
+
# Returns whether the option should be selected or not
|
|
589
|
+
#
|
|
590
|
+
# @example
|
|
591
|
+
# option_is_selected?("red", "Red", ["red", "blue"]) => true
|
|
592
|
+
# option_is_selected?("red", "Red", ["green", "blue"]) => false
|
|
593
|
+
#
|
|
594
|
+
# @api private
|
|
595
|
+
def option_is_selected?(value, caption, selected_values)
|
|
596
|
+
Array(selected_values).any? do |selected|
|
|
597
|
+
[value.to_s, caption.to_s].include?(selected.to_s)
|
|
598
|
+
end
|
|
599
|
+
end
|
|
600
|
+
end # FormHelpers
|
|
601
|
+
end # Helpers
|
|
602
|
+
end # Padrino
|