jwhitmire-haml 2.1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +332 -0
- data/bin/css2sass +7 -0
- data/bin/haml +9 -0
- data/bin/html2haml +7 -0
- data/bin/sass +8 -0
- data/lib/haml/buffer.rb +255 -0
- data/lib/haml/engine.rb +268 -0
- data/lib/haml/error.rb +22 -0
- data/lib/haml/exec.rb +395 -0
- data/lib/haml/filters.rb +276 -0
- data/lib/haml/helpers/action_view_extensions.rb +45 -0
- data/lib/haml/helpers/action_view_mods.rb +181 -0
- data/lib/haml/helpers.rb +468 -0
- data/lib/haml/html.rb +218 -0
- data/lib/haml/precompiler.rb +889 -0
- data/lib/haml/shared.rb +45 -0
- data/lib/haml/template/patch.rb +58 -0
- data/lib/haml/template/plugin.rb +72 -0
- data/lib/haml/template.rb +51 -0
- data/lib/haml/util.rb +77 -0
- data/lib/haml/version.rb +47 -0
- data/lib/haml.rb +1042 -0
- data/lib/sass/css.rb +388 -0
- data/lib/sass/engine.rb +499 -0
- data/lib/sass/environment.rb +33 -0
- data/lib/sass/error.rb +35 -0
- data/lib/sass/plugin/merb.rb +56 -0
- data/lib/sass/plugin/rails.rb +24 -0
- data/lib/sass/plugin.rb +203 -0
- data/lib/sass/repl.rb +51 -0
- data/lib/sass/script/bool.rb +13 -0
- data/lib/sass/script/color.rb +97 -0
- data/lib/sass/script/funcall.rb +28 -0
- data/lib/sass/script/functions.rb +122 -0
- data/lib/sass/script/lexer.rb +152 -0
- data/lib/sass/script/literal.rb +60 -0
- data/lib/sass/script/number.rb +231 -0
- data/lib/sass/script/operation.rb +30 -0
- data/lib/sass/script/parser.rb +142 -0
- data/lib/sass/script/string.rb +42 -0
- data/lib/sass/script/unary_operation.rb +21 -0
- data/lib/sass/script/variable.rb +20 -0
- data/lib/sass/script.rb +38 -0
- data/lib/sass/tree/attr_node.rb +64 -0
- data/lib/sass/tree/comment_node.rb +34 -0
- data/lib/sass/tree/debug_node.rb +22 -0
- data/lib/sass/tree/directive_node.rb +50 -0
- data/lib/sass/tree/file_node.rb +27 -0
- data/lib/sass/tree/for_node.rb +29 -0
- data/lib/sass/tree/if_node.rb +27 -0
- data/lib/sass/tree/mixin_def_node.rb +18 -0
- data/lib/sass/tree/mixin_node.rb +34 -0
- data/lib/sass/tree/node.rb +99 -0
- data/lib/sass/tree/rule_node.rb +120 -0
- data/lib/sass/tree/variable_node.rb +24 -0
- data/lib/sass/tree/while_node.rb +20 -0
- data/lib/sass.rb +1062 -0
- data/test/benchmark.rb +99 -0
- data/test/haml/engine_test.rb +734 -0
- data/test/haml/helper_test.rb +224 -0
- data/test/haml/html2haml_test.rb +92 -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 +15 -0
- data/test/haml/results/eval_suppressed.xhtml +9 -0
- data/test/haml/results/filters.xhtml +62 -0
- data/test/haml/results/helpers.xhtml +93 -0
- data/test/haml/results/helpful.xhtml +10 -0
- data/test/haml/results/just_stuff.xhtml +68 -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 +42 -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/rhtml/_av_partial_1.rhtml +12 -0
- data/test/haml/rhtml/_av_partial_2.rhtml +8 -0
- data/test/haml/rhtml/action_view.rhtml +62 -0
- data/test/haml/rhtml/standard.rhtml +54 -0
- data/test/haml/template_test.rb +204 -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 +10 -0
- data/test/haml/templates/eval_suppressed.haml +11 -0
- data/test/haml/templates/filters.haml +66 -0
- data/test/haml/templates/helpers.haml +95 -0
- data/test/haml/templates/helpful.haml +11 -0
- data/test/haml/templates/just_stuff.haml +83 -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 +3 -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 +42 -0
- data/test/haml/templates/standard_ugly.haml +1 -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/linked_rails.rb +12 -0
- data/test/sass/css2sass_test.rb +193 -0
- data/test/sass/engine_test.rb +786 -0
- data/test/sass/functions_test.rb +96 -0
- data/test/sass/more_results/more1.css +9 -0
- data/test/sass/more_results/more1_with_line_comments.css +26 -0
- data/test/sass/more_results/more_import.css +29 -0
- data/test/sass/more_templates/_more_partial.sass +2 -0
- data/test/sass/more_templates/more1.sass +23 -0
- data/test/sass/more_templates/more_import.sass +11 -0
- data/test/sass/plugin_test.rb +208 -0
- data/test/sass/results/alt.css +4 -0
- data/test/sass/results/basic.css +9 -0
- data/test/sass/results/compact.css +5 -0
- data/test/sass/results/complex.css +87 -0
- data/test/sass/results/compressed.css +1 -0
- data/test/sass/results/expanded.css +19 -0
- data/test/sass/results/import.css +29 -0
- data/test/sass/results/line_numbers.css +49 -0
- data/test/sass/results/mixins.css +95 -0
- data/test/sass/results/multiline.css +24 -0
- data/test/sass/results/nested.css +22 -0
- data/test/sass/results/parent_ref.css +13 -0
- data/test/sass/results/script.css +16 -0
- data/test/sass/results/subdir/nested_subdir/nested_subdir.css +1 -0
- data/test/sass/results/subdir/subdir.css +3 -0
- data/test/sass/results/units.css +11 -0
- data/test/sass/script_test.rb +153 -0
- data/test/sass/templates/_partial.sass +2 -0
- data/test/sass/templates/alt.sass +16 -0
- data/test/sass/templates/basic.sass +23 -0
- data/test/sass/templates/bork.sass +2 -0
- data/test/sass/templates/bork2.sass +2 -0
- data/test/sass/templates/compact.sass +17 -0
- data/test/sass/templates/complex.sass +309 -0
- data/test/sass/templates/compressed.sass +15 -0
- data/test/sass/templates/expanded.sass +17 -0
- data/test/sass/templates/import.sass +11 -0
- data/test/sass/templates/importee.sass +19 -0
- data/test/sass/templates/line_numbers.sass +13 -0
- data/test/sass/templates/mixins.sass +76 -0
- data/test/sass/templates/multiline.sass +20 -0
- data/test/sass/templates/nested.sass +25 -0
- data/test/sass/templates/parent_ref.sass +25 -0
- data/test/sass/templates/script.sass +101 -0
- data/test/sass/templates/subdir/nested_subdir/_nested_partial.sass +2 -0
- data/test/sass/templates/subdir/nested_subdir/nested_subdir.sass +3 -0
- data/test/sass/templates/subdir/subdir.sass +6 -0
- data/test/sass/templates/units.sass +11 -0
- data/test/test_helper.rb +21 -0
- metadata +245 -0
data/test/benchmark.rb
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
times = (ARGV.first || 1000).to_i
|
4
|
+
|
5
|
+
if times == 0 # Invalid parameter
|
6
|
+
puts <<END
|
7
|
+
ruby #$0 [times=1000]
|
8
|
+
Benchmark Haml against various other templating languages and Sass
|
9
|
+
on its own.
|
10
|
+
END
|
11
|
+
exit 1
|
12
|
+
end
|
13
|
+
|
14
|
+
require File.dirname(__FILE__) + '/../lib/haml'
|
15
|
+
require File.dirname(__FILE__) + '/linked_rails'
|
16
|
+
%w[sass rubygems erb erubis markaby active_support action_controller
|
17
|
+
action_view action_pack haml/template rbench].each {|dep| require(dep)}
|
18
|
+
|
19
|
+
def view
|
20
|
+
unless Haml::Util.has?(:instance_method, ActionView::Base, :finder)
|
21
|
+
return ActionView::Base.new(File.dirname(__FILE__), {})
|
22
|
+
end
|
23
|
+
|
24
|
+
# Rails >=2.1.0
|
25
|
+
base = ActionView::Base.new
|
26
|
+
base.finder.append_view_path(File.dirname(__FILE__))
|
27
|
+
base
|
28
|
+
end
|
29
|
+
|
30
|
+
def render(view, file)
|
31
|
+
view.render :file => file
|
32
|
+
end
|
33
|
+
|
34
|
+
RBench.run(times) do
|
35
|
+
column :haml, :title => "Haml"
|
36
|
+
column :haml_ugly, :title => "Haml :ugly"
|
37
|
+
column :erb, :title => "ERB"
|
38
|
+
column :erubis, :title => "Erubis"
|
39
|
+
|
40
|
+
template_name = 'standard'
|
41
|
+
directory = File.dirname(__FILE__) + '/haml'
|
42
|
+
haml_template = File.read("#{directory}/templates/#{template_name}.haml")
|
43
|
+
erb_template = File.read("#{directory}/rhtml/#{template_name}.rhtml")
|
44
|
+
markaby_template = File.read("#{directory}/markaby/#{template_name}.mab")
|
45
|
+
|
46
|
+
report "Cached" do
|
47
|
+
obj = Object.new
|
48
|
+
|
49
|
+
Haml::Engine.new(haml_template).def_method(obj, :haml)
|
50
|
+
Haml::Engine.new(haml_template, :ugly => true).def_method(obj, :haml_ugly)
|
51
|
+
Erubis::Eruby.new(erb_template).def_method(obj, :erubis)
|
52
|
+
obj.instance_eval("def erb; #{ERB.new(erb_template, nil, '-').src}; end")
|
53
|
+
|
54
|
+
haml { obj.haml }
|
55
|
+
haml_ugly { obj.haml_ugly }
|
56
|
+
erb { obj.erb }
|
57
|
+
erubis { obj.erubis }
|
58
|
+
end
|
59
|
+
|
60
|
+
report "ActionView" do
|
61
|
+
@base = view
|
62
|
+
|
63
|
+
@base.unmemoize_all
|
64
|
+
Haml::Template.options[:ugly] = false
|
65
|
+
# To cache the template
|
66
|
+
render @base, 'haml/templates/standard'
|
67
|
+
render @base, 'haml/rhtml/standard'
|
68
|
+
|
69
|
+
haml { render @base, 'haml/templates/standard' }
|
70
|
+
erb { render @base, 'haml/rhtml/standard' }
|
71
|
+
|
72
|
+
Haml::Template.options[:ugly] = true
|
73
|
+
render @base, 'haml/templates/standard_ugly'
|
74
|
+
haml_ugly { render @base, 'haml/templates/standard_ugly' }
|
75
|
+
end
|
76
|
+
|
77
|
+
report "ActionView with deep partials" do
|
78
|
+
@base = view
|
79
|
+
|
80
|
+
@base.unmemoize_all
|
81
|
+
Haml::Template.options[:ugly] = false
|
82
|
+
# To cache the template
|
83
|
+
render @base, 'haml/templates/action_view'
|
84
|
+
render @base, 'haml/rhtml/action_view'
|
85
|
+
|
86
|
+
haml { render @base, 'haml/templates/action_view' }
|
87
|
+
erb { render @base, 'haml/rhtml/action_view' }
|
88
|
+
|
89
|
+
Haml::Template.options[:ugly] = true
|
90
|
+
render @base, 'haml/templates/action_view_ugly'
|
91
|
+
haml_ugly { render @base, 'haml/templates/action_view_ugly' }
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
RBench.run(times) do
|
96
|
+
sass_template = File.read("#{File.dirname(__FILE__)}/sass/templates/complex.sass")
|
97
|
+
|
98
|
+
report("Sass") { Sass::Engine.new(sass_template).render }
|
99
|
+
end
|