hamlit 1.7.2 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +4 -3
- data/.gitmodules +3 -0
- data/.travis.yml +25 -37
- data/CHANGELOG.md +18 -0
- data/Gemfile +16 -0
- data/LICENSE.txt +23 -2
- data/README.md +106 -48
- data/REFERENCE.md +222 -0
- data/Rakefile +77 -19
- data/benchmark/boolean_attribute.haml +6 -0
- data/benchmark/class_attribute.haml +5 -0
- data/benchmark/common_attribute.haml +3 -0
- data/benchmark/data_attribute.haml +4 -0
- data/benchmark/dynamic_attributes/boolean_attribute.haml +4 -0
- data/benchmark/dynamic_attributes/class_attribute.haml +4 -0
- data/benchmark/dynamic_attributes/common_attribute.haml +2 -0
- data/benchmark/dynamic_attributes/data_attribute.haml +2 -0
- data/benchmark/dynamic_attributes/id_attribute.haml +2 -0
- data/benchmark/etc/attribute_builder.haml +5 -0
- data/benchmark/etc/real_sample.haml +888 -0
- data/benchmark/etc/real_sample.rb +11 -0
- data/benchmark/etc/static_analyzer.haml +1 -0
- data/benchmark/etc/tags.haml +3 -0
- data/benchmark/ext/build_data.rb +15 -0
- data/benchmark/ext/build_id.rb +13 -0
- data/benchmark/id_attribute.haml +3 -0
- data/benchmark/plain.haml +4 -0
- data/benchmark/script.haml +4 -0
- data/benchmark/slim/LICENSE +21 -0
- data/{benchmarks → benchmark/slim}/context.rb +2 -4
- data/benchmark/slim/run-benchmarks.rb +94 -0
- data/{benchmarks → benchmark/slim}/view.erb +3 -3
- data/{benchmarks → benchmark/slim}/view.haml +0 -0
- data/{benchmarks/view.escaped.slim → benchmark/slim/view.slim} +1 -1
- data/benchmark/string_interpolation.haml +2 -0
- data/benchmark/utils/benchmark_ips_extension.rb +43 -0
- data/bin/bench +85 -0
- data/bin/clone +14 -0
- data/bin/console +11 -0
- data/bin/lineprof +48 -0
- data/bin/ruby +3 -0
- data/bin/setup +7 -0
- data/bin/stackprof +27 -0
- data/{test → bin/test} +6 -10
- data/{bin → exe}/hamlit +0 -0
- data/ext/hamlit/extconf.rb +14 -0
- data/ext/hamlit/hamlit.c +512 -0
- data/ext/hamlit/houdini/.gitignore +3 -0
- data/ext/hamlit/houdini/COPYING +7 -0
- data/ext/hamlit/houdini/Makefile +79 -0
- data/ext/hamlit/houdini/README.md +59 -0
- data/ext/hamlit/houdini/buffer.c +249 -0
- data/ext/hamlit/houdini/buffer.h +113 -0
- data/ext/hamlit/houdini/houdini.h +46 -0
- data/ext/hamlit/houdini/houdini_href_e.c +115 -0
- data/ext/hamlit/houdini/houdini_html_e.c +90 -0
- data/ext/hamlit/houdini/houdini_html_u.c +122 -0
- data/ext/hamlit/houdini/houdini_js_e.c +90 -0
- data/ext/hamlit/houdini/houdini_js_u.c +60 -0
- data/ext/hamlit/houdini/houdini_uri_e.c +107 -0
- data/ext/hamlit/houdini/houdini_uri_u.c +68 -0
- data/ext/hamlit/houdini/houdini_xml_e.c +136 -0
- data/ext/hamlit/houdini/html_unescape.gperf +258 -0
- data/ext/hamlit/houdini/html_unescape.h +754 -0
- data/ext/hamlit/houdini/tools/build_table.py +13 -0
- data/ext/hamlit/houdini/tools/build_tables.c +51 -0
- data/ext/hamlit/houdini/tools/wikipedia_table.txt +2025 -0
- data/hamlit.gemspec +30 -31
- data/lib/hamlit.rb +3 -1
- data/lib/hamlit/attribute_builder.rb +12 -0
- data/lib/hamlit/cli.rb +44 -43
- data/lib/hamlit/compiler.rb +92 -16
- data/lib/hamlit/compiler/attribute_compiler.rb +148 -0
- data/lib/hamlit/compiler/children_compiler.rb +111 -0
- data/lib/hamlit/compiler/comment_compiler.rb +36 -0
- data/lib/hamlit/compiler/doctype_compiler.rb +45 -0
- data/lib/hamlit/compiler/script_compiler.rb +97 -0
- data/lib/hamlit/compiler/silent_script_compiler.rb +24 -0
- data/lib/hamlit/compiler/tag_compiler.rb +69 -0
- data/lib/hamlit/engine.rb +12 -7
- data/lib/hamlit/error.rb +14 -0
- data/lib/hamlit/escapable.rb +12 -0
- data/lib/hamlit/filters.rb +65 -0
- data/lib/hamlit/filters/base.rb +4 -62
- data/lib/hamlit/filters/coffee.rb +9 -7
- data/lib/hamlit/filters/css.rb +25 -8
- data/lib/hamlit/filters/erb.rb +4 -6
- data/lib/hamlit/filters/escaped.rb +11 -9
- data/lib/hamlit/filters/javascript.rb +25 -8
- data/lib/hamlit/filters/less.rb +9 -7
- data/lib/hamlit/filters/markdown.rb +5 -6
- data/lib/hamlit/filters/plain.rb +11 -15
- data/lib/hamlit/filters/preserve.rb +15 -5
- data/lib/hamlit/filters/ruby.rb +3 -5
- data/lib/hamlit/filters/sass.rb +9 -7
- data/lib/hamlit/filters/scss.rb +9 -7
- data/lib/hamlit/filters/text_base.rb +24 -0
- data/lib/hamlit/filters/tilt_base.rb +47 -0
- data/lib/hamlit/hash_parser.rb +107 -0
- data/lib/hamlit/html.rb +9 -6
- data/lib/hamlit/identity.rb +12 -0
- data/lib/hamlit/object_ref.rb +29 -0
- data/lib/hamlit/parser.rb +25 -142
- data/lib/hamlit/parser/MIT-LICENSE +20 -0
- data/lib/hamlit/parser/README.md +28 -0
- data/lib/hamlit/parser/haml_buffer.rb +348 -0
- data/lib/hamlit/parser/haml_compiler.rb +553 -0
- data/lib/hamlit/parser/haml_error.rb +61 -0
- data/lib/hamlit/parser/haml_helpers.rb +727 -0
- data/lib/hamlit/parser/haml_options.rb +286 -0
- data/lib/hamlit/parser/haml_parser.rb +801 -0
- data/lib/hamlit/parser/haml_util.rb +283 -0
- data/lib/hamlit/parser/haml_xss_mods.rb +109 -0
- data/lib/hamlit/{helpers.rb → rails_helpers.rb} +2 -7
- data/lib/hamlit/rails_template.rb +30 -0
- data/lib/hamlit/railtie.rb +1 -12
- data/lib/hamlit/ruby_expression.rb +31 -0
- data/lib/hamlit/static_analyzer.rb +49 -0
- data/lib/hamlit/string_interpolation.rb +69 -0
- data/lib/hamlit/template.rb +8 -0
- data/lib/hamlit/utils.rb +9 -0
- data/lib/hamlit/version.rb +1 -1
- metadata +116 -324
- data/.rspec +0 -2
- data/benchmarks/benchmark.rb +0 -110
- data/benchmarks/view.slim +0 -17
- data/doc/README.md +0 -19
- data/doc/engine/indent.md +0 -48
- data/doc/engine/new_attribute.md +0 -77
- data/doc/engine/old_attributes.md +0 -198
- data/doc/engine/silent_script.md +0 -97
- data/doc/engine/tag.md +0 -48
- data/doc/engine/text.md +0 -64
- data/doc/faml/README.md +0 -16
- data/doc/faml/engine/indent.md +0 -48
- data/doc/faml/engine/old_attributes.md +0 -111
- data/doc/faml/engine/silent_script.md +0 -97
- data/doc/faml/engine/text.md +0 -59
- data/doc/faml/filters/erb.md +0 -24
- data/doc/faml/filters/javascript.md +0 -27
- data/doc/faml/filters/less.md +0 -57
- data/doc/faml/filters/plain.md +0 -25
- data/doc/filters/erb.md +0 -31
- data/doc/filters/javascript.md +0 -83
- data/doc/filters/less.md +0 -57
- data/doc/filters/markdown.md +0 -31
- data/doc/filters/plain.md +0 -25
- data/doc/haml/README.md +0 -15
- data/doc/haml/engine/new_attribute.md +0 -77
- data/doc/haml/engine/old_attributes.md +0 -142
- data/doc/haml/engine/tag.md +0 -48
- data/doc/haml/engine/text.md +0 -29
- data/doc/haml/filters/erb.md +0 -26
- data/doc/haml/filters/javascript.md +0 -76
- data/doc/haml/filters/markdown.md +0 -31
- data/lib/hamlit/attribute.rb +0 -78
- data/lib/hamlit/compilers/attributes.rb +0 -108
- data/lib/hamlit/compilers/comment.rb +0 -13
- data/lib/hamlit/compilers/doctype.rb +0 -39
- data/lib/hamlit/compilers/filter.rb +0 -53
- data/lib/hamlit/compilers/new_attribute.rb +0 -115
- data/lib/hamlit/compilers/old_attribute.rb +0 -241
- data/lib/hamlit/compilers/runtime_attribute.rb +0 -58
- data/lib/hamlit/compilers/script.rb +0 -31
- data/lib/hamlit/compilers/strip.rb +0 -19
- data/lib/hamlit/compilers/text.rb +0 -111
- data/lib/hamlit/concerns/attribute_builder.rb +0 -22
- data/lib/hamlit/concerns/balanceable.rb +0 -68
- data/lib/hamlit/concerns/deprecation.rb +0 -20
- data/lib/hamlit/concerns/error.rb +0 -31
- data/lib/hamlit/concerns/escapable.rb +0 -17
- data/lib/hamlit/concerns/included.rb +0 -28
- data/lib/hamlit/concerns/indentable.rb +0 -117
- data/lib/hamlit/concerns/lexable.rb +0 -32
- data/lib/hamlit/concerns/line_reader.rb +0 -62
- data/lib/hamlit/concerns/registerable.rb +0 -24
- data/lib/hamlit/concerns/string_interpolation.rb +0 -48
- data/lib/hamlit/concerns/whitespace.rb +0 -91
- data/lib/hamlit/filters/tilt.rb +0 -41
- data/lib/hamlit/parsers/attribute.rb +0 -71
- data/lib/hamlit/parsers/comment.rb +0 -30
- data/lib/hamlit/parsers/doctype.rb +0 -18
- data/lib/hamlit/parsers/filter.rb +0 -18
- data/lib/hamlit/parsers/multiline.rb +0 -58
- data/lib/hamlit/parsers/script.rb +0 -126
- data/lib/hamlit/parsers/tag.rb +0 -83
- data/lib/hamlit/parsers/text.rb +0 -28
- data/lib/hamlit/temple.rb +0 -9
- data/release +0 -6
- data/spec/Rakefile +0 -72
- data/spec/hamlit/engine/comment_spec.rb +0 -56
- data/spec/hamlit/engine/doctype_spec.rb +0 -19
- data/spec/hamlit/engine/error_spec.rb +0 -135
- data/spec/hamlit/engine/indent_spec.rb +0 -42
- data/spec/hamlit/engine/multiline_spec.rb +0 -44
- data/spec/hamlit/engine/new_attribute_spec.rb +0 -110
- data/spec/hamlit/engine/old_attributes_spec.rb +0 -404
- data/spec/hamlit/engine/script_spec.rb +0 -116
- data/spec/hamlit/engine/silent_script_spec.rb +0 -213
- data/spec/hamlit/engine/tag_spec.rb +0 -295
- data/spec/hamlit/engine/text_spec.rb +0 -239
- data/spec/hamlit/engine_spec.rb +0 -58
- data/spec/hamlit/filters/coffee_spec.rb +0 -60
- data/spec/hamlit/filters/css_spec.rb +0 -33
- data/spec/hamlit/filters/erb_spec.rb +0 -16
- data/spec/hamlit/filters/javascript_spec.rb +0 -82
- data/spec/hamlit/filters/less_spec.rb +0 -37
- data/spec/hamlit/filters/markdown_spec.rb +0 -30
- data/spec/hamlit/filters/plain_spec.rb +0 -15
- data/spec/hamlit/filters/ruby_spec.rb +0 -24
- data/spec/hamlit/filters/sass_spec.rb +0 -33
- data/spec/hamlit/filters/scss_spec.rb +0 -37
- data/spec/hamlit/haml_spec.rb +0 -910
- data/spec/rails/.gitignore +0 -18
- data/spec/rails/.rspec +0 -2
- data/spec/rails/Gemfile +0 -19
- data/spec/rails/README.rdoc +0 -28
- data/spec/rails/Rakefile +0 -6
- data/spec/rails/app/assets/images/.keep +0 -0
- data/spec/rails/app/assets/javascripts/application.js +0 -15
- data/spec/rails/app/assets/stylesheets/application.css +0 -15
- data/spec/rails/app/controllers/application_controller.rb +0 -8
- data/spec/rails/app/controllers/concerns/.keep +0 -0
- data/spec/rails/app/controllers/users_controller.rb +0 -23
- data/spec/rails/app/helpers/application_helper.rb +0 -2
- data/spec/rails/app/mailers/.keep +0 -0
- data/spec/rails/app/models/.keep +0 -0
- data/spec/rails/app/models/concerns/.keep +0 -0
- data/spec/rails/app/views/application/index.html.haml +0 -18
- data/spec/rails/app/views/layouts/application.html.haml +0 -12
- data/spec/rails/app/views/users/capture.html.haml +0 -5
- data/spec/rails/app/views/users/capture_haml.html.haml +0 -5
- data/spec/rails/app/views/users/form.html.haml +0 -2
- data/spec/rails/app/views/users/helpers.html.haml +0 -10
- data/spec/rails/app/views/users/index.html.haml +0 -9
- data/spec/rails/app/views/users/inline.html.haml +0 -6
- data/spec/rails/app/views/users/old_attributes.html.haml +0 -5
- data/spec/rails/app/views/users/safe_buffer.html.haml +0 -4
- data/spec/rails/app/views/users/whitespace.html.haml +0 -4
- data/spec/rails/bin/bundle +0 -3
- data/spec/rails/bin/rails +0 -8
- data/spec/rails/bin/rake +0 -8
- data/spec/rails/bin/setup +0 -29
- data/spec/rails/bin/spring +0 -15
- data/spec/rails/config.ru +0 -4
- data/spec/rails/config/application.rb +0 -34
- data/spec/rails/config/boot.rb +0 -3
- data/spec/rails/config/database.yml +0 -25
- data/spec/rails/config/environment.rb +0 -5
- data/spec/rails/config/environments/development.rb +0 -41
- data/spec/rails/config/environments/production.rb +0 -79
- data/spec/rails/config/environments/test.rb +0 -42
- data/spec/rails/config/initializers/assets.rb +0 -11
- data/spec/rails/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/rails/config/initializers/cookies_serializer.rb +0 -3
- data/spec/rails/config/initializers/filter_parameter_logging.rb +0 -4
- data/spec/rails/config/initializers/inflections.rb +0 -16
- data/spec/rails/config/initializers/mime_types.rb +0 -4
- data/spec/rails/config/initializers/session_store.rb +0 -3
- data/spec/rails/config/initializers/wrap_parameters.rb +0 -14
- data/spec/rails/config/locales/en.yml +0 -24
- data/spec/rails/config/routes.rb +0 -16
- data/spec/rails/config/secrets.yml +0 -22
- data/spec/rails/db/schema.rb +0 -16
- data/spec/rails/db/seeds.rb +0 -7
- data/spec/rails/lib/assets/.keep +0 -0
- data/spec/rails/lib/tasks/.keep +0 -0
- data/spec/rails/log/.keep +0 -0
- data/spec/rails/public/404.html +0 -67
- data/spec/rails/public/422.html +0 -67
- data/spec/rails/public/500.html +0 -66
- data/spec/rails/public/favicon.ico +0 -0
- data/spec/rails/public/robots.txt +0 -5
- data/spec/rails/spec/hamlit_spec.rb +0 -123
- data/spec/rails/spec/rails_helper.rb +0 -56
- data/spec/rails/spec/spec_helper.rb +0 -91
- data/spec/rails/vendor/assets/javascripts/.keep +0 -0
- data/spec/rails/vendor/assets/stylesheets/.keep +0 -0
- data/spec/spec_helper.rb +0 -36
- data/spec/spec_helper/document_generator.rb +0 -93
- data/spec/spec_helper/render_helper.rb +0 -120
- data/spec/spec_helper/test_case.rb +0 -55
@@ -1,37 +0,0 @@
|
|
1
|
-
describe Hamlit::Filters::Less do
|
2
|
-
describe '#compile' do
|
3
|
-
it 'renders less filter' do
|
4
|
-
assert_render(<<-HAML, <<-HTML, compatible_only: :haml, error_with: :faml)
|
5
|
-
:less
|
6
|
-
.users_controller {
|
7
|
-
.show_action {
|
8
|
-
margin: 10px;
|
9
|
-
padding: 20px;
|
10
|
-
}
|
11
|
-
}
|
12
|
-
HAML
|
13
|
-
<style>
|
14
|
-
.users_controller .show_action {
|
15
|
-
margin: 10px;
|
16
|
-
padding: 20px;
|
17
|
-
}
|
18
|
-
</style>
|
19
|
-
HTML
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'parses string interpolation' do
|
23
|
-
assert_render(<<-'HAML', <<-HTML, compatible_only: :haml, error_with: :faml)
|
24
|
-
:less
|
25
|
-
.foo {
|
26
|
-
content: "#{'<&>'}";
|
27
|
-
}
|
28
|
-
HAML
|
29
|
-
<style>
|
30
|
-
.foo {
|
31
|
-
content: "<&>";
|
32
|
-
}
|
33
|
-
</style>
|
34
|
-
HTML
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
describe Hamlit::Filters::Markdown do
|
2
|
-
describe '#compile' do
|
3
|
-
it 'renders markdown filter' do
|
4
|
-
assert_render(<<-HAML, <<-HTML)
|
5
|
-
:markdown
|
6
|
-
# Hamlit
|
7
|
-
Yet another haml implementation
|
8
|
-
HAML
|
9
|
-
<h1>Hamlit</h1>
|
10
|
-
|
11
|
-
<p>Yet another haml implementation</p>
|
12
|
-
HTML
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'renders markdown filter with string interpolation' do
|
16
|
-
assert_render(<<-'HAML', <<-HTML, compatible_only: :faml)
|
17
|
-
- project = '<Hamlit>'
|
18
|
-
:markdown
|
19
|
-
# #{project}
|
20
|
-
#{'<&>'}
|
21
|
-
Yet another haml implementation
|
22
|
-
HAML
|
23
|
-
<h1><Hamlit></h1>
|
24
|
-
|
25
|
-
<p><&>
|
26
|
-
Yet another haml implementation</p>
|
27
|
-
HTML
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Hamlit::Filters::Ruby do
|
4
|
-
it 'renders ruby filter' do
|
5
|
-
assert_render(<<-HAML, <<-HTML)
|
6
|
-
:ruby
|
7
|
-
hello
|
8
|
-
HAML
|
9
|
-
hello
|
10
|
-
HTML
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'renders ruby filter' do
|
14
|
-
assert_render(<<-'HAML', <<-HTML)
|
15
|
-
:ruby
|
16
|
-
hash = {
|
17
|
-
a: "#{'<&>'}",
|
18
|
-
}
|
19
|
-
= hash[:a]
|
20
|
-
HAML
|
21
|
-
<&>
|
22
|
-
HTML
|
23
|
-
end
|
24
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
describe Hamlit::Filters::Sass do
|
2
|
-
describe '#compile' do
|
3
|
-
it 'renders sass filter' do
|
4
|
-
assert_render(<<-HAML, <<-HTML)
|
5
|
-
:sass
|
6
|
-
.users_controller
|
7
|
-
.show_action
|
8
|
-
margin: 10px
|
9
|
-
padding: 20px
|
10
|
-
HAML
|
11
|
-
<style>
|
12
|
-
.users_controller .show_action {
|
13
|
-
margin: 10px;
|
14
|
-
padding: 20px; }
|
15
|
-
</style>
|
16
|
-
HTML
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'renders sass filter with string interpolation' do
|
20
|
-
assert_render(<<-'HAML', <<-HTML)
|
21
|
-
:sass
|
22
|
-
.users_controller
|
23
|
-
.show_action
|
24
|
-
content: "#{'<&>'}"
|
25
|
-
HAML
|
26
|
-
<style>
|
27
|
-
.users_controller .show_action {
|
28
|
-
content: "<&>"; }
|
29
|
-
</style>
|
30
|
-
HTML
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
describe Hamlit::Filters::Scss do
|
2
|
-
describe '#compile' do
|
3
|
-
it 'renders scss filter' do
|
4
|
-
assert_render(<<-HAML, <<-HTML)
|
5
|
-
:scss
|
6
|
-
.users_controller {
|
7
|
-
.show_action {
|
8
|
-
margin: 10px;
|
9
|
-
padding: 20px;
|
10
|
-
}
|
11
|
-
}
|
12
|
-
HAML
|
13
|
-
<style>
|
14
|
-
.users_controller .show_action {
|
15
|
-
margin: 10px;
|
16
|
-
padding: 20px; }
|
17
|
-
</style>
|
18
|
-
HTML
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'parses string interpolation' do
|
22
|
-
assert_render(<<-'HAML', <<-HTML)
|
23
|
-
:scss
|
24
|
-
.users_controller {
|
25
|
-
.show_action {
|
26
|
-
content: "#{'<&>'}";
|
27
|
-
}
|
28
|
-
}
|
29
|
-
HAML
|
30
|
-
<style>
|
31
|
-
.users_controller .show_action {
|
32
|
-
content: "<&>"; }
|
33
|
-
</style>
|
34
|
-
HTML
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
data/spec/hamlit/haml_spec.rb
DELETED
@@ -1,910 +0,0 @@
|
|
1
|
-
require "haml"
|
2
|
-
|
3
|
-
# This is a spec converted by haml-spec.
|
4
|
-
# See: https://github.com/haml/haml-spec
|
5
|
-
describe "haml ugly mode with ecape_html" do
|
6
|
-
DEFAULT_OPTIONS = { ugly: true, escape_html: true }.freeze
|
7
|
-
|
8
|
-
def assert_haml(haml, locals, options)
|
9
|
-
engine = Haml::Engine.new(haml, DEFAULT_OPTIONS.merge(options))
|
10
|
-
hamlit = Hamlit::Template.new(options) { haml }
|
11
|
-
expect(hamlit.render(Object.new, locals)).to eq(engine.render(Object.new, locals))
|
12
|
-
end
|
13
|
-
|
14
|
-
context "headers" do
|
15
|
-
specify "an XHTML XML prolog" do
|
16
|
-
haml = %q{!!! XML}
|
17
|
-
html = %q{<?xml version='1.0' encoding='utf-8' ?>}
|
18
|
-
locals = {}
|
19
|
-
options = {:format=>:xhtml}
|
20
|
-
assert_haml(haml, locals, options)
|
21
|
-
end
|
22
|
-
|
23
|
-
specify "an XHTML default (transitional) doctype" do
|
24
|
-
haml = %q{!!!}
|
25
|
-
html = %q{<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">}
|
26
|
-
locals = {}
|
27
|
-
options = {:format=>:xhtml}
|
28
|
-
assert_haml(haml, locals, options)
|
29
|
-
end
|
30
|
-
|
31
|
-
specify "an XHTML 1.1 doctype" do
|
32
|
-
haml = %q{!!! 1.1}
|
33
|
-
html = %q{<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">}
|
34
|
-
locals = {}
|
35
|
-
options = {:format=>:xhtml}
|
36
|
-
assert_haml(haml, locals, options)
|
37
|
-
end
|
38
|
-
|
39
|
-
specify "an XHTML 1.2 mobile doctype" do
|
40
|
-
haml = %q{!!! mobile}
|
41
|
-
html = %q{<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.2//EN" "http://www.openmobilealliance.org/tech/DTD/xhtml-mobile12.dtd">}
|
42
|
-
locals = {}
|
43
|
-
options = {:format=>:xhtml}
|
44
|
-
assert_haml(haml, locals, options)
|
45
|
-
end
|
46
|
-
|
47
|
-
specify "an XHTML 1.1 basic doctype" do
|
48
|
-
haml = %q{!!! basic}
|
49
|
-
html = %q{<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd">}
|
50
|
-
locals = {}
|
51
|
-
options = {:format=>:xhtml}
|
52
|
-
assert_haml(haml, locals, options)
|
53
|
-
end
|
54
|
-
|
55
|
-
specify "an XHTML 1.0 frameset doctype" do
|
56
|
-
haml = %q{!!! frameset}
|
57
|
-
html = %q{<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">}
|
58
|
-
locals = {}
|
59
|
-
options = {:format=>:xhtml}
|
60
|
-
assert_haml(haml, locals, options)
|
61
|
-
end
|
62
|
-
|
63
|
-
specify "an HTML 5 doctype with XHTML syntax" do
|
64
|
-
haml = %q{!!! 5}
|
65
|
-
html = %q{<!DOCTYPE html>}
|
66
|
-
locals = {}
|
67
|
-
options = {:format=>:xhtml}
|
68
|
-
assert_haml(haml, locals, options)
|
69
|
-
end
|
70
|
-
|
71
|
-
specify "an HTML 5 XML prolog (silent)" do
|
72
|
-
haml = %q{!!! XML}
|
73
|
-
html = %q{}
|
74
|
-
locals = {}
|
75
|
-
options = {:format=>:html5}
|
76
|
-
assert_haml(haml, locals, options)
|
77
|
-
end
|
78
|
-
|
79
|
-
specify "an HTML 5 doctype" do
|
80
|
-
haml = %q{!!!}
|
81
|
-
html = %q{<!DOCTYPE html>}
|
82
|
-
locals = {}
|
83
|
-
options = {:format=>:html5}
|
84
|
-
assert_haml(haml, locals, options)
|
85
|
-
end
|
86
|
-
|
87
|
-
specify "an HTML 4 XML prolog (silent)" do
|
88
|
-
haml = %q{!!! XML}
|
89
|
-
html = %q{}
|
90
|
-
locals = {}
|
91
|
-
options = {:format=>:html4}
|
92
|
-
assert_haml(haml, locals, options)
|
93
|
-
end
|
94
|
-
|
95
|
-
specify "an HTML 4 default (transitional) doctype" do
|
96
|
-
haml = %q{!!!}
|
97
|
-
html = %q{<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">}
|
98
|
-
locals = {}
|
99
|
-
options = {:format=>:html4}
|
100
|
-
assert_haml(haml, locals, options)
|
101
|
-
end
|
102
|
-
|
103
|
-
specify "an HTML 4 frameset doctype" do
|
104
|
-
haml = %q{!!! frameset}
|
105
|
-
html = %q{<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">}
|
106
|
-
locals = {}
|
107
|
-
options = {:format=>:html4}
|
108
|
-
assert_haml(haml, locals, options)
|
109
|
-
end
|
110
|
-
|
111
|
-
specify "an HTML 4 strict doctype" do
|
112
|
-
haml = %q{!!! strict}
|
113
|
-
html = %q{<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">}
|
114
|
-
locals = {}
|
115
|
-
options = {:format=>:html4}
|
116
|
-
assert_haml(haml, locals, options)
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
context "basic Haml tags and CSS" do
|
121
|
-
specify "a simple Haml tag" do
|
122
|
-
haml = %q{%p}
|
123
|
-
html = %q{<p></p>}
|
124
|
-
locals = {}
|
125
|
-
options = {}
|
126
|
-
assert_haml(haml, locals, options)
|
127
|
-
end
|
128
|
-
|
129
|
-
specify "a self-closing tag (XHTML)" do
|
130
|
-
haml = %q{%meta}
|
131
|
-
html = %q{<meta />}
|
132
|
-
locals = {}
|
133
|
-
options = {:format=>:xhtml}
|
134
|
-
assert_haml(haml, locals, options)
|
135
|
-
end
|
136
|
-
|
137
|
-
specify "a self-closing tag (HTML4)" do
|
138
|
-
haml = %q{%meta}
|
139
|
-
html = %q{<meta>}
|
140
|
-
locals = {}
|
141
|
-
options = {:format=>:html4}
|
142
|
-
assert_haml(haml, locals, options)
|
143
|
-
end
|
144
|
-
|
145
|
-
specify "a self-closing tag (HTML5)" do
|
146
|
-
haml = %q{%meta}
|
147
|
-
html = %q{<meta>}
|
148
|
-
locals = {}
|
149
|
-
options = {:format=>:html5}
|
150
|
-
assert_haml(haml, locals, options)
|
151
|
-
end
|
152
|
-
|
153
|
-
specify "a self-closing tag ('/' modifier + XHTML)" do
|
154
|
-
haml = %q{%zzz/}
|
155
|
-
html = %q{<zzz />}
|
156
|
-
locals = {}
|
157
|
-
options = {:format=>:xhtml}
|
158
|
-
assert_haml(haml, locals, options)
|
159
|
-
end
|
160
|
-
|
161
|
-
specify "a self-closing tag ('/' modifier + HTML5)" do
|
162
|
-
haml = %q{%zzz/}
|
163
|
-
html = %q{<zzz>}
|
164
|
-
locals = {}
|
165
|
-
options = {:format=>:html5}
|
166
|
-
assert_haml(haml, locals, options)
|
167
|
-
end
|
168
|
-
|
169
|
-
specify "a tag with a CSS class" do
|
170
|
-
haml = %q{%p.class1}
|
171
|
-
html = %q{<p class='class1'></p>}
|
172
|
-
locals = {}
|
173
|
-
options = {}
|
174
|
-
assert_haml(haml, locals, options)
|
175
|
-
end
|
176
|
-
|
177
|
-
specify "a tag with multiple CSS classes" do
|
178
|
-
haml = %q{%p.class1.class2}
|
179
|
-
html = %q{<p class='class1 class2'></p>}
|
180
|
-
locals = {}
|
181
|
-
options = {}
|
182
|
-
assert_haml(haml, locals, options)
|
183
|
-
end
|
184
|
-
|
185
|
-
specify "a tag with a CSS id" do
|
186
|
-
haml = %q{%p#id1}
|
187
|
-
html = %q{<p id='id1'></p>}
|
188
|
-
locals = {}
|
189
|
-
options = {}
|
190
|
-
assert_haml(haml, locals, options)
|
191
|
-
end
|
192
|
-
|
193
|
-
specify "a tag with multiple CSS id's" do
|
194
|
-
haml = %q{%p#id1#id2}
|
195
|
-
html = %q{<p id='id2'></p>}
|
196
|
-
locals = {}
|
197
|
-
options = {}
|
198
|
-
assert_haml(haml, locals, options)
|
199
|
-
end
|
200
|
-
|
201
|
-
specify "a tag with a class followed by an id" do
|
202
|
-
haml = %q{%p.class1#id1}
|
203
|
-
html = %q{<p class='class1' id='id1'></p>}
|
204
|
-
locals = {}
|
205
|
-
options = {}
|
206
|
-
assert_haml(haml, locals, options)
|
207
|
-
end
|
208
|
-
|
209
|
-
specify "a tag with an id followed by a class" do
|
210
|
-
haml = %q{%p#id1.class1}
|
211
|
-
html = %q{<p class='class1' id='id1'></p>}
|
212
|
-
locals = {}
|
213
|
-
options = {}
|
214
|
-
assert_haml(haml, locals, options)
|
215
|
-
end
|
216
|
-
|
217
|
-
specify "an implicit div with a CSS id" do
|
218
|
-
haml = %q{#id1}
|
219
|
-
html = %q{<div id='id1'></div>}
|
220
|
-
locals = {}
|
221
|
-
options = {}
|
222
|
-
assert_haml(haml, locals, options)
|
223
|
-
end
|
224
|
-
|
225
|
-
specify "an implicit div with a CSS class" do
|
226
|
-
haml = %q{.class1}
|
227
|
-
html = %q{<div class='class1'></div>}
|
228
|
-
locals = {}
|
229
|
-
options = {}
|
230
|
-
assert_haml(haml, locals, options)
|
231
|
-
end
|
232
|
-
|
233
|
-
specify "multiple simple Haml tags" do
|
234
|
-
haml = %q{%div
|
235
|
-
%div
|
236
|
-
%p}
|
237
|
-
html = %q{<div>
|
238
|
-
<div>
|
239
|
-
<p></p>
|
240
|
-
</div>
|
241
|
-
</div>}
|
242
|
-
locals = {}
|
243
|
-
options = {}
|
244
|
-
assert_haml(haml, locals, options)
|
245
|
-
end
|
246
|
-
end
|
247
|
-
|
248
|
-
context "tags with unusual HTML characters" do
|
249
|
-
specify "a tag with colons" do
|
250
|
-
haml = %q{%ns:tag}
|
251
|
-
html = %q{<ns:tag></ns:tag>}
|
252
|
-
locals = {}
|
253
|
-
options = {}
|
254
|
-
assert_haml(haml, locals, options)
|
255
|
-
end
|
256
|
-
|
257
|
-
specify "a tag with underscores" do
|
258
|
-
haml = %q{%snake_case}
|
259
|
-
html = %q{<snake_case></snake_case>}
|
260
|
-
locals = {}
|
261
|
-
options = {}
|
262
|
-
assert_haml(haml, locals, options)
|
263
|
-
end
|
264
|
-
|
265
|
-
specify "a tag with dashes" do
|
266
|
-
haml = %q{%dashed-tag}
|
267
|
-
html = %q{<dashed-tag></dashed-tag>}
|
268
|
-
locals = {}
|
269
|
-
options = {}
|
270
|
-
assert_haml(haml, locals, options)
|
271
|
-
end
|
272
|
-
|
273
|
-
specify "a tag with camelCase" do
|
274
|
-
haml = %q{%camelCase}
|
275
|
-
html = %q{<camelCase></camelCase>}
|
276
|
-
locals = {}
|
277
|
-
options = {}
|
278
|
-
assert_haml(haml, locals, options)
|
279
|
-
end
|
280
|
-
|
281
|
-
specify "a tag with PascalCase" do
|
282
|
-
haml = %q{%PascalCase}
|
283
|
-
html = %q{<PascalCase></PascalCase>}
|
284
|
-
locals = {}
|
285
|
-
options = {}
|
286
|
-
assert_haml(haml, locals, options)
|
287
|
-
end
|
288
|
-
end
|
289
|
-
|
290
|
-
context "tags with unusual CSS identifiers" do
|
291
|
-
specify "an all-numeric class" do
|
292
|
-
haml = %q{.123}
|
293
|
-
html = %q{<div class='123'></div>}
|
294
|
-
locals = {}
|
295
|
-
options = {}
|
296
|
-
assert_haml(haml, locals, options)
|
297
|
-
end
|
298
|
-
|
299
|
-
specify "a class with underscores" do
|
300
|
-
haml = %q{.__}
|
301
|
-
html = %q{<div class='__'></div>}
|
302
|
-
locals = {}
|
303
|
-
options = {}
|
304
|
-
assert_haml(haml, locals, options)
|
305
|
-
end
|
306
|
-
|
307
|
-
specify "a class with dashes" do
|
308
|
-
haml = %q{.--}
|
309
|
-
html = %q{<div class='--'></div>}
|
310
|
-
locals = {}
|
311
|
-
options = {}
|
312
|
-
assert_haml(haml, locals, options)
|
313
|
-
end
|
314
|
-
end
|
315
|
-
|
316
|
-
context "tags with inline content" do
|
317
|
-
specify "Inline content simple tag" do
|
318
|
-
haml = %q{%p hello}
|
319
|
-
html = %q{<p>hello</p>}
|
320
|
-
locals = {}
|
321
|
-
options = {}
|
322
|
-
assert_haml(haml, locals, options)
|
323
|
-
end
|
324
|
-
|
325
|
-
specify "Inline content tag with CSS" do
|
326
|
-
haml = %q{%p.class1 hello}
|
327
|
-
html = %q{<p class='class1'>hello</p>}
|
328
|
-
locals = {}
|
329
|
-
options = {}
|
330
|
-
assert_haml(haml, locals, options)
|
331
|
-
end
|
332
|
-
|
333
|
-
specify "Inline content multiple simple tags" do
|
334
|
-
haml = %q{%div
|
335
|
-
%div
|
336
|
-
%p text}
|
337
|
-
html = %q{<div>
|
338
|
-
<div>
|
339
|
-
<p>text</p>
|
340
|
-
</div>
|
341
|
-
</div>}
|
342
|
-
locals = {}
|
343
|
-
options = {}
|
344
|
-
assert_haml(haml, locals, options)
|
345
|
-
end
|
346
|
-
end
|
347
|
-
|
348
|
-
context "tags with nested content" do
|
349
|
-
specify "Nested content simple tag" do
|
350
|
-
haml = %q{%p
|
351
|
-
hello}
|
352
|
-
html = %q{<p>
|
353
|
-
hello
|
354
|
-
</p>}
|
355
|
-
locals = {}
|
356
|
-
options = {}
|
357
|
-
assert_haml(haml, locals, options)
|
358
|
-
end
|
359
|
-
|
360
|
-
specify "Nested content tag with CSS" do
|
361
|
-
haml = %q{%p.class1
|
362
|
-
hello}
|
363
|
-
html = %q{<p class='class1'>
|
364
|
-
hello
|
365
|
-
</p>}
|
366
|
-
locals = {}
|
367
|
-
options = {}
|
368
|
-
assert_haml(haml, locals, options)
|
369
|
-
end
|
370
|
-
|
371
|
-
specify "Nested content multiple simple tags" do
|
372
|
-
haml = %q{%div
|
373
|
-
%div
|
374
|
-
%p
|
375
|
-
text}
|
376
|
-
html = %q{<div>
|
377
|
-
<div>
|
378
|
-
<p>
|
379
|
-
text
|
380
|
-
</p>
|
381
|
-
</div>
|
382
|
-
</div>}
|
383
|
-
locals = {}
|
384
|
-
options = {}
|
385
|
-
assert_haml(haml, locals, options)
|
386
|
-
end
|
387
|
-
end
|
388
|
-
|
389
|
-
context "tags with HTML-style attributes" do
|
390
|
-
specify "HTML-style one attribute" do
|
391
|
-
haml = %q{%p(a='b')}
|
392
|
-
html = %q{<p a='b'></p>}
|
393
|
-
locals = {}
|
394
|
-
options = {}
|
395
|
-
assert_haml(haml, locals, options)
|
396
|
-
end
|
397
|
-
|
398
|
-
specify "HTML-style multiple attributes" do
|
399
|
-
haml = %q{%p(a='b' c='d')}
|
400
|
-
html = %q{<p a='b' c='d'></p>}
|
401
|
-
locals = {}
|
402
|
-
options = {}
|
403
|
-
assert_haml(haml, locals, options)
|
404
|
-
end
|
405
|
-
|
406
|
-
specify "HTML-style attributes separated with newlines" do
|
407
|
-
haml = %q{%p(a='b'
|
408
|
-
c='d')}
|
409
|
-
html = %q{<p a='b' c='d'></p>}
|
410
|
-
locals = {}
|
411
|
-
options = {}
|
412
|
-
assert_haml(haml, locals, options)
|
413
|
-
end
|
414
|
-
|
415
|
-
specify "HTML-style interpolated attribute" do
|
416
|
-
haml = %q{%p(a="#{var}")}
|
417
|
-
html = %q{<p a='value'></p>}
|
418
|
-
locals = {:var=>"value"}
|
419
|
-
options = {}
|
420
|
-
assert_haml(haml, locals, options)
|
421
|
-
end
|
422
|
-
|
423
|
-
specify "HTML-style 'class' as an attribute" do
|
424
|
-
haml = %q{%p(class='class1')}
|
425
|
-
html = %q{<p class='class1'></p>}
|
426
|
-
locals = {}
|
427
|
-
options = {}
|
428
|
-
assert_haml(haml, locals, options)
|
429
|
-
end
|
430
|
-
|
431
|
-
specify "HTML-style tag with a CSS class and 'class' as an attribute" do
|
432
|
-
haml = %q{%p.class2(class='class1')}
|
433
|
-
html = %q{<p class='class1 class2'></p>}
|
434
|
-
locals = {}
|
435
|
-
options = {}
|
436
|
-
assert_haml(haml, locals, options)
|
437
|
-
end
|
438
|
-
|
439
|
-
specify "HTML-style tag with 'id' as an attribute" do
|
440
|
-
haml = %q{%p(id='1')}
|
441
|
-
html = %q{<p id='1'></p>}
|
442
|
-
locals = {}
|
443
|
-
options = {}
|
444
|
-
assert_haml(haml, locals, options)
|
445
|
-
end
|
446
|
-
|
447
|
-
specify "HTML-style tag with a CSS id and 'id' as an attribute" do
|
448
|
-
haml = %q{%p#id(id='1')}
|
449
|
-
html = %q{<p id='id_1'></p>}
|
450
|
-
locals = {}
|
451
|
-
options = {}
|
452
|
-
assert_haml(haml, locals, options)
|
453
|
-
end
|
454
|
-
|
455
|
-
specify "HTML-style tag with a variable attribute" do
|
456
|
-
haml = %q{%p(class=var)}
|
457
|
-
html = %q{<p class='hello'></p>}
|
458
|
-
locals = {:var=>"hello"}
|
459
|
-
options = {}
|
460
|
-
assert_haml(haml, locals, options)
|
461
|
-
end
|
462
|
-
|
463
|
-
specify "HTML-style tag with a CSS class and 'class' as a variable attribute" do
|
464
|
-
haml = %q{.hello(class=var)}
|
465
|
-
html = %q{<div class='hello world'></div>}
|
466
|
-
locals = {:var=>"world"}
|
467
|
-
options = {}
|
468
|
-
assert_haml(haml, locals, options)
|
469
|
-
end
|
470
|
-
|
471
|
-
specify "HTML-style tag multiple CSS classes (sorted correctly)" do
|
472
|
-
haml = %q{.z(class=var)}
|
473
|
-
html = %q{<div class='a z'></div>}
|
474
|
-
locals = {:var=>"a"}
|
475
|
-
options = {}
|
476
|
-
assert_haml(haml, locals, options)
|
477
|
-
end
|
478
|
-
|
479
|
-
specify "HTML-style tag with an atomic attribute" do
|
480
|
-
haml = %q{%a(flag)}
|
481
|
-
html = %q{<a flag></a>}
|
482
|
-
locals = {}
|
483
|
-
options = {}
|
484
|
-
assert_haml(haml, locals, options)
|
485
|
-
end
|
486
|
-
end
|
487
|
-
|
488
|
-
context "tags with Ruby-style attributes" do
|
489
|
-
specify "Ruby-style one attribute" do
|
490
|
-
haml = %q{%p{:a => 'b'}}
|
491
|
-
html = %q{<p a='b'></p>}
|
492
|
-
locals = {}
|
493
|
-
options = {}
|
494
|
-
assert_haml(haml, locals, options)
|
495
|
-
end
|
496
|
-
|
497
|
-
specify "Ruby-style attributes hash with whitespace" do
|
498
|
-
haml = %q{%p{ :a => 'b' }}
|
499
|
-
html = %q{<p a='b'></p>}
|
500
|
-
locals = {}
|
501
|
-
options = {}
|
502
|
-
assert_haml(haml, locals, options)
|
503
|
-
end
|
504
|
-
|
505
|
-
specify "Ruby-style interpolated attribute" do
|
506
|
-
haml = %q{%p{:a =>"#{var}"}}
|
507
|
-
html = %q{<p a='value'></p>}
|
508
|
-
locals = {:var=>"value"}
|
509
|
-
options = {}
|
510
|
-
assert_haml(haml, locals, options)
|
511
|
-
end
|
512
|
-
|
513
|
-
specify "Ruby-style multiple attributes" do
|
514
|
-
haml = %q{%p{ :a => 'b', 'c' => 'd' }}
|
515
|
-
html = %q{<p a='b' c='d'></p>}
|
516
|
-
locals = {}
|
517
|
-
options = {}
|
518
|
-
assert_haml(haml, locals, options)
|
519
|
-
end
|
520
|
-
|
521
|
-
specify "Ruby-style attributes separated with newlines" do
|
522
|
-
haml = %q{%p{ :a => 'b',
|
523
|
-
'c' => 'd' }}
|
524
|
-
html = %q{<p a='b' c='d'></p>}
|
525
|
-
locals = {}
|
526
|
-
options = {}
|
527
|
-
assert_haml(haml, locals, options)
|
528
|
-
end
|
529
|
-
|
530
|
-
specify "Ruby-style 'class' as an attribute" do
|
531
|
-
haml = %q{%p{:class => 'class1'}}
|
532
|
-
html = %q{<p class='class1'></p>}
|
533
|
-
locals = {}
|
534
|
-
options = {}
|
535
|
-
assert_haml(haml, locals, options)
|
536
|
-
end
|
537
|
-
|
538
|
-
specify "Ruby-style tag with a CSS class and 'class' as an attribute" do
|
539
|
-
haml = %q{%p.class2{:class => 'class1'}}
|
540
|
-
html = %q{<p class='class1 class2'></p>}
|
541
|
-
locals = {}
|
542
|
-
options = {}
|
543
|
-
assert_haml(haml, locals, options)
|
544
|
-
end
|
545
|
-
|
546
|
-
specify "Ruby-style tag with 'id' as an attribute" do
|
547
|
-
haml = %q{%p{:id => '1'}}
|
548
|
-
html = %q{<p id='1'></p>}
|
549
|
-
locals = {}
|
550
|
-
options = {}
|
551
|
-
assert_haml(haml, locals, options)
|
552
|
-
end
|
553
|
-
|
554
|
-
specify "Ruby-style tag with a CSS id and 'id' as an attribute" do
|
555
|
-
haml = %q{%p#id{:id => '1'}}
|
556
|
-
html = %q{<p id='id_1'></p>}
|
557
|
-
locals = {}
|
558
|
-
options = {}
|
559
|
-
assert_haml(haml, locals, options)
|
560
|
-
end
|
561
|
-
|
562
|
-
specify "Ruby-style tag with a CSS id and a numeric 'id' as an attribute" do
|
563
|
-
haml = %q{%p#id{:id => 1}}
|
564
|
-
html = %q{<p id='id_1'></p>}
|
565
|
-
locals = {}
|
566
|
-
options = {}
|
567
|
-
assert_haml(haml, locals, options)
|
568
|
-
end
|
569
|
-
|
570
|
-
specify "Ruby-style tag with a variable attribute" do
|
571
|
-
haml = %q{%p{:class => var}}
|
572
|
-
html = %q{<p class='hello'></p>}
|
573
|
-
locals = {:var=>"hello"}
|
574
|
-
options = {}
|
575
|
-
assert_haml(haml, locals, options)
|
576
|
-
end
|
577
|
-
|
578
|
-
specify "Ruby-style tag with a CSS class and 'class' as a variable attribute" do
|
579
|
-
haml = %q{.hello{:class => var}}
|
580
|
-
html = %q{<div class='hello world'></div>}
|
581
|
-
locals = {:var=>"world"}
|
582
|
-
options = {}
|
583
|
-
assert_haml(haml, locals, options)
|
584
|
-
end
|
585
|
-
|
586
|
-
specify "Ruby-style tag multiple CSS classes (sorted correctly)" do
|
587
|
-
haml = %q{.z{:class => var}}
|
588
|
-
html = %q{<div class='a z'></div>}
|
589
|
-
locals = {:var=>"a"}
|
590
|
-
options = {}
|
591
|
-
assert_haml(haml, locals, options)
|
592
|
-
end
|
593
|
-
end
|
594
|
-
|
595
|
-
context "silent comments" do
|
596
|
-
specify "an inline silent comment" do
|
597
|
-
haml = %q{-# hello}
|
598
|
-
html = %q{}
|
599
|
-
locals = {}
|
600
|
-
options = {}
|
601
|
-
assert_haml(haml, locals, options)
|
602
|
-
end
|
603
|
-
|
604
|
-
specify "a nested silent comment" do
|
605
|
-
haml = %q{-#
|
606
|
-
hello}
|
607
|
-
html = %q{}
|
608
|
-
locals = {}
|
609
|
-
options = {}
|
610
|
-
assert_haml(haml, locals, options)
|
611
|
-
end
|
612
|
-
|
613
|
-
specify "a multiply nested silent comment" do
|
614
|
-
haml = %q{-#
|
615
|
-
%div
|
616
|
-
foo}
|
617
|
-
html = %q{}
|
618
|
-
locals = {}
|
619
|
-
options = {}
|
620
|
-
assert_haml(haml, locals, options)
|
621
|
-
end
|
622
|
-
|
623
|
-
specify "a multiply nested silent comment with inconsistent indents" do
|
624
|
-
haml = %q{-#
|
625
|
-
%div
|
626
|
-
foo}
|
627
|
-
html = %q{}
|
628
|
-
locals = {}
|
629
|
-
options = {}
|
630
|
-
assert_haml(haml, locals, options)
|
631
|
-
end
|
632
|
-
end
|
633
|
-
|
634
|
-
context "markup comments" do
|
635
|
-
specify "an inline markup comment" do
|
636
|
-
haml = %q{/ comment}
|
637
|
-
html = %q{<!-- comment -->}
|
638
|
-
locals = {}
|
639
|
-
options = {}
|
640
|
-
assert_haml(haml, locals, options)
|
641
|
-
end
|
642
|
-
|
643
|
-
specify "a nested markup comment" do
|
644
|
-
haml = %q{/
|
645
|
-
comment
|
646
|
-
comment2}
|
647
|
-
html = %q{<!--
|
648
|
-
comment
|
649
|
-
comment2
|
650
|
-
-->}
|
651
|
-
locals = {}
|
652
|
-
options = {}
|
653
|
-
assert_haml(haml, locals, options)
|
654
|
-
end
|
655
|
-
end
|
656
|
-
|
657
|
-
context "conditional comments" do
|
658
|
-
specify "a conditional comment" do
|
659
|
-
haml = %q{/[if IE]
|
660
|
-
%p a}
|
661
|
-
html = %q{<!--[if IE]>
|
662
|
-
<p>a</p>
|
663
|
-
<![endif]-->}
|
664
|
-
locals = {}
|
665
|
-
options = {}
|
666
|
-
assert_haml(haml, locals, options)
|
667
|
-
end
|
668
|
-
end
|
669
|
-
|
670
|
-
context "internal filters" do
|
671
|
-
specify "content in an 'escaped' filter" do
|
672
|
-
haml = %q{:escaped
|
673
|
-
<&">}
|
674
|
-
html = %q{<&">}
|
675
|
-
locals = {}
|
676
|
-
options = {}
|
677
|
-
assert_haml(haml, locals, options)
|
678
|
-
end
|
679
|
-
|
680
|
-
specify "content in a 'preserve' filter" do
|
681
|
-
haml = %q{:preserve
|
682
|
-
hello
|
683
|
-
|
684
|
-
%p}
|
685
|
-
html = %q{hello

|
686
|
-
<p></p>}
|
687
|
-
locals = {}
|
688
|
-
options = {}
|
689
|
-
assert_haml(haml, locals, options)
|
690
|
-
end
|
691
|
-
|
692
|
-
specify "content in a 'plain' filter" do
|
693
|
-
haml = %q{:plain
|
694
|
-
hello
|
695
|
-
|
696
|
-
%p}
|
697
|
-
html = %q{hello
|
698
|
-
<p></p>}
|
699
|
-
locals = {}
|
700
|
-
options = {}
|
701
|
-
assert_haml(haml, locals, options)
|
702
|
-
end
|
703
|
-
|
704
|
-
specify "content in a 'css' filter (XHTML)" do
|
705
|
-
haml = %q{:css
|
706
|
-
hello
|
707
|
-
|
708
|
-
%p}
|
709
|
-
html = %q{<style type='text/css'>
|
710
|
-
/*<![CDATA[*/
|
711
|
-
hello
|
712
|
-
/*]]>*/
|
713
|
-
</style>
|
714
|
-
<p></p>}
|
715
|
-
locals = {}
|
716
|
-
options = {:format=>:xhtml}
|
717
|
-
assert_haml(haml, locals, options)
|
718
|
-
end
|
719
|
-
|
720
|
-
specify "content in a 'javascript' filter (XHTML)" do
|
721
|
-
haml = %q{:javascript
|
722
|
-
a();
|
723
|
-
%p}
|
724
|
-
html = %q{<script type='text/javascript'>
|
725
|
-
//<![CDATA[
|
726
|
-
a();
|
727
|
-
//]]>
|
728
|
-
</script>
|
729
|
-
<p></p>}
|
730
|
-
locals = {}
|
731
|
-
options = {:format=>:xhtml}
|
732
|
-
assert_haml(haml, locals, options)
|
733
|
-
end
|
734
|
-
|
735
|
-
specify "content in a 'css' filter (HTML)" do
|
736
|
-
haml = %q{:css
|
737
|
-
hello
|
738
|
-
|
739
|
-
%p}
|
740
|
-
html = %q{<style>
|
741
|
-
hello
|
742
|
-
</style>
|
743
|
-
<p></p>}
|
744
|
-
locals = {}
|
745
|
-
options = {:format=>:html5}
|
746
|
-
assert_haml(haml, locals, options)
|
747
|
-
end
|
748
|
-
|
749
|
-
specify "content in a 'javascript' filter (HTML)" do
|
750
|
-
haml = %q{:javascript
|
751
|
-
a();
|
752
|
-
%p}
|
753
|
-
html = %q{<script>
|
754
|
-
a();
|
755
|
-
</script>
|
756
|
-
<p></p>}
|
757
|
-
locals = {}
|
758
|
-
options = {:format=>:html5}
|
759
|
-
assert_haml(haml, locals, options)
|
760
|
-
end
|
761
|
-
end
|
762
|
-
|
763
|
-
context "Ruby-style interpolation" do
|
764
|
-
specify "interpolation inside inline content" do
|
765
|
-
haml = %q{%p #{var}}
|
766
|
-
html = %q{<p>value</p>}
|
767
|
-
locals = {:var=>"value"}
|
768
|
-
options = {}
|
769
|
-
assert_haml(haml, locals, options)
|
770
|
-
end
|
771
|
-
|
772
|
-
specify "no interpolation when escaped" do
|
773
|
-
haml = %q{%p \#{var}}
|
774
|
-
html = %q{<p>#{var}</p>}
|
775
|
-
locals = {:var=>"value"}
|
776
|
-
options = {}
|
777
|
-
assert_haml(haml, locals, options)
|
778
|
-
end
|
779
|
-
|
780
|
-
specify "interpolation when the escape character is escaped" do
|
781
|
-
haml = %q{%p \\#{var}}
|
782
|
-
html = %q{<p>\value</p>}
|
783
|
-
locals = {:var=>"value"}
|
784
|
-
options = {}
|
785
|
-
assert_haml(haml, locals, options)
|
786
|
-
end
|
787
|
-
|
788
|
-
specify "interpolation inside filtered content" do
|
789
|
-
haml = %q{:plain
|
790
|
-
#{var} interpolated: #{var}}
|
791
|
-
html = %q{value interpolated: value}
|
792
|
-
locals = {:var=>"value"}
|
793
|
-
options = {}
|
794
|
-
assert_haml(haml, locals, options)
|
795
|
-
end
|
796
|
-
end
|
797
|
-
|
798
|
-
context "HTML escaping" do
|
799
|
-
specify "code following '&='" do
|
800
|
-
haml = %q{&= '<"&>'}
|
801
|
-
html = %q{<"&>}
|
802
|
-
locals = {}
|
803
|
-
options = {}
|
804
|
-
assert_haml(haml, locals, options)
|
805
|
-
end
|
806
|
-
|
807
|
-
specify "code following '=' when escape_haml is set to true" do
|
808
|
-
haml = %q{= '<"&>'}
|
809
|
-
html = %q{<"&>}
|
810
|
-
locals = {}
|
811
|
-
options = {:escape_html=>"true"}
|
812
|
-
assert_haml(haml, locals, options)
|
813
|
-
end
|
814
|
-
|
815
|
-
specify "code following '!=' when escape_haml is set to true" do
|
816
|
-
haml = %q{!= '<"&>'}
|
817
|
-
html = %q{<"&>}
|
818
|
-
locals = {}
|
819
|
-
options = {:escape_html=>"true"}
|
820
|
-
assert_haml(haml, locals, options)
|
821
|
-
end
|
822
|
-
end
|
823
|
-
|
824
|
-
context "boolean attributes" do
|
825
|
-
specify "boolean attribute with XHTML" do
|
826
|
-
haml = %q{%input(checked=true)}
|
827
|
-
html = %q{<input checked='checked' />}
|
828
|
-
locals = {}
|
829
|
-
options = {:format=>:xhtml}
|
830
|
-
assert_haml(haml, locals, options)
|
831
|
-
end
|
832
|
-
|
833
|
-
specify "boolean attribute with HTML" do
|
834
|
-
haml = %q{%input(checked=true)}
|
835
|
-
html = %q{<input checked>}
|
836
|
-
locals = {}
|
837
|
-
options = {:format=>:html5}
|
838
|
-
assert_haml(haml, locals, options)
|
839
|
-
end
|
840
|
-
end
|
841
|
-
|
842
|
-
context "whitespace preservation" do
|
843
|
-
specify "following the '~' operator" do
|
844
|
-
haml = %q{~ "Foo\n<pre>Bar\nBaz</pre>"}
|
845
|
-
html = %q{Foo
|
846
|
-
<pre>Bar
Baz</pre>}
|
847
|
-
locals = {}
|
848
|
-
options = {}
|
849
|
-
assert_haml(haml, locals, options)
|
850
|
-
end
|
851
|
-
|
852
|
-
specify "inside a textarea tag" do
|
853
|
-
haml = %q{%textarea
|
854
|
-
hello
|
855
|
-
hello}
|
856
|
-
html = %q{<textarea>hello
|
857
|
-
hello</textarea>}
|
858
|
-
locals = {}
|
859
|
-
options = {}
|
860
|
-
assert_haml(haml, locals, options)
|
861
|
-
end
|
862
|
-
|
863
|
-
specify "inside a pre tag" do
|
864
|
-
haml = %q{%pre
|
865
|
-
hello
|
866
|
-
hello}
|
867
|
-
html = %q{<pre>hello
|
868
|
-
hello</pre>}
|
869
|
-
locals = {}
|
870
|
-
options = {}
|
871
|
-
assert_haml(haml, locals, options)
|
872
|
-
end
|
873
|
-
end
|
874
|
-
|
875
|
-
context "whitespace removal" do
|
876
|
-
specify "a tag with '>' appended and inline content" do
|
877
|
-
haml = %q{%li hello
|
878
|
-
%li> world
|
879
|
-
%li again}
|
880
|
-
html = %q{<li>hello</li><li>world</li><li>again</li>}
|
881
|
-
locals = {}
|
882
|
-
options = {}
|
883
|
-
assert_haml(haml, locals, options)
|
884
|
-
end
|
885
|
-
|
886
|
-
specify "a tag with '>' appended and nested content" do
|
887
|
-
haml = %q{%li hello
|
888
|
-
%li>
|
889
|
-
world
|
890
|
-
%li again}
|
891
|
-
html = %q{<li>hello</li><li>
|
892
|
-
world
|
893
|
-
</li><li>again</li>}
|
894
|
-
locals = {}
|
895
|
-
options = {}
|
896
|
-
assert_haml(haml, locals, options)
|
897
|
-
end
|
898
|
-
|
899
|
-
specify "a tag with '<' appended" do
|
900
|
-
haml = %q{%p<
|
901
|
-
hello
|
902
|
-
world}
|
903
|
-
html = %q{<p>hello
|
904
|
-
world</p>}
|
905
|
-
locals = {}
|
906
|
-
options = {}
|
907
|
-
assert_haml(haml, locals, options)
|
908
|
-
end
|
909
|
-
end
|
910
|
-
end
|