haml_ejs 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.yardopts +11 -0
- data/CONTRIBUTING +3 -0
- data/MIT-LICENSE +20 -0
- data/README.md +68 -0
- data/Rakefile +419 -0
- data/VERSION +1 -0
- data/VERSION_NAME +1 -0
- data/bin/haml +9 -0
- data/bin/html2haml +7 -0
- data/extra/update_watch.rb +13 -0
- data/init.rb +18 -0
- data/lib/haml.rb +49 -0
- data/lib/haml/buffer.rb +297 -0
- data/lib/haml/compiler.rb +486 -0
- data/lib/haml/engine.rb +312 -0
- data/lib/haml/error.rb +22 -0
- data/lib/haml/exec.rb +362 -0
- data/lib/haml/filters.rb +388 -0
- data/lib/haml/haml_ejs.rb +57 -0
- data/lib/haml/helpers.rb +608 -0
- data/lib/haml/helpers/action_view_extensions.rb +57 -0
- data/lib/haml/helpers/action_view_mods.rb +257 -0
- data/lib/haml/helpers/xss_mods.rb +165 -0
- data/lib/haml/html.rb +412 -0
- data/lib/haml/html/erb.rb +141 -0
- data/lib/haml/parser.rb +760 -0
- data/lib/haml/railtie.rb +19 -0
- data/lib/haml/root.rb +7 -0
- data/lib/haml/shared.rb +78 -0
- data/lib/haml/template.rb +99 -0
- data/lib/haml/template/options.rb +16 -0
- data/lib/haml/template/patch.rb +58 -0
- data/lib/haml/template/plugin.rb +123 -0
- data/lib/haml/util.rb +842 -0
- data/lib/haml/version.rb +109 -0
- data/lib/sass.rb +8 -0
- data/lib/sass/plugin.rb +10 -0
- data/lib/sass/rails2_shim.rb +9 -0
- data/lib/sass/rails3_shim.rb +16 -0
- data/rails/init.rb +1 -0
- data/test/benchmark.rb +91 -0
- data/test/gemfiles/Gemfile.rails-2.0.x +8 -0
- data/test/gemfiles/Gemfile.rails-2.0.x.lock +38 -0
- data/test/gemfiles/Gemfile.rails-2.1.x +8 -0
- data/test/gemfiles/Gemfile.rails-2.1.x.lock +38 -0
- data/test/gemfiles/Gemfile.rails-2.2.x +8 -0
- data/test/gemfiles/Gemfile.rails-2.2.x.lock +38 -0
- data/test/gemfiles/Gemfile.rails-2.3.x +8 -0
- data/test/gemfiles/Gemfile.rails-2.3.x.lock +40 -0
- data/test/gemfiles/Gemfile.rails-3.0.x +8 -0
- data/test/gemfiles/Gemfile.rails-3.0.x.lock +85 -0
- data/test/gemfiles/Gemfile.rails-3.1.x +8 -0
- data/test/gemfiles/Gemfile.rails-3.1.x.lock +98 -0
- data/test/gemfiles/Gemfile.rails-xss-2.3.x +9 -0
- data/test/gemfiles/Gemfile.rails-xss-2.3.x.lock +42 -0
- data/test/haml-ejs/haml-ejs_test.rb +22 -0
- data/test/haml-ejs/templates/conditional.input +3 -0
- data/test/haml-ejs/templates/conditional.output +3 -0
- data/test/haml-ejs/templates/conditional_and_interpolation.input +2 -0
- data/test/haml-ejs/templates/conditional_and_interpolation.output +3 -0
- data/test/haml-ejs/templates/conditional_else.input +5 -0
- data/test/haml-ejs/templates/conditional_else.output +5 -0
- data/test/haml-ejs/templates/conditional_else_elsif.input +7 -0
- data/test/haml-ejs/templates/conditional_else_elsif.output +7 -0
- data/test/haml-ejs/templates/conditional_elsif.input +5 -0
- data/test/haml-ejs/templates/conditional_elsif.output +5 -0
- data/test/haml-ejs/templates/conditional_unless.input +3 -0
- data/test/haml-ejs/templates/conditional_unless.output +3 -0
- data/test/haml-ejs/templates/conditional_unless_else.input +5 -0
- data/test/haml-ejs/templates/conditional_unless_else.output +5 -0
- data/test/haml-ejs/templates/conditional_unless_elsif_else.input +5 -0
- data/test/haml-ejs/templates/conditional_unless_elsif_else.output +5 -0
- data/test/haml-ejs/templates/interpolation.input +2 -0
- data/test/haml-ejs/templates/interpolation.output +1 -0
- data/test/haml-ejs/templates/iteration.input +2 -0
- data/test/haml-ejs/templates/iteration.output +3 -0
- data/test/haml-ejs/templates/suite.input +26 -0
- data/test/haml-ejs/templates/suite.output +27 -0
- data/test/haml/engine_test.rb +1925 -0
- data/test/haml/erb/_av_partial_1.erb +12 -0
- data/test/haml/erb/_av_partial_2.erb +8 -0
- data/test/haml/erb/action_view.erb +62 -0
- data/test/haml/erb/standard.erb +55 -0
- data/test/haml/helper_test.rb +454 -0
- data/test/haml/html2haml/erb_tests.rb +440 -0
- data/test/haml/html2haml_test.rb +336 -0
- data/test/haml/markaby/standard.mab +52 -0
- data/test/haml/mocks/article.rb +6 -0
- data/test/haml/results/content_for_layout.xhtml +12 -0
- data/test/haml/results/eval_suppressed.xhtml +9 -0
- data/test/haml/results/filters.xhtml +62 -0
- data/test/haml/results/helpers.xhtml +70 -0
- data/test/haml/results/helpful.xhtml +10 -0
- data/test/haml/results/just_stuff.xhtml +70 -0
- data/test/haml/results/list.xhtml +12 -0
- data/test/haml/results/nuke_inner_whitespace.xhtml +40 -0
- data/test/haml/results/nuke_outer_whitespace.xhtml +148 -0
- data/test/haml/results/original_engine.xhtml +20 -0
- data/test/haml/results/partial_layout.xhtml +5 -0
- data/test/haml/results/partials.xhtml +21 -0
- data/test/haml/results/render_layout.xhtml +3 -0
- data/test/haml/results/silent_script.xhtml +74 -0
- data/test/haml/results/standard.xhtml +162 -0
- data/test/haml/results/tag_parsing.xhtml +23 -0
- data/test/haml/results/very_basic.xhtml +5 -0
- data/test/haml/results/whitespace_handling.xhtml +89 -0
- data/test/haml/spec/README.md +97 -0
- data/test/haml/spec/lua_haml_spec.lua +30 -0
- data/test/haml/spec/ruby_haml_test.rb +19 -0
- data/test/haml/spec/tests.json +534 -0
- data/test/haml/spec_test.rb +44 -0
- data/test/haml/template_test.rb +419 -0
- data/test/haml/templates/_av_partial_1.haml +9 -0
- data/test/haml/templates/_av_partial_1_ugly.haml +9 -0
- data/test/haml/templates/_av_partial_2.haml +5 -0
- data/test/haml/templates/_av_partial_2_ugly.haml +5 -0
- data/test/haml/templates/_layout.erb +3 -0
- data/test/haml/templates/_layout_for_partial.haml +3 -0
- data/test/haml/templates/_partial.haml +8 -0
- data/test/haml/templates/_text_area.haml +3 -0
- data/test/haml/templates/action_view.haml +47 -0
- data/test/haml/templates/action_view_ugly.haml +47 -0
- data/test/haml/templates/breakage.haml +8 -0
- data/test/haml/templates/content_for_layout.haml +8 -0
- data/test/haml/templates/eval_suppressed.haml +11 -0
- data/test/haml/templates/filters.haml +66 -0
- data/test/haml/templates/helpers.haml +55 -0
- data/test/haml/templates/helpful.haml +11 -0
- data/test/haml/templates/just_stuff.haml +85 -0
- data/test/haml/templates/list.haml +12 -0
- data/test/haml/templates/nuke_inner_whitespace.haml +32 -0
- data/test/haml/templates/nuke_outer_whitespace.haml +144 -0
- data/test/haml/templates/original_engine.haml +17 -0
- data/test/haml/templates/partial_layout.haml +10 -0
- data/test/haml/templates/partialize.haml +1 -0
- data/test/haml/templates/partials.haml +12 -0
- data/test/haml/templates/render_layout.haml +2 -0
- data/test/haml/templates/silent_script.haml +40 -0
- data/test/haml/templates/standard.haml +43 -0
- data/test/haml/templates/standard_ugly.haml +43 -0
- data/test/haml/templates/tag_parsing.haml +21 -0
- data/test/haml/templates/very_basic.haml +4 -0
- data/test/haml/templates/whitespace_handling.haml +87 -0
- data/test/haml/util_test.rb +300 -0
- data/test/linked_rails.rb +42 -0
- data/test/test_helper.rb +75 -0
- data/vendor/sass/CONTRIBUTING +3 -0
- data/vendor/sass/MIT-LICENSE +20 -0
- data/vendor/sass/README.md +201 -0
- data/vendor/sass/Rakefile +339 -0
- data/vendor/sass/TODO +39 -0
- data/vendor/sass/VERSION +1 -0
- data/vendor/sass/VERSION_NAME +1 -0
- data/vendor/sass/bin/sass +8 -0
- data/vendor/sass/bin/sass-convert +7 -0
- data/vendor/sass/bin/scss +8 -0
- data/vendor/sass/doc-src/FAQ.md +35 -0
- data/vendor/sass/doc-src/INDENTED_SYNTAX.md +210 -0
- data/vendor/sass/doc-src/SASS_CHANGELOG.md +2214 -0
- data/vendor/sass/doc-src/SASS_REFERENCE.md +1957 -0
- data/vendor/sass/doc-src/SCSS_FOR_SASS_USERS.md +155 -0
- data/vendor/sass/ext/extconf.rb +10 -0
- data/vendor/sass/extra/update_watch.rb +13 -0
- data/vendor/sass/init.rb +18 -0
- data/vendor/sass/lib/sass.rb +72 -0
- data/vendor/sass/lib/sass/cache_stores.rb +15 -0
- data/vendor/sass/lib/sass/cache_stores/base.rb +84 -0
- data/vendor/sass/lib/sass/cache_stores/chain.rb +33 -0
- data/vendor/sass/lib/sass/cache_stores/filesystem.rb +58 -0
- data/vendor/sass/lib/sass/cache_stores/memory.rb +47 -0
- data/vendor/sass/lib/sass/cache_stores/null.rb +25 -0
- data/vendor/sass/lib/sass/callbacks.rb +66 -0
- data/vendor/sass/lib/sass/css.rb +294 -0
- data/vendor/sass/lib/sass/engine.rb +862 -0
- data/vendor/sass/lib/sass/environment.rb +155 -0
- data/vendor/sass/lib/sass/error.rb +201 -0
- data/vendor/sass/lib/sass/exec.rb +659 -0
- data/vendor/sass/lib/sass/importers.rb +22 -0
- data/vendor/sass/lib/sass/importers/base.rb +138 -0
- data/vendor/sass/lib/sass/importers/filesystem.rb +144 -0
- data/vendor/sass/lib/sass/less.rb +382 -0
- data/vendor/sass/lib/sass/plugin.rb +136 -0
- data/vendor/sass/lib/sass/plugin/compiler.rb +358 -0
- data/vendor/sass/lib/sass/plugin/configuration.rb +125 -0
- data/vendor/sass/lib/sass/plugin/generic.rb +15 -0
- data/vendor/sass/lib/sass/plugin/merb.rb +48 -0
- data/vendor/sass/lib/sass/plugin/rack.rb +60 -0
- data/vendor/sass/lib/sass/plugin/rails.rb +47 -0
- data/vendor/sass/lib/sass/plugin/staleness_checker.rb +173 -0
- data/vendor/sass/lib/sass/railtie.rb +9 -0
- data/vendor/sass/lib/sass/repl.rb +58 -0
- data/vendor/sass/lib/sass/root.rb +7 -0
- data/vendor/sass/lib/sass/script.rb +40 -0
- data/vendor/sass/lib/sass/script/bool.rb +18 -0
- data/vendor/sass/lib/sass/script/color.rb +480 -0
- data/vendor/sass/lib/sass/script/css_lexer.rb +29 -0
- data/vendor/sass/lib/sass/script/css_parser.rb +31 -0
- data/vendor/sass/lib/sass/script/funcall.rb +162 -0
- data/vendor/sass/lib/sass/script/functions.rb +1343 -0
- data/vendor/sass/lib/sass/script/interpolation.rb +70 -0
- data/vendor/sass/lib/sass/script/lexer.rb +334 -0
- data/vendor/sass/lib/sass/script/list.rb +76 -0
- data/vendor/sass/lib/sass/script/literal.rb +245 -0
- data/vendor/sass/lib/sass/script/node.rb +91 -0
- data/vendor/sass/lib/sass/script/number.rb +429 -0
- data/vendor/sass/lib/sass/script/operation.rb +91 -0
- data/vendor/sass/lib/sass/script/parser.rb +467 -0
- data/vendor/sass/lib/sass/script/string.rb +51 -0
- data/vendor/sass/lib/sass/script/string_interpolation.rb +94 -0
- data/vendor/sass/lib/sass/script/unary_operation.rb +57 -0
- data/vendor/sass/lib/sass/script/variable.rb +54 -0
- data/vendor/sass/lib/sass/scss.rb +17 -0
- data/vendor/sass/lib/sass/scss/css_parser.rb +46 -0
- data/vendor/sass/lib/sass/scss/parser.rb +920 -0
- data/vendor/sass/lib/sass/scss/rx.rb +127 -0
- data/vendor/sass/lib/sass/scss/sass_parser.rb +11 -0
- data/vendor/sass/lib/sass/scss/script_lexer.rb +15 -0
- data/vendor/sass/lib/sass/scss/script_parser.rb +25 -0
- data/vendor/sass/lib/sass/scss/static_parser.rb +40 -0
- data/vendor/sass/lib/sass/selector.rb +361 -0
- data/vendor/sass/lib/sass/selector/abstract_sequence.rb +62 -0
- data/vendor/sass/lib/sass/selector/comma_sequence.rb +81 -0
- data/vendor/sass/lib/sass/selector/sequence.rb +233 -0
- data/vendor/sass/lib/sass/selector/simple.rb +113 -0
- data/vendor/sass/lib/sass/selector/simple_sequence.rb +134 -0
- data/vendor/sass/lib/sass/shared.rb +78 -0
- data/vendor/sass/lib/sass/tree/charset_node.rb +22 -0
- data/vendor/sass/lib/sass/tree/comment_node.rb +77 -0
- data/vendor/sass/lib/sass/tree/debug_node.rb +18 -0
- data/vendor/sass/lib/sass/tree/directive_node.rb +23 -0
- data/vendor/sass/lib/sass/tree/each_node.rb +24 -0
- data/vendor/sass/lib/sass/tree/extend_node.rb +29 -0
- data/vendor/sass/lib/sass/tree/for_node.rb +36 -0
- data/vendor/sass/lib/sass/tree/function_node.rb +27 -0
- data/vendor/sass/lib/sass/tree/if_node.rb +65 -0
- data/vendor/sass/lib/sass/tree/import_node.rb +68 -0
- data/vendor/sass/lib/sass/tree/media_node.rb +32 -0
- data/vendor/sass/lib/sass/tree/mixin_def_node.rb +27 -0
- data/vendor/sass/lib/sass/tree/mixin_node.rb +32 -0
- data/vendor/sass/lib/sass/tree/node.rb +204 -0
- data/vendor/sass/lib/sass/tree/prop_node.rb +155 -0
- data/vendor/sass/lib/sass/tree/return_node.rb +18 -0
- data/vendor/sass/lib/sass/tree/root_node.rb +28 -0
- data/vendor/sass/lib/sass/tree/rule_node.rb +129 -0
- data/vendor/sass/lib/sass/tree/variable_node.rb +30 -0
- data/vendor/sass/lib/sass/tree/visitors/base.rb +75 -0
- data/vendor/sass/lib/sass/tree/visitors/check_nesting.rb +134 -0
- data/vendor/sass/lib/sass/tree/visitors/convert.rb +255 -0
- data/vendor/sass/lib/sass/tree/visitors/cssize.rb +175 -0
- data/vendor/sass/lib/sass/tree/visitors/perform.rb +301 -0
- data/vendor/sass/lib/sass/tree/visitors/to_css.rb +216 -0
- data/vendor/sass/lib/sass/tree/warn_node.rb +18 -0
- data/vendor/sass/lib/sass/tree/while_node.rb +18 -0
- data/vendor/sass/lib/sass/util.rb +669 -0
- data/vendor/sass/lib/sass/util/subset_map.rb +101 -0
- data/vendor/sass/lib/sass/version.rb +112 -0
- data/vendor/sass/rails/init.rb +1 -0
- data/vendor/sass/sass.gemspec +32 -0
- data/vendor/sass/test/sass/cache_test.rb +74 -0
- data/vendor/sass/test/sass/callbacks_test.rb +61 -0
- data/vendor/sass/test/sass/conversion_test.rb +1203 -0
- data/vendor/sass/test/sass/css2sass_test.rb +364 -0
- data/vendor/sass/test/sass/data/hsl-rgb.txt +319 -0
- data/vendor/sass/test/sass/engine_test.rb +2469 -0
- data/vendor/sass/test/sass/extend_test.rb +1348 -0
- data/vendor/sass/test/sass/functions_test.rb +1025 -0
- data/vendor/sass/test/sass/importer_test.rb +82 -0
- data/vendor/sass/test/sass/less_conversion_test.rb +653 -0
- data/vendor/sass/test/sass/mock_importer.rb +49 -0
- data/vendor/sass/test/sass/more_results/more1.css +9 -0
- data/vendor/sass/test/sass/more_results/more1_with_line_comments.css +26 -0
- data/vendor/sass/test/sass/more_results/more_import.css +29 -0
- data/vendor/sass/test/sass/more_templates/_more_partial.sass +2 -0
- data/vendor/sass/test/sass/more_templates/more1.sass +23 -0
- data/vendor/sass/test/sass/more_templates/more_import.sass +11 -0
- data/vendor/sass/test/sass/plugin_test.rb +469 -0
- data/vendor/sass/test/sass/results/alt.css +4 -0
- data/vendor/sass/test/sass/results/basic.css +9 -0
- data/vendor/sass/test/sass/results/compact.css +5 -0
- data/vendor/sass/test/sass/results/complex.css +86 -0
- data/vendor/sass/test/sass/results/compressed.css +1 -0
- data/vendor/sass/test/sass/results/expanded.css +19 -0
- data/vendor/sass/test/sass/results/if.css +3 -0
- data/vendor/sass/test/sass/results/import.css +31 -0
- data/vendor/sass/test/sass/results/import_charset.css +4 -0
- data/vendor/sass/test/sass/results/import_charset_1_8.css +4 -0
- data/vendor/sass/test/sass/results/import_charset_ibm866.css +4 -0
- data/vendor/sass/test/sass/results/line_numbers.css +49 -0
- data/vendor/sass/test/sass/results/mixins.css +95 -0
- data/vendor/sass/test/sass/results/multiline.css +24 -0
- data/vendor/sass/test/sass/results/nested.css +22 -0
- data/vendor/sass/test/sass/results/options.css +1 -0
- data/vendor/sass/test/sass/results/parent_ref.css +13 -0
- data/vendor/sass/test/sass/results/script.css +16 -0
- data/vendor/sass/test/sass/results/scss_import.css +31 -0
- data/vendor/sass/test/sass/results/scss_importee.css +2 -0
- data/vendor/sass/test/sass/results/subdir/nested_subdir/nested_subdir.css +1 -0
- data/vendor/sass/test/sass/results/subdir/subdir.css +3 -0
- data/vendor/sass/test/sass/results/units.css +11 -0
- data/vendor/sass/test/sass/results/warn.css +0 -0
- data/vendor/sass/test/sass/results/warn_imported.css +0 -0
- data/vendor/sass/test/sass/script_conversion_test.rb +283 -0
- data/vendor/sass/test/sass/script_test.rb +496 -0
- data/vendor/sass/test/sass/scss/css_test.rb +916 -0
- data/vendor/sass/test/sass/scss/rx_test.rb +156 -0
- data/vendor/sass/test/sass/scss/scss_test.rb +1249 -0
- data/vendor/sass/test/sass/scss/test_helper.rb +37 -0
- data/vendor/sass/test/sass/templates/_imported_charset_ibm866.sass +4 -0
- data/vendor/sass/test/sass/templates/_imported_charset_utf8.sass +4 -0
- data/vendor/sass/test/sass/templates/_partial.sass +2 -0
- data/vendor/sass/test/sass/templates/alt.sass +16 -0
- data/vendor/sass/test/sass/templates/basic.sass +23 -0
- data/vendor/sass/test/sass/templates/bork1.sass +2 -0
- data/vendor/sass/test/sass/templates/bork2.sass +2 -0
- data/vendor/sass/test/sass/templates/bork3.sass +2 -0
- data/vendor/sass/test/sass/templates/bork4.sass +2 -0
- data/vendor/sass/test/sass/templates/compact.sass +17 -0
- data/vendor/sass/test/sass/templates/complex.sass +305 -0
- data/vendor/sass/test/sass/templates/compressed.sass +15 -0
- data/vendor/sass/test/sass/templates/expanded.sass +17 -0
- data/vendor/sass/test/sass/templates/if.sass +11 -0
- data/vendor/sass/test/sass/templates/import.sass +12 -0
- data/vendor/sass/test/sass/templates/import_charset.sass +7 -0
- data/vendor/sass/test/sass/templates/import_charset_1_8.sass +4 -0
- data/vendor/sass/test/sass/templates/import_charset_ibm866.sass +9 -0
- data/vendor/sass/test/sass/templates/importee.less +2 -0
- data/vendor/sass/test/sass/templates/importee.sass +19 -0
- data/vendor/sass/test/sass/templates/line_numbers.sass +13 -0
- data/vendor/sass/test/sass/templates/mixin_bork.sass +5 -0
- data/vendor/sass/test/sass/templates/mixins.sass +76 -0
- data/vendor/sass/test/sass/templates/multiline.sass +20 -0
- data/vendor/sass/test/sass/templates/nested.sass +25 -0
- data/vendor/sass/test/sass/templates/nested_bork1.sass +2 -0
- data/vendor/sass/test/sass/templates/nested_bork2.sass +2 -0
- data/vendor/sass/test/sass/templates/nested_bork3.sass +2 -0
- data/vendor/sass/test/sass/templates/nested_bork4.sass +2 -0
- data/vendor/sass/test/sass/templates/nested_import.sass +2 -0
- data/vendor/sass/test/sass/templates/nested_mixin_bork.sass +6 -0
- data/vendor/sass/test/sass/templates/options.sass +2 -0
- data/vendor/sass/test/sass/templates/parent_ref.sass +25 -0
- data/vendor/sass/test/sass/templates/script.sass +101 -0
- data/vendor/sass/test/sass/templates/scss_import.scss +11 -0
- data/vendor/sass/test/sass/templates/scss_importee.scss +1 -0
- data/vendor/sass/test/sass/templates/subdir/nested_subdir/_nested_partial.sass +2 -0
- data/vendor/sass/test/sass/templates/subdir/nested_subdir/nested_subdir.sass +3 -0
- data/vendor/sass/test/sass/templates/subdir/subdir.sass +6 -0
- data/vendor/sass/test/sass/templates/units.sass +11 -0
- data/vendor/sass/test/sass/templates/warn.sass +3 -0
- data/vendor/sass/test/sass/templates/warn_imported.sass +4 -0
- data/vendor/sass/test/sass/test_helper.rb +8 -0
- data/vendor/sass/test/sass/util/subset_map_test.rb +91 -0
- data/vendor/sass/test/sass/util_test.rb +254 -0
- data/vendor/sass/test/test_helper.rb +69 -0
- data/vendor/sass/yard/callbacks.rb +29 -0
- data/vendor/sass/yard/default/fulldoc/html/css/common.sass +26 -0
- data/vendor/sass/yard/default/layout/html/footer.erb +12 -0
- data/vendor/sass/yard/inherited_hash.rb +41 -0
- metadata +458 -0
@@ -0,0 +1,57 @@
|
|
1
|
+
module Haml
|
2
|
+
module Helpers
|
3
|
+
@@action_view_defined = true
|
4
|
+
|
5
|
+
# This module contains various useful helper methods
|
6
|
+
# that either tie into ActionView or the rest of the ActionPack stack,
|
7
|
+
# or are only useful in that context.
|
8
|
+
# Thus, the methods defined here are only available
|
9
|
+
# if ActionView is installed.
|
10
|
+
module ActionViewExtensions
|
11
|
+
# Returns a value for the "class" attribute
|
12
|
+
# unique to this controller/action pair.
|
13
|
+
# This can be used to target styles specifically at this action or controller.
|
14
|
+
# For example, if the current action were `EntryController#show`,
|
15
|
+
#
|
16
|
+
# %div{:class => page_class} My Div
|
17
|
+
#
|
18
|
+
# would become
|
19
|
+
#
|
20
|
+
# <div class="entry show">My Div</div>
|
21
|
+
#
|
22
|
+
# Then, in a stylesheet (shown here as [Sass](http://sass-lang.com)),
|
23
|
+
# you could refer to this specific action:
|
24
|
+
#
|
25
|
+
# .entry.show
|
26
|
+
# font-weight: bold
|
27
|
+
#
|
28
|
+
# or to all actions in the entry controller:
|
29
|
+
#
|
30
|
+
# .entry
|
31
|
+
# color: #00f
|
32
|
+
#
|
33
|
+
# @return [String] The class name for the current page
|
34
|
+
def page_class
|
35
|
+
controller.controller_name + " " + controller.action_name
|
36
|
+
end
|
37
|
+
alias_method :generate_content_class_names, :page_class
|
38
|
+
|
39
|
+
# Treats all input to \{Haml::Helpers#haml\_concat} within the block
|
40
|
+
# as being HTML safe for Rails' XSS protection.
|
41
|
+
# This is useful for wrapping blocks of code that concatenate HTML en masse.
|
42
|
+
#
|
43
|
+
# This has no effect if Rails' XSS protection isn't enabled.
|
44
|
+
#
|
45
|
+
# @yield A block in which all input to `#haml_concat` is treated as raw.
|
46
|
+
# @see Haml::Util#rails_xss_safe?
|
47
|
+
def with_raw_haml_concat
|
48
|
+
@_haml_concat_raw, old = true, @_haml_concat_raw
|
49
|
+
yield
|
50
|
+
ensure
|
51
|
+
@_haml_concat_raw = old
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
include ActionViewExtensions
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,257 @@
|
|
1
|
+
module ActionView
|
2
|
+
class Base
|
3
|
+
def render_with_haml(*args, &block)
|
4
|
+
options = args.first
|
5
|
+
|
6
|
+
# If render :layout is used with a block,
|
7
|
+
# it concats rather than returning a string
|
8
|
+
# so we need it to keep thinking it's Haml
|
9
|
+
# until it hits the sub-render
|
10
|
+
if is_haml? && !(options.is_a?(Hash) && options[:layout] && block_given?)
|
11
|
+
return non_haml { render_without_haml(*args, &block) }
|
12
|
+
end
|
13
|
+
render_without_haml(*args, &block)
|
14
|
+
end
|
15
|
+
alias_method :render_without_haml, :render
|
16
|
+
alias_method :render, :render_with_haml
|
17
|
+
|
18
|
+
# Rails >2.1
|
19
|
+
if Haml::Util.has?(:instance_method, self, :output_buffer)
|
20
|
+
def output_buffer_with_haml
|
21
|
+
return haml_buffer.buffer if is_haml?
|
22
|
+
output_buffer_without_haml
|
23
|
+
end
|
24
|
+
alias_method :output_buffer_without_haml, :output_buffer
|
25
|
+
alias_method :output_buffer, :output_buffer_with_haml
|
26
|
+
|
27
|
+
def set_output_buffer_with_haml(new)
|
28
|
+
if is_haml?
|
29
|
+
new = String.new(new) if Haml::Util.rails_xss_safe? &&
|
30
|
+
new.is_a?(Haml::Util.rails_safe_buffer_class)
|
31
|
+
haml_buffer.buffer = new
|
32
|
+
else
|
33
|
+
set_output_buffer_without_haml new
|
34
|
+
end
|
35
|
+
end
|
36
|
+
alias_method :set_output_buffer_without_haml, :output_buffer=
|
37
|
+
alias_method :output_buffer=, :set_output_buffer_with_haml
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
module Helpers
|
42
|
+
# In Rails <=2.1, we've got to override considerable capturing infrastructure.
|
43
|
+
# In Rails >2.1, we can make do with only overriding #capture
|
44
|
+
# (which no longer behaves differently in helper contexts).
|
45
|
+
unless Haml::Util.has?(:instance_method, ActionView::Base, :output_buffer)
|
46
|
+
module CaptureHelper
|
47
|
+
def capture_with_haml(*args, &block)
|
48
|
+
# Rails' #capture helper will just return the value of the block
|
49
|
+
# if it's not actually in the template context,
|
50
|
+
# as detected by the existance of an _erbout variable.
|
51
|
+
# We've got to do the same thing for compatibility.
|
52
|
+
|
53
|
+
if is_haml? && block_is_haml?(block)
|
54
|
+
value = nil
|
55
|
+
buffer = capture_haml(*args) { value = yield(*args) }
|
56
|
+
return buffer unless buffer.empty?
|
57
|
+
return value if value.is_a?(String)
|
58
|
+
else
|
59
|
+
capture_without_haml(*args, &block)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
alias_method :capture_without_haml, :capture
|
63
|
+
alias_method :capture, :capture_with_haml
|
64
|
+
|
65
|
+
def capture_erb_with_buffer_with_haml(buffer, *args, &block)
|
66
|
+
if is_haml?
|
67
|
+
capture_haml(*args, &block)
|
68
|
+
else
|
69
|
+
capture_erb_with_buffer_without_haml(buffer, *args, &block)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
alias_method :capture_erb_with_buffer_without_haml, :capture_erb_with_buffer
|
73
|
+
alias_method :capture_erb_with_buffer, :capture_erb_with_buffer_with_haml
|
74
|
+
end
|
75
|
+
|
76
|
+
module TextHelper
|
77
|
+
def concat_with_haml(string, binding = nil)
|
78
|
+
if is_haml?
|
79
|
+
haml_buffer.buffer.concat(string)
|
80
|
+
else
|
81
|
+
concat_without_haml(string, binding)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
alias_method :concat_without_haml, :concat
|
85
|
+
alias_method :concat, :concat_with_haml
|
86
|
+
end
|
87
|
+
else
|
88
|
+
module CaptureHelper
|
89
|
+
def capture_with_haml(*args, &block)
|
90
|
+
if Haml::Helpers.block_is_haml?(block)
|
91
|
+
_hamlout = eval('_hamlout', block.binding) # Necessary since capture_haml checks _hamlout
|
92
|
+
value = nil
|
93
|
+
buffer = capture_haml(*args) { value = yield(*args) }
|
94
|
+
str =
|
95
|
+
if !buffer.empty?
|
96
|
+
buffer
|
97
|
+
elsif value.is_a?(String)
|
98
|
+
value
|
99
|
+
else
|
100
|
+
''
|
101
|
+
end
|
102
|
+
return ActionView::NonConcattingString.new(str) if defined?(ActionView::NonConcattingString)
|
103
|
+
return str
|
104
|
+
else
|
105
|
+
capture_without_haml(*args, &block)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
alias_method :capture_without_haml, :capture
|
109
|
+
alias_method :capture, :capture_with_haml
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
module TagHelper
|
114
|
+
def content_tag_with_haml(name, *args, &block)
|
115
|
+
return content_tag_without_haml(name, *args, &block) unless is_haml?
|
116
|
+
|
117
|
+
preserve = haml_buffer.options[:preserve].include?(name.to_s)
|
118
|
+
|
119
|
+
if block_given? && block_is_haml?(block) && preserve
|
120
|
+
return content_tag_without_haml(name, *args) {preserve(&block)}
|
121
|
+
end
|
122
|
+
|
123
|
+
content = content_tag_without_haml(name, *args, &block)
|
124
|
+
content = Haml::Helpers.preserve(content) if preserve && content
|
125
|
+
content
|
126
|
+
end
|
127
|
+
|
128
|
+
alias_method :content_tag_without_haml, :content_tag
|
129
|
+
alias_method :content_tag, :content_tag_with_haml
|
130
|
+
end
|
131
|
+
|
132
|
+
class InstanceTag
|
133
|
+
# Includes TagHelper
|
134
|
+
|
135
|
+
def haml_buffer
|
136
|
+
@template_object.send :haml_buffer
|
137
|
+
end
|
138
|
+
|
139
|
+
def is_haml?
|
140
|
+
@template_object.send :is_haml?
|
141
|
+
end
|
142
|
+
|
143
|
+
def content_tag(*args)
|
144
|
+
html_tag = content_tag_with_haml(*args)
|
145
|
+
return html_tag unless respond_to?(:error_wrapping)
|
146
|
+
return error_wrapping(html_tag) if method(:error_wrapping).arity == 1
|
147
|
+
return html_tag unless object.respond_to?(:errors) && object.errors.respond_to?(:on)
|
148
|
+
return error_wrapping(html_tag, object.errors.on(@method_name))
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
if Haml::Util.ap_geq_3?
|
153
|
+
module FormTagHelper
|
154
|
+
def form_tag_with_haml(url_for_options = {}, options = {}, *parameters_for_url, &proc)
|
155
|
+
if is_haml?
|
156
|
+
wrap_block = block_given? && block_is_haml?(proc)
|
157
|
+
if wrap_block
|
158
|
+
oldproc = proc
|
159
|
+
proc = haml_bind_proc do |*args|
|
160
|
+
concat "\n"
|
161
|
+
with_tabs(1) {oldproc.call(*args)}
|
162
|
+
end
|
163
|
+
end
|
164
|
+
res = form_tag_without_haml(url_for_options, options, *parameters_for_url, &proc) + "\n"
|
165
|
+
res << "\n" if wrap_block
|
166
|
+
res
|
167
|
+
else
|
168
|
+
form_tag_without_haml(url_for_options, options, *parameters_for_url, &proc)
|
169
|
+
end
|
170
|
+
end
|
171
|
+
alias_method :form_tag_without_haml, :form_tag
|
172
|
+
alias_method :form_tag, :form_tag_with_haml
|
173
|
+
end
|
174
|
+
|
175
|
+
module FormHelper
|
176
|
+
def form_for_with_haml(object_name, *args, &proc)
|
177
|
+
wrap_block = block_given? && is_haml? && block_is_haml?(proc)
|
178
|
+
if wrap_block
|
179
|
+
oldproc = proc
|
180
|
+
proc = proc {|*args| with_tabs(1) {oldproc.call(*args)}}
|
181
|
+
end
|
182
|
+
res = form_for_without_haml(object_name, *args, &proc)
|
183
|
+
res << "\n" if wrap_block
|
184
|
+
res
|
185
|
+
end
|
186
|
+
alias_method :form_for_without_haml, :form_for
|
187
|
+
alias_method :form_for, :form_for_with_haml
|
188
|
+
end
|
189
|
+
|
190
|
+
module CacheHelper
|
191
|
+
# This is a workaround for a Rails 3 bug
|
192
|
+
# that's present at least through beta 3.
|
193
|
+
# Their fragment_for assumes that the block
|
194
|
+
# will return its contents as a string,
|
195
|
+
# which is not always the case.
|
196
|
+
# Luckily, it only makes this assumption if caching is disabled,
|
197
|
+
# so we only override that case.
|
198
|
+
def fragment_for_with_haml(*args, &block)
|
199
|
+
return fragment_for_without_haml(*args, &block) if controller.perform_caching
|
200
|
+
capture(&block)
|
201
|
+
end
|
202
|
+
alias_method :fragment_for_without_haml, :fragment_for
|
203
|
+
alias_method :fragment_for, :fragment_for_with_haml
|
204
|
+
end
|
205
|
+
else
|
206
|
+
module FormTagHelper
|
207
|
+
def form_tag_with_haml(url_for_options = {}, options = {}, *parameters_for_url, &proc)
|
208
|
+
if is_haml?
|
209
|
+
wrap_block = block_given? && block_is_haml?(proc)
|
210
|
+
if wrap_block
|
211
|
+
oldproc = proc
|
212
|
+
proc = haml_bind_proc do |*args|
|
213
|
+
concat "\n"
|
214
|
+
tab_up
|
215
|
+
oldproc.call(*args)
|
216
|
+
tab_down
|
217
|
+
concat haml_indent
|
218
|
+
end
|
219
|
+
concat haml_indent
|
220
|
+
end
|
221
|
+
res = form_tag_without_haml(url_for_options, options, *parameters_for_url, &proc) + "\n"
|
222
|
+
if block_given?
|
223
|
+
concat "\n"
|
224
|
+
return Haml::Helpers::ErrorReturn.new("form_tag")
|
225
|
+
end
|
226
|
+
res
|
227
|
+
else
|
228
|
+
form_tag_without_haml(url_for_options, options, *parameters_for_url, &proc)
|
229
|
+
end
|
230
|
+
end
|
231
|
+
alias_method :form_tag_without_haml, :form_tag
|
232
|
+
alias_method :form_tag, :form_tag_with_haml
|
233
|
+
end
|
234
|
+
|
235
|
+
module FormHelper
|
236
|
+
def form_for_with_haml(object_name, *args, &proc)
|
237
|
+
wrap_block = block_given? && is_haml? && block_is_haml?(proc)
|
238
|
+
if wrap_block
|
239
|
+
oldproc = proc
|
240
|
+
proc = haml_bind_proc do |*args|
|
241
|
+
tab_up
|
242
|
+
oldproc.call(*args)
|
243
|
+
tab_down
|
244
|
+
concat haml_indent
|
245
|
+
end
|
246
|
+
concat haml_indent
|
247
|
+
end
|
248
|
+
form_for_without_haml(object_name, *args, &proc)
|
249
|
+
concat "\n" if wrap_block
|
250
|
+
Haml::Helpers::ErrorReturn.new("form_for") if is_haml?
|
251
|
+
end
|
252
|
+
alias_method :form_for_without_haml, :form_for
|
253
|
+
alias_method :form_for, :form_for_with_haml
|
254
|
+
end
|
255
|
+
end
|
256
|
+
end
|
257
|
+
end
|
@@ -0,0 +1,165 @@
|
|
1
|
+
module Haml
|
2
|
+
module Helpers
|
3
|
+
# This module overrides Haml helpers to work properly
|
4
|
+
# in the context of ActionView.
|
5
|
+
# Currently it's only used for modifying the helpers
|
6
|
+
# to work with Rails' XSS protection methods.
|
7
|
+
module XssMods
|
8
|
+
def self.included(base)
|
9
|
+
%w[html_escape find_and_preserve preserve list_of surround
|
10
|
+
precede succeed capture_haml haml_concat haml_indent
|
11
|
+
haml_tag escape_once].each do |name|
|
12
|
+
base.send(:alias_method, "#{name}_without_haml_xss", name)
|
13
|
+
base.send(:alias_method, name, "#{name}_with_haml_xss")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
# Don't escape text that's already safe,
|
18
|
+
# output is always HTML safe
|
19
|
+
def html_escape_with_haml_xss(text)
|
20
|
+
str = text.to_s
|
21
|
+
return text if str.html_safe?
|
22
|
+
Haml::Util.html_safe(html_escape_without_haml_xss(str))
|
23
|
+
end
|
24
|
+
|
25
|
+
# Output is always HTML safe
|
26
|
+
def find_and_preserve_with_haml_xss(*args, &block)
|
27
|
+
Haml::Util.html_safe(find_and_preserve_without_haml_xss(*args, &block))
|
28
|
+
end
|
29
|
+
|
30
|
+
# Output is always HTML safe
|
31
|
+
def preserve_with_haml_xss(*args, &block)
|
32
|
+
Haml::Util.html_safe(preserve_without_haml_xss(*args, &block))
|
33
|
+
end
|
34
|
+
|
35
|
+
# Output is always HTML safe
|
36
|
+
def list_of_with_haml_xss(*args, &block)
|
37
|
+
Haml::Util.html_safe(list_of_without_haml_xss(*args, &block))
|
38
|
+
end
|
39
|
+
|
40
|
+
# Input is escaped, output is always HTML safe
|
41
|
+
def surround_with_haml_xss(front, back = front, &block)
|
42
|
+
Haml::Util.html_safe(
|
43
|
+
surround_without_haml_xss(
|
44
|
+
haml_xss_html_escape(front),
|
45
|
+
haml_xss_html_escape(back),
|
46
|
+
&block))
|
47
|
+
end
|
48
|
+
|
49
|
+
# Input is escaped, output is always HTML safe
|
50
|
+
def precede_with_haml_xss(str, &block)
|
51
|
+
Haml::Util.html_safe(precede_without_haml_xss(haml_xss_html_escape(str), &block))
|
52
|
+
end
|
53
|
+
|
54
|
+
# Input is escaped, output is always HTML safe
|
55
|
+
def succeed_with_haml_xss(str, &block)
|
56
|
+
Haml::Util.html_safe(succeed_without_haml_xss(haml_xss_html_escape(str), &block))
|
57
|
+
end
|
58
|
+
|
59
|
+
# Output is always HTML safe
|
60
|
+
def capture_haml_with_haml_xss(*args, &block)
|
61
|
+
Haml::Util.html_safe(capture_haml_without_haml_xss(*args, &block))
|
62
|
+
end
|
63
|
+
|
64
|
+
# Input is escaped
|
65
|
+
def haml_concat_with_haml_xss(text = "")
|
66
|
+
haml_concat_without_haml_xss(@_haml_concat_raw ? text : haml_xss_html_escape(text))
|
67
|
+
end
|
68
|
+
|
69
|
+
# Output is always HTML safe
|
70
|
+
def haml_indent_with_haml_xss
|
71
|
+
Haml::Util.html_safe(haml_indent_without_haml_xss)
|
72
|
+
end
|
73
|
+
|
74
|
+
# Input is escaped, haml_concat'ed output is always HTML safe
|
75
|
+
def haml_tag_with_haml_xss(name, *rest, &block)
|
76
|
+
name = haml_xss_html_escape(name.to_s)
|
77
|
+
rest.unshift(haml_xss_html_escape(rest.shift.to_s)) unless [Symbol, Hash, NilClass].any? {|t| rest.first.is_a? t}
|
78
|
+
with_raw_haml_concat {haml_tag_without_haml_xss(name, *rest, &block)}
|
79
|
+
end
|
80
|
+
|
81
|
+
# Output is always HTML safe
|
82
|
+
def escape_once_with_haml_xss(*args)
|
83
|
+
Haml::Util.html_safe(escape_once_without_haml_xss(*args))
|
84
|
+
end
|
85
|
+
|
86
|
+
private
|
87
|
+
|
88
|
+
# Escapes the HTML in the text if and only if
|
89
|
+
# Rails XSS protection is enabled *and* the `:escape_html` option is set.
|
90
|
+
def haml_xss_html_escape(text)
|
91
|
+
return text unless Haml::Util.rails_xss_safe? && haml_buffer.options[:escape_html]
|
92
|
+
html_escape(text)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
class ErrorReturn
|
97
|
+
# Any attempt to treat ErrorReturn as a string should cause it to blow up.
|
98
|
+
alias_method :html_safe, :to_s
|
99
|
+
alias_method :html_safe?, :to_s
|
100
|
+
alias_method :html_safe!, :to_s
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
module ActionView
|
106
|
+
module Helpers
|
107
|
+
module CaptureHelper
|
108
|
+
def with_output_buffer_with_haml_xss(*args, &block)
|
109
|
+
res = with_output_buffer_without_haml_xss(*args, &block)
|
110
|
+
case res
|
111
|
+
when Array; res.map {|s| Haml::Util.html_safe(s)}
|
112
|
+
when String; Haml::Util.html_safe(res)
|
113
|
+
else; res
|
114
|
+
end
|
115
|
+
end
|
116
|
+
alias_method :with_output_buffer_without_haml_xss, :with_output_buffer
|
117
|
+
alias_method :with_output_buffer, :with_output_buffer_with_haml_xss
|
118
|
+
end
|
119
|
+
|
120
|
+
module FormTagHelper
|
121
|
+
def form_tag_with_haml_xss(*args, &block)
|
122
|
+
res = form_tag_without_haml_xss(*args, &block)
|
123
|
+
res = Haml::Util.html_safe(res) unless block_given?
|
124
|
+
res
|
125
|
+
end
|
126
|
+
alias_method :form_tag_without_haml_xss, :form_tag
|
127
|
+
alias_method :form_tag, :form_tag_with_haml_xss
|
128
|
+
end
|
129
|
+
|
130
|
+
module FormHelper
|
131
|
+
def form_for_with_haml_xss(*args, &block)
|
132
|
+
res = form_for_without_haml_xss(*args, &block)
|
133
|
+
return Haml::Util.html_safe(res) if res.is_a?(String)
|
134
|
+
return res
|
135
|
+
end
|
136
|
+
alias_method :form_for_without_haml_xss, :form_for
|
137
|
+
alias_method :form_for, :form_for_with_haml_xss
|
138
|
+
end
|
139
|
+
|
140
|
+
module TextHelper
|
141
|
+
def concat_with_haml_xss(string)
|
142
|
+
if is_haml?
|
143
|
+
haml_buffer.buffer.concat(haml_xss_html_escape(string))
|
144
|
+
else
|
145
|
+
concat_without_haml_xss(string)
|
146
|
+
end
|
147
|
+
end
|
148
|
+
alias_method :concat_without_haml_xss, :concat
|
149
|
+
alias_method :concat, :concat_with_haml_xss
|
150
|
+
|
151
|
+
# safe_concat was introduced in Rails 3.0
|
152
|
+
if Haml::Util.has?(:instance_method, self, :safe_concat)
|
153
|
+
def safe_concat_with_haml_xss(string)
|
154
|
+
if is_haml?
|
155
|
+
haml_buffer.buffer.concat(string)
|
156
|
+
else
|
157
|
+
safe_concat_without_haml_xss(string)
|
158
|
+
end
|
159
|
+
end
|
160
|
+
alias_method :safe_concat_without_haml_xss, :safe_concat
|
161
|
+
alias_method :safe_concat, :safe_concat_with_haml_xss
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|