haml_ejs 0.0.1
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/.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,12 @@
|
|
|
1
|
+
<h2>This is a pretty complicated partial</h2>
|
|
2
|
+
<div class="partial">
|
|
3
|
+
<p>It has several nested partials,</p>
|
|
4
|
+
<ul>
|
|
5
|
+
<% 5.times do %>
|
|
6
|
+
<li>
|
|
7
|
+
<strong>Partial:</strong>
|
|
8
|
+
<% @nesting = 5 %>
|
|
9
|
+
<%= render :partial => 'haml/erb/av_partial_2' %>
|
|
10
|
+
<% end %>
|
|
11
|
+
</ul>
|
|
12
|
+
</div>
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
2
|
+
<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en-US'>
|
|
3
|
+
<head>
|
|
4
|
+
<title>Hampton Catlin Is Totally Awesome</title>
|
|
5
|
+
<meta content='text/html; charset=utf-8' http-equiv='Content-Type' />
|
|
6
|
+
</head>
|
|
7
|
+
<body>
|
|
8
|
+
<h1>
|
|
9
|
+
This is very much like the standard template,
|
|
10
|
+
except that it has some ActionView-specific stuff.
|
|
11
|
+
It's only used for benchmarking.
|
|
12
|
+
</h1>
|
|
13
|
+
<div class="crazy_partials">
|
|
14
|
+
<%= render :partial => 'haml/erb/av_partial_1' %>
|
|
15
|
+
</div>
|
|
16
|
+
<!-- You're In my house now! -->
|
|
17
|
+
<div class='header'>
|
|
18
|
+
Yes, ladies and gentileman. He is just that egotistical.
|
|
19
|
+
Fantastic! This should be multi-line output
|
|
20
|
+
The question is if this would translate! Ahah!
|
|
21
|
+
<%= 1 + 9 + 8 + 2 %>
|
|
22
|
+
<%# numbers should work and this should be ignored %>
|
|
23
|
+
</div>
|
|
24
|
+
<% 120.times do |number| -%>
|
|
25
|
+
<%= number %>
|
|
26
|
+
<% end -%>
|
|
27
|
+
<div id='body'><%= " Quotes should be loved! Just like people!" %></div>
|
|
28
|
+
Wow.
|
|
29
|
+
<p>
|
|
30
|
+
<%= "Holy cow " +
|
|
31
|
+
"multiline " +
|
|
32
|
+
"tags! " +
|
|
33
|
+
"A pipe (|) even!" %>
|
|
34
|
+
<%= [1, 2, 3].collect { |n| "PipesIgnored|" } %>
|
|
35
|
+
<%= [1, 2, 3].collect { |n|
|
|
36
|
+
n.to_s
|
|
37
|
+
}.join("|") %>
|
|
38
|
+
</p>
|
|
39
|
+
<div class='silent'>
|
|
40
|
+
<% foo = String.new
|
|
41
|
+
foo << "this"
|
|
42
|
+
foo << " shouldn't"
|
|
43
|
+
foo << " evaluate" %>
|
|
44
|
+
<%= foo + "but now it should!" %>
|
|
45
|
+
<%# Woah crap a comment! %>
|
|
46
|
+
</div>
|
|
47
|
+
<ul class='really cool'>
|
|
48
|
+
<% ('a'..'f').each do |a|%>
|
|
49
|
+
<li><%= a %>
|
|
50
|
+
<% end %>
|
|
51
|
+
<div class='of_divs_with_underscore' id='combo'><%= @should_eval = "with this text" %></div>
|
|
52
|
+
<%= [ 104, 101, 108, 108, 111 ].map do |byte|
|
|
53
|
+
byte.chr
|
|
54
|
+
end %>
|
|
55
|
+
<div class='footer'>
|
|
56
|
+
<strong class='shout'>
|
|
57
|
+
<%= "This is a really long ruby quote. It should be loved and wrapped because its more than 50 characters. This value may change in the future and this test may look stupid.\n" +
|
|
58
|
+
" So, I'm just making it *really* long. God, I hope this works" %>
|
|
59
|
+
</strong>
|
|
60
|
+
</div>
|
|
61
|
+
</body>
|
|
62
|
+
</html>
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
2
|
+
<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en-US' lang='en-US'>
|
|
3
|
+
<head>
|
|
4
|
+
<title>Hampton Catlin Is Totally Awesome</title>
|
|
5
|
+
<meta content='text/html; charset=utf-8' http-equiv='Content-Type' />
|
|
6
|
+
</head>
|
|
7
|
+
<body>
|
|
8
|
+
<!-- You're In my house now! -->
|
|
9
|
+
<div class='header'>
|
|
10
|
+
Yes, ladies and gentileman. He is just that egotistical.
|
|
11
|
+
Fantastic! This should be multi-line output
|
|
12
|
+
The question is if this would translate! Ahah!
|
|
13
|
+
<%= 1 + 9 + 8 + 2 %>
|
|
14
|
+
<%# numbers should work and this should be ignored %>
|
|
15
|
+
</div>
|
|
16
|
+
<% 120.times do |number| -%>
|
|
17
|
+
<%= number %>
|
|
18
|
+
<% end -%>
|
|
19
|
+
<div id='body'><%= " Quotes should be loved! Just like people!" %></div>
|
|
20
|
+
Wow.
|
|
21
|
+
<p code="<%= 1 + 2 %>">
|
|
22
|
+
<%= "Holy cow " +
|
|
23
|
+
"multiline " +
|
|
24
|
+
"tags! " +
|
|
25
|
+
"A pipe (|) even!" %>
|
|
26
|
+
<%= [1, 2, 3].collect { |n| "PipesIgnored|" }.join %>
|
|
27
|
+
<%= [1, 2, 3].collect { |n|
|
|
28
|
+
n.to_s
|
|
29
|
+
}.join("|") %>
|
|
30
|
+
</p>
|
|
31
|
+
<% bar = 17 %>
|
|
32
|
+
<div class='silent' foo="<%= bar %>">
|
|
33
|
+
<% foo = String.new
|
|
34
|
+
foo << "this"
|
|
35
|
+
foo << " shouldn't"
|
|
36
|
+
foo << " evaluate" %>
|
|
37
|
+
<%= foo + "but now it should!" %>
|
|
38
|
+
<%# Woah crap a comment! %>
|
|
39
|
+
</div>
|
|
40
|
+
<ul class='really cool'>
|
|
41
|
+
<% ('a'..'f').each do |a|%>
|
|
42
|
+
<li><%= a %></li>
|
|
43
|
+
<% end %>
|
|
44
|
+
<div class='of_divs_with_underscore' id='combo'><%= @should_eval = "with this text" %></div>
|
|
45
|
+
<%= "foo".each_line do |line|
|
|
46
|
+
nil
|
|
47
|
+
end %>
|
|
48
|
+
<div class='footer'>
|
|
49
|
+
<strong class='shout'>
|
|
50
|
+
<%= "This is a really long ruby quote. It should be loved and wrapped because its more than 50 characters. This value may change in the future and this test may look stupid.\n" +
|
|
51
|
+
" So, I'm just making it *really* long. God, I hope this works" %>
|
|
52
|
+
</strong>
|
|
53
|
+
</div>
|
|
54
|
+
</body>
|
|
55
|
+
</html>
|
|
@@ -0,0 +1,454 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
|
3
|
+
|
|
4
|
+
class ActionView::Base
|
|
5
|
+
def nested_tag
|
|
6
|
+
content_tag(:span) {content_tag(:div) {"something"}}
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def wacky_form
|
|
10
|
+
form_tag("/foo") {"bar"}
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
module Haml::Helpers
|
|
15
|
+
def something_that_uses_haml_concat
|
|
16
|
+
haml_concat('foo').to_s
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
class HelperTest < Test::Unit::TestCase
|
|
21
|
+
Post = Struct.new('Post', :body, :error_field, :errors)
|
|
22
|
+
class PostErrors
|
|
23
|
+
def on(name)
|
|
24
|
+
return unless name == 'error_field'
|
|
25
|
+
["Really bad error"]
|
|
26
|
+
end
|
|
27
|
+
alias_method :full_messages, :on
|
|
28
|
+
|
|
29
|
+
def [](name)
|
|
30
|
+
on(name) || []
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def setup
|
|
35
|
+
@base = ActionView::Base.new
|
|
36
|
+
@base.controller = ActionController::Base.new
|
|
37
|
+
|
|
38
|
+
if defined?(ActionController::Response)
|
|
39
|
+
# This is needed for >=3.0.0
|
|
40
|
+
@base.controller.response = ActionController::Response.new
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
@base.instance_variable_set('@post', Post.new("Foo bar\nbaz", nil, PostErrors.new))
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def render(text, options = {})
|
|
47
|
+
if options == :action_view
|
|
48
|
+
@base.render :inline => text, :type => :haml
|
|
49
|
+
else
|
|
50
|
+
scope = options.delete :scope_object
|
|
51
|
+
Haml::Engine.new(text, options).to_html(scope ? scope : Object.new)
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def test_flatten
|
|
56
|
+
assert_equal("FooBar", Haml::Helpers.flatten("FooBar"))
|
|
57
|
+
|
|
58
|
+
assert_equal("FooBar", Haml::Helpers.flatten("Foo\rBar"))
|
|
59
|
+
|
|
60
|
+
assert_equal("Foo
Bar", Haml::Helpers.flatten("Foo\nBar"))
|
|
61
|
+
|
|
62
|
+
assert_equal("Hello
World!
YOU ARE FLAT?
OMGZ!",
|
|
63
|
+
Haml::Helpers.flatten("Hello\nWorld!\nYOU ARE \rFLAT?\n\rOMGZ!"))
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def test_list_of_should_render_correctly
|
|
67
|
+
assert_equal("<li>1</li>\n<li>2</li>\n", render("= list_of([1, 2]) do |i|\n = i"))
|
|
68
|
+
assert_equal("<li>[1]</li>\n", render("= list_of([[1]]) do |i|\n = i.inspect"))
|
|
69
|
+
assert_equal("<li>\n <h1>Fee</h1>\n <p>A word!</p>\n</li>\n<li>\n <h1>Fi</h1>\n <p>A word!</p>\n</li>\n<li>\n <h1>Fo</h1>\n <p>A word!</p>\n</li>\n<li>\n <h1>Fum</h1>\n <p>A word!</p>\n</li>\n",
|
|
70
|
+
render("= list_of(['Fee', 'Fi', 'Fo', 'Fum']) do |title|\n %h1= title\n %p A word!"))
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def test_buffer_access
|
|
74
|
+
assert(render("= buffer") =~ /#<Haml::Buffer:0x[a-z0-9]+>/)
|
|
75
|
+
assert_equal(render("= (buffer == _hamlout)"), "true\n")
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def test_tabs
|
|
79
|
+
assert_equal("foo\n bar\nbaz\n", render("foo\n- tab_up\nbar\n- tab_down\nbaz"))
|
|
80
|
+
assert_equal(" <p>tabbed</p>\n", render("- buffer.tabulation=5\n%p tabbed"))
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def test_with_tabs
|
|
84
|
+
assert_equal(<<HTML, render(<<HAML))
|
|
85
|
+
Foo
|
|
86
|
+
Bar
|
|
87
|
+
Baz
|
|
88
|
+
Baz
|
|
89
|
+
HTML
|
|
90
|
+
Foo
|
|
91
|
+
- with_tabs 2 do
|
|
92
|
+
= "Bar\\nBaz"
|
|
93
|
+
Baz
|
|
94
|
+
HAML
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def test_helpers_dont_leak
|
|
98
|
+
# Haml helpers shouldn't be accessible from ERB
|
|
99
|
+
render("foo")
|
|
100
|
+
proper_behavior = false
|
|
101
|
+
|
|
102
|
+
begin
|
|
103
|
+
ActionView::Base.new.render(:inline => "<%= flatten('Foo\\nBar') %>")
|
|
104
|
+
rescue NoMethodError, Haml::Util.av_template_class(:Error)
|
|
105
|
+
proper_behavior = true
|
|
106
|
+
end
|
|
107
|
+
assert(proper_behavior)
|
|
108
|
+
|
|
109
|
+
begin
|
|
110
|
+
ActionView::Base.new.render(:inline => "<%= concat('foo') %>")
|
|
111
|
+
rescue ArgumentError, NameError
|
|
112
|
+
proper_behavior = true
|
|
113
|
+
end
|
|
114
|
+
assert(proper_behavior)
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
def test_action_view_included
|
|
118
|
+
assert(Haml::Helpers.action_view?)
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def test_form_tag
|
|
122
|
+
# This is usually provided by ActionController::Base.
|
|
123
|
+
def @base.protect_against_forgery?; false; end
|
|
124
|
+
assert_equal(<<HTML, render(<<HAML, :action_view))
|
|
125
|
+
<form #{rails_form_attr}action="foo" method="post">#{rails_form_opener}
|
|
126
|
+
<p>bar</p>
|
|
127
|
+
<strong>baz</strong>
|
|
128
|
+
</form>
|
|
129
|
+
HTML
|
|
130
|
+
#{rails_block_helper_char} form_tag 'foo' do
|
|
131
|
+
%p bar
|
|
132
|
+
%strong baz
|
|
133
|
+
HAML
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
def test_text_area
|
|
137
|
+
assert_equal(%(<textarea id="body" name="body">Foo
Bar
 Baz
 Boom</textarea>\n),
|
|
138
|
+
render('= text_area_tag "body", "Foo\nBar\n Baz\n Boom"', :action_view))
|
|
139
|
+
|
|
140
|
+
assert_equal(%(<textarea cols="40" id="post_body" name="post[body]" rows="20">Foo bar
baz</textarea>\n),
|
|
141
|
+
render('= text_area :post, :body', :action_view))
|
|
142
|
+
|
|
143
|
+
assert_equal(%(<pre>Foo bar
 baz</pre>\n),
|
|
144
|
+
render('= content_tag "pre", "Foo bar\n baz"', :action_view))
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
def test_capture_haml
|
|
148
|
+
assert_equal(<<HTML, render(<<HAML))
|
|
149
|
+
"<p>13</p>\\n"
|
|
150
|
+
HTML
|
|
151
|
+
- (foo = capture_haml(13) do |a|
|
|
152
|
+
%p= a
|
|
153
|
+
- end; nil)
|
|
154
|
+
= foo.dump
|
|
155
|
+
HAML
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
def test_content_tag_block
|
|
159
|
+
assert_equal(<<HTML.strip, render(<<HAML, :action_view).strip)
|
|
160
|
+
<div><p>bar</p>
|
|
161
|
+
<strong>bar</strong>
|
|
162
|
+
</div>
|
|
163
|
+
HTML
|
|
164
|
+
#{rails_block_helper_char} content_tag :div do
|
|
165
|
+
%p bar
|
|
166
|
+
%strong bar
|
|
167
|
+
HAML
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
def test_content_tag_error_wrapping
|
|
171
|
+
def @base.protect_against_forgery?; false; end
|
|
172
|
+
error_class = Haml::Util.ap_geq_3? ? "field_with_errors" : "fieldWithErrors"
|
|
173
|
+
assert_equal(<<HTML, render(<<HAML, :action_view))
|
|
174
|
+
<form #{rails_form_attr}action="" method="post">#{rails_form_opener}
|
|
175
|
+
<div class="#{error_class}"><label for="post_error_field">Error field</label></div>
|
|
176
|
+
</form>
|
|
177
|
+
HTML
|
|
178
|
+
#{rails_block_helper_char} form_for #{form_for_calling_convention('post')}, :url => '' do |f|
|
|
179
|
+
= f.label 'error_field'
|
|
180
|
+
HAML
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
def test_form_tag_in_helper_with_string_block
|
|
184
|
+
def @base.protect_against_forgery?; false; end
|
|
185
|
+
assert_equal(<<HTML, render(<<HAML, :action_view))
|
|
186
|
+
<form #{rails_form_attr}action="/foo" method="post">#{rails_form_opener}bar</form>
|
|
187
|
+
HTML
|
|
188
|
+
#{rails_block_helper_char} wacky_form
|
|
189
|
+
HAML
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
def test_haml_tag_name_attribute_with_id
|
|
193
|
+
assert_equal("<p id='some_id'></p>\n", render("- haml_tag 'p#some_id'"))
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
def test_haml_tag_name_attribute_with_colon_id
|
|
197
|
+
assert_equal("<p id='some:id'></p>\n", render("- haml_tag 'p#some:id'"))
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
def test_haml_tag_without_name_but_with_id
|
|
201
|
+
assert_equal("<div id='some_id'></div>\n", render("- haml_tag '#some_id'"))
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
def test_haml_tag_without_name_but_with_class
|
|
205
|
+
assert_equal("<div class='foo'></div>\n", render("- haml_tag '.foo'"))
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
def test_haml_tag_without_name_but_with_colon_class
|
|
209
|
+
assert_equal("<div class='foo:bar'></div>\n", render("- haml_tag '.foo:bar'"))
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
def test_haml_tag_name_with_id_and_class
|
|
213
|
+
assert_equal("<p class='foo' id='some_id'></p>\n", render("- haml_tag 'p#some_id.foo'"))
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
def test_haml_tag_name_with_class
|
|
217
|
+
assert_equal("<p class='foo'></p>\n", render("- haml_tag 'p.foo'"))
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
def test_haml_tag_name_with_class_and_id
|
|
221
|
+
assert_equal("<p class='foo' id='some_id'></p>\n", render("- haml_tag 'p.foo#some_id'"))
|
|
222
|
+
end
|
|
223
|
+
|
|
224
|
+
def test_haml_tag_name_with_id_and_multiple_classes
|
|
225
|
+
assert_equal("<p class='foo bar' id='some_id'></p>\n", render("- haml_tag 'p#some_id.foo.bar'"))
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
def test_haml_tag_name_with_multiple_classes_and_id
|
|
229
|
+
assert_equal("<p class='foo bar' id='some_id'></p>\n", render("- haml_tag 'p.foo.bar#some_id'"))
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
def test_haml_tag_name_and_attribute_classes_merging
|
|
233
|
+
assert_equal("<p class='foo bar' id='some_id'></p>\n", render("- haml_tag 'p#some_id.foo', :class => 'bar'"))
|
|
234
|
+
end
|
|
235
|
+
|
|
236
|
+
def test_haml_tag_name_and_attribute_classes_merging
|
|
237
|
+
assert_equal("<p class='bar foo'></p>\n", render("- haml_tag 'p.foo', :class => 'bar'"))
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
def test_haml_tag_name_merges_id_and_attribute_id
|
|
241
|
+
assert_equal("<p id='foo_bar'></p>\n", render("- haml_tag 'p#foo', :id => 'bar'"))
|
|
242
|
+
end
|
|
243
|
+
|
|
244
|
+
def test_haml_tag_attribute_html_escaping
|
|
245
|
+
assert_equal("<p id='foo&bar'>baz</p>\n", render("%p{:id => 'foo&bar'} baz", :escape_html => true))
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
def test_haml_tag_autoclosed_tags_are_closed
|
|
249
|
+
assert_equal("<br class='foo' />\n", render("- haml_tag :br, :class => 'foo'"))
|
|
250
|
+
end
|
|
251
|
+
|
|
252
|
+
def test_haml_tag_with_class_array
|
|
253
|
+
assert_equal("<p class='a b'>foo</p>\n", render("- haml_tag :p, 'foo', :class => %w[a b]"))
|
|
254
|
+
assert_equal("<p class='a b c d'>foo</p>\n", render("- haml_tag 'p.c.d', 'foo', :class => %w[a b]"))
|
|
255
|
+
end
|
|
256
|
+
|
|
257
|
+
def test_haml_tag_with_id_array
|
|
258
|
+
assert_equal("<p id='a_b'>foo</p>\n", render("- haml_tag :p, 'foo', :id => %w[a b]"))
|
|
259
|
+
assert_equal("<p id='c_a_b'>foo</p>\n", render("- haml_tag 'p#c', 'foo', :id => %w[a b]"))
|
|
260
|
+
end
|
|
261
|
+
|
|
262
|
+
def test_haml_tag_with_data_hash
|
|
263
|
+
assert_equal("<p data-baz='data-baz' data-foo='bar'>foo</p>\n",
|
|
264
|
+
render("- haml_tag :p, 'foo', :data => {:foo => 'bar', :baz => true}"))
|
|
265
|
+
end
|
|
266
|
+
|
|
267
|
+
def test_haml_tag_non_autoclosed_tags_arent_closed
|
|
268
|
+
assert_equal("<p></p>\n", render("- haml_tag :p"))
|
|
269
|
+
end
|
|
270
|
+
|
|
271
|
+
def test_haml_tag_renders_text_on_a_single_line
|
|
272
|
+
assert_equal("<p>#{'a' * 100}</p>\n", render("- haml_tag :p, 'a' * 100"))
|
|
273
|
+
end
|
|
274
|
+
|
|
275
|
+
def test_haml_tag_raises_error_for_multiple_content
|
|
276
|
+
assert_raise(Haml::Error) { render("- haml_tag :p, 'foo' do\n bar") }
|
|
277
|
+
end
|
|
278
|
+
|
|
279
|
+
def test_haml_tag_flags
|
|
280
|
+
assert_equal("<p />\n", render("- haml_tag :p, :/"))
|
|
281
|
+
assert_equal("<p>kumquat</p>\n", render("- haml_tag :p, :< do\n kumquat"))
|
|
282
|
+
|
|
283
|
+
assert_raise(Haml::Error) { render("- haml_tag :p, 'foo', :/") }
|
|
284
|
+
assert_raise(Haml::Error) { render("- haml_tag :p, :/ do\n foo") }
|
|
285
|
+
end
|
|
286
|
+
|
|
287
|
+
def test_haml_tag_error_return
|
|
288
|
+
assert_raise(Haml::Error) { render("= haml_tag :p") }
|
|
289
|
+
end
|
|
290
|
+
|
|
291
|
+
def test_haml_tag_with_multiline_string
|
|
292
|
+
assert_equal(<<HTML, render(<<HAML))
|
|
293
|
+
<p>
|
|
294
|
+
foo
|
|
295
|
+
bar
|
|
296
|
+
baz
|
|
297
|
+
</p>
|
|
298
|
+
HTML
|
|
299
|
+
- haml_tag :p, "foo\\nbar\\nbaz"
|
|
300
|
+
HAML
|
|
301
|
+
end
|
|
302
|
+
|
|
303
|
+
def test_haml_concat_with_multiline_string
|
|
304
|
+
assert_equal(<<HTML, render(<<HAML))
|
|
305
|
+
<p>
|
|
306
|
+
foo
|
|
307
|
+
bar
|
|
308
|
+
baz
|
|
309
|
+
</p>
|
|
310
|
+
HTML
|
|
311
|
+
%p
|
|
312
|
+
- haml_concat "foo\\nbar\\nbaz"
|
|
313
|
+
HAML
|
|
314
|
+
end
|
|
315
|
+
|
|
316
|
+
def test_haml_tag_with_ugly
|
|
317
|
+
assert_equal(<<HTML, render(<<HAML, :ugly => true))
|
|
318
|
+
<p>
|
|
319
|
+
<strong>Hi!</strong>
|
|
320
|
+
</p>
|
|
321
|
+
HTML
|
|
322
|
+
- haml_tag :p do
|
|
323
|
+
- haml_tag :strong, "Hi!"
|
|
324
|
+
HAML
|
|
325
|
+
end
|
|
326
|
+
|
|
327
|
+
def test_is_haml
|
|
328
|
+
assert(!ActionView::Base.new.is_haml?)
|
|
329
|
+
assert_equal("true\n", render("= is_haml?"))
|
|
330
|
+
assert_equal("true\n", render("= is_haml?", :action_view))
|
|
331
|
+
assert_equal("false", @base.render(:inline => '<%= is_haml? %>'))
|
|
332
|
+
assert_equal("false\n", render("= render :inline => '<%= is_haml? %>'", :action_view))
|
|
333
|
+
end
|
|
334
|
+
|
|
335
|
+
def test_page_class
|
|
336
|
+
controller = Struct.new(:controller_name, :action_name).new('troller', 'tion')
|
|
337
|
+
scope = Struct.new(:controller).new(controller)
|
|
338
|
+
result = render("%div{:class => page_class} MyDiv", :scope_object => scope)
|
|
339
|
+
expected = "<div class='troller tion'>MyDiv</div>\n"
|
|
340
|
+
assert_equal expected, result
|
|
341
|
+
end
|
|
342
|
+
|
|
343
|
+
def test_indented_capture
|
|
344
|
+
prior = Haml::Util.ap_geq_3? ? "" : " \n"
|
|
345
|
+
assert_equal("#{prior} Foo\n ", @base.render(:inline => " <% res = capture do %>\n Foo\n <% end %><%= res %>"))
|
|
346
|
+
end
|
|
347
|
+
|
|
348
|
+
def test_capture_deals_properly_with_collections
|
|
349
|
+
Haml::Helpers.module_eval do
|
|
350
|
+
def trc(collection, &block)
|
|
351
|
+
collection.each do |record|
|
|
352
|
+
haml_concat capture_haml(record, &block)
|
|
353
|
+
end
|
|
354
|
+
end
|
|
355
|
+
end
|
|
356
|
+
|
|
357
|
+
assert_equal("1\n\n2\n\n3\n\n", render("- trc([1, 2, 3]) do |i|\n = i.inspect"))
|
|
358
|
+
end
|
|
359
|
+
|
|
360
|
+
def test_capture_with_string_block
|
|
361
|
+
assert_equal("foo\n", render("= capture { 'foo' }", :action_view))
|
|
362
|
+
end
|
|
363
|
+
|
|
364
|
+
def test_find_and_preserve_with_block
|
|
365
|
+
assert_equal("<pre>Foo
Bar</pre>\nFoo\nBar\n",
|
|
366
|
+
render("= find_and_preserve do\n %pre\n Foo\n Bar\n Foo\n Bar"))
|
|
367
|
+
end
|
|
368
|
+
|
|
369
|
+
def test_find_and_preserve_with_block_and_tags
|
|
370
|
+
assert_equal("<pre>Foo\nBar</pre>\nFoo\nBar\n",
|
|
371
|
+
render("= find_and_preserve([]) do\n %pre\n Foo\n Bar\n Foo\n Bar"))
|
|
372
|
+
end
|
|
373
|
+
|
|
374
|
+
def test_preserve_with_block
|
|
375
|
+
assert_equal("<pre>Foo
Bar</pre>
Foo
Bar\n",
|
|
376
|
+
render("= preserve do\n %pre\n Foo\n Bar\n Foo\n Bar"))
|
|
377
|
+
end
|
|
378
|
+
|
|
379
|
+
def test_init_haml_helpers
|
|
380
|
+
context = Object.new
|
|
381
|
+
class << context
|
|
382
|
+
include Haml::Helpers
|
|
383
|
+
end
|
|
384
|
+
context.init_haml_helpers
|
|
385
|
+
|
|
386
|
+
result = context.capture_haml do
|
|
387
|
+
context.haml_tag :p, :attr => "val" do
|
|
388
|
+
context.haml_concat "Blah"
|
|
389
|
+
end
|
|
390
|
+
end
|
|
391
|
+
|
|
392
|
+
assert_equal("<p attr='val'>\n Blah\n</p>\n", result)
|
|
393
|
+
end
|
|
394
|
+
|
|
395
|
+
def test_non_haml
|
|
396
|
+
assert_equal("false\n", render("= non_haml { is_haml? }"))
|
|
397
|
+
end
|
|
398
|
+
|
|
399
|
+
def test_content_tag_nested
|
|
400
|
+
assert_equal "<span><div>something</div></span>", render("= nested_tag", :action_view).strip
|
|
401
|
+
end
|
|
402
|
+
|
|
403
|
+
def test_error_return
|
|
404
|
+
assert_raise(Haml::Error, <<MESSAGE) {render("= haml_concat 'foo'")}
|
|
405
|
+
haml_concat outputs directly to the Haml template.
|
|
406
|
+
Disregard its return value and use the - operator,
|
|
407
|
+
or use capture_haml to get the value as a String.
|
|
408
|
+
MESSAGE
|
|
409
|
+
end
|
|
410
|
+
|
|
411
|
+
def test_error_return_line
|
|
412
|
+
render("%p foo\n= haml_concat 'foo'\n%p bar")
|
|
413
|
+
assert false, "Expected Haml::Error"
|
|
414
|
+
rescue Haml::Error => e
|
|
415
|
+
assert_equal 2, e.backtrace[1].scan(/:(\d+)/).first.first.to_i
|
|
416
|
+
end
|
|
417
|
+
|
|
418
|
+
def test_error_return_line_in_helper
|
|
419
|
+
render("- something_that_uses_haml_concat")
|
|
420
|
+
assert false, "Expected Haml::Error"
|
|
421
|
+
rescue Haml::Error => e
|
|
422
|
+
assert_equal 16, e.backtrace[0].scan(/:(\d+)/).first.first.to_i
|
|
423
|
+
end
|
|
424
|
+
|
|
425
|
+
class ActsLikeTag
|
|
426
|
+
# We want to be able to have people include monkeypatched ActionView helpers
|
|
427
|
+
# without redefining is_haml?.
|
|
428
|
+
# This is accomplished via Object#is_haml?, and this is a test for it.
|
|
429
|
+
include ActionView::Helpers::TagHelper
|
|
430
|
+
def to_s
|
|
431
|
+
content_tag :p, 'some tag content'
|
|
432
|
+
end
|
|
433
|
+
end
|
|
434
|
+
|
|
435
|
+
def test_random_class_includes_tag_helper
|
|
436
|
+
assert_equal "<p>some tag content</p>", ActsLikeTag.new.to_s
|
|
437
|
+
end
|
|
438
|
+
|
|
439
|
+
def test_capture_with_nuke_outer
|
|
440
|
+
assert_equal "<div></div>\n*<div>hi there!</div>\n", render(<<HAML)
|
|
441
|
+
%div
|
|
442
|
+
= precede("*") do
|
|
443
|
+
%div> hi there!
|
|
444
|
+
HAML
|
|
445
|
+
|
|
446
|
+
assert_equal "<div></div>\n*<div>hi there!</div>\n", render(<<HAML)
|
|
447
|
+
%div
|
|
448
|
+
= precede("*") do
|
|
449
|
+
= " "
|
|
450
|
+
%div> hi there!
|
|
451
|
+
HAML
|
|
452
|
+
end
|
|
453
|
+
end
|
|
454
|
+
|