radiant 0.6.6 → 0.6.7
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of radiant might be problematic. Click here for more details.
- data/CHANGELOG +15 -0
- data/CONTRIBUTORS +8 -0
- data/app/controllers/admin/page_controller.rb +1 -11
- data/app/controllers/admin/welcome_controller.rb +5 -6
- data/app/controllers/application.rb +2 -0
- data/app/controllers/site_controller.rb +1 -0
- data/app/helpers/admin/page_helper.rb +36 -0
- data/app/helpers/admin/regions_helper.rb +28 -0
- data/app/helpers/admin/user_helper.rb +6 -0
- data/app/helpers/application_helper.rb +2 -1
- data/app/models/user.rb +7 -8
- data/app/views/admin/extension/index.html.haml +28 -0
- data/app/views/admin/layout/edit.html.haml +44 -0
- data/app/views/admin/layout/index.html.haml +25 -0
- data/app/views/admin/layout/remove.html.haml +16 -0
- data/app/views/admin/page/_meta_row.html.haml +6 -0
- data/app/views/admin/page/_node.html.haml +25 -0
- data/app/views/admin/page/_part.html.haml +17 -0
- data/app/views/admin/page/_tag_reference.html.haml +3 -0
- data/app/views/admin/page/children.html.haml +2 -0
- data/app/views/admin/page/edit.html.haml +114 -0
- data/app/views/admin/page/index.html.haml +28 -0
- data/app/views/admin/page/remove.html.haml +20 -0
- data/app/views/admin/snippet/edit.html.haml +36 -0
- data/app/views/admin/snippet/index.html.haml +20 -0
- data/app/views/admin/snippet/remove.html.haml +19 -0
- data/app/views/admin/user/edit.html.haml +80 -0
- data/app/views/admin/user/index.html.haml +23 -0
- data/app/views/admin/user/preferences.html.haml +28 -0
- data/app/views/admin/user/remove.html.haml +18 -0
- data/app/views/admin/welcome/login.html.haml +44 -0
- data/app/views/layouts/application.html.haml +54 -0
- data/app/views/site/not_found.html.haml +3 -0
- data/db/migrate/019_add_salt_to_users.rb +11 -0
- data/db/schema.rb +2 -1
- data/lib/login_system.rb +1 -0
- data/lib/radiant.rb +1 -1
- data/lib/radiant/admin_ui.rb +65 -0
- data/lib/radiant/admin_ui/region_partials.rb +18 -0
- data/lib/radiant/admin_ui/region_set.rb +35 -0
- data/lib/tasks/extensions.rake +33 -0
- data/public/javascripts/admin/admin.js +8 -2
- data/public/javascripts/admin/sitemap.js +2 -1
- data/public/stylesheets/admin/main.css +4 -0
- data/spec/controllers/admin/abstract_model_controller_spec.rb +2 -0
- data/spec/controllers/admin/page_controller_spec.rb +3 -28
- data/spec/controllers/admin/user_controller_spec.rb +1 -1
- data/spec/controllers/admin/welcome_controller_spec.rb +26 -0
- data/spec/helpers/admin/page_helper_spec.rb +4 -0
- data/spec/helpers/admin/regions_helper_spec.rb +47 -0
- data/spec/helpers/admin/user_helper_spec.rb +7 -0
- data/spec/helpers/application_helper_spec.rb +7 -3
- data/spec/lib/login_system_spec.rb +5 -0
- data/spec/lib/radiant/admin_ui/region_partials_spec.rb +35 -0
- data/spec/lib/radiant/admin_ui/region_set_spec.rb +61 -0
- data/spec/lib/radiant/admin_ui_spec.rb +74 -18
- data/spec/models/user_spec.rb +11 -4
- data/spec/scenarios/users_scenario.rb +2 -2
- data/vendor/plugins/haml/MIT-LICENSE +20 -0
- data/vendor/plugins/haml/README.rdoc +319 -0
- data/vendor/plugins/haml/Rakefile +158 -0
- data/vendor/plugins/haml/TODO +9 -0
- data/vendor/plugins/haml/VERSION +1 -0
- data/vendor/plugins/haml/bin/css2sass +7 -0
- data/vendor/plugins/haml/bin/haml +8 -0
- data/vendor/plugins/haml/bin/html2haml +7 -0
- data/vendor/plugins/haml/bin/sass +8 -0
- data/vendor/plugins/haml/extra/haml-mode.el +328 -0
- data/vendor/plugins/haml/extra/sass-mode.el +88 -0
- data/vendor/plugins/haml/init.rb +2 -0
- data/vendor/plugins/haml/lib/haml.rb +977 -0
- data/vendor/plugins/haml/lib/haml/buffer.rb +229 -0
- data/vendor/plugins/haml/lib/haml/engine.rb +274 -0
- data/vendor/plugins/haml/lib/haml/error.rb +23 -0
- data/vendor/plugins/haml/lib/haml/exec.rb +347 -0
- data/vendor/plugins/haml/lib/haml/filters.rb +249 -0
- data/vendor/plugins/haml/lib/haml/helpers.rb +413 -0
- data/vendor/plugins/haml/lib/haml/helpers/action_view_extensions.rb +45 -0
- data/vendor/plugins/haml/lib/haml/helpers/action_view_mods.rb +122 -0
- data/vendor/plugins/haml/lib/haml/html.rb +188 -0
- data/vendor/plugins/haml/lib/haml/precompiler.rb +757 -0
- data/vendor/plugins/haml/lib/haml/template.rb +43 -0
- data/vendor/plugins/haml/lib/haml/template/patch.rb +58 -0
- data/vendor/plugins/haml/lib/haml/template/plugin.rb +72 -0
- data/vendor/plugins/haml/lib/sass.rb +833 -0
- data/vendor/plugins/haml/lib/sass/constant.rb +245 -0
- data/vendor/plugins/haml/lib/sass/constant/color.rb +101 -0
- data/vendor/plugins/haml/lib/sass/constant/literal.rb +53 -0
- data/vendor/plugins/haml/lib/sass/constant/number.rb +87 -0
- data/vendor/plugins/haml/lib/sass/constant/operation.rb +30 -0
- data/vendor/plugins/haml/lib/sass/constant/string.rb +22 -0
- data/vendor/plugins/haml/lib/sass/css.rb +378 -0
- data/vendor/plugins/haml/lib/sass/engine.rb +459 -0
- data/vendor/plugins/haml/lib/sass/error.rb +35 -0
- data/vendor/plugins/haml/lib/sass/plugin.rb +165 -0
- data/vendor/plugins/haml/lib/sass/plugin/merb.rb +56 -0
- data/vendor/plugins/haml/lib/sass/plugin/rails.rb +24 -0
- data/vendor/plugins/haml/lib/sass/tree/attr_node.rb +53 -0
- data/vendor/plugins/haml/lib/sass/tree/comment_node.rb +20 -0
- data/vendor/plugins/haml/lib/sass/tree/directive_node.rb +46 -0
- data/vendor/plugins/haml/lib/sass/tree/node.rb +42 -0
- data/vendor/plugins/haml/lib/sass/tree/rule_node.rb +89 -0
- data/vendor/plugins/haml/lib/sass/tree/value_node.rb +16 -0
- data/vendor/plugins/haml/test/benchmark.rb +82 -0
- data/vendor/plugins/haml/test/haml/engine_test.rb +587 -0
- data/vendor/plugins/haml/test/haml/helper_test.rb +187 -0
- data/vendor/plugins/haml/test/haml/html2haml_test.rb +60 -0
- data/vendor/plugins/haml/test/haml/markaby/standard.mab +52 -0
- data/vendor/plugins/haml/test/haml/mocks/article.rb +6 -0
- data/vendor/plugins/haml/test/haml/results/content_for_layout.xhtml +16 -0
- data/vendor/plugins/haml/test/haml/results/eval_suppressed.xhtml +11 -0
- data/vendor/plugins/haml/test/haml/results/filters.xhtml +82 -0
- data/vendor/plugins/haml/test/haml/results/helpers.xhtml +94 -0
- data/vendor/plugins/haml/test/haml/results/helpful.xhtml +10 -0
- data/vendor/plugins/haml/test/haml/results/just_stuff.xhtml +64 -0
- data/vendor/plugins/haml/test/haml/results/list.xhtml +12 -0
- data/vendor/plugins/haml/test/haml/results/original_engine.xhtml +22 -0
- data/vendor/plugins/haml/test/haml/results/partials.xhtml +21 -0
- data/vendor/plugins/haml/test/haml/results/silent_script.xhtml +74 -0
- data/vendor/plugins/haml/test/haml/results/standard.xhtml +42 -0
- data/vendor/plugins/haml/test/haml/results/tag_parsing.xhtml +28 -0
- data/vendor/plugins/haml/test/haml/results/very_basic.xhtml +7 -0
- data/vendor/plugins/haml/test/haml/results/whitespace_handling.xhtml +94 -0
- data/vendor/plugins/haml/test/haml/rhtml/_av_partial_1.rhtml +12 -0
- data/vendor/plugins/haml/test/haml/rhtml/_av_partial_2.rhtml +8 -0
- data/vendor/plugins/haml/test/haml/rhtml/action_view.rhtml +62 -0
- data/vendor/plugins/haml/test/haml/rhtml/standard.rhtml +54 -0
- data/vendor/plugins/haml/test/haml/template_test.rb +168 -0
- data/vendor/plugins/haml/test/haml/templates/_av_partial_1.haml +9 -0
- data/vendor/plugins/haml/test/haml/templates/_av_partial_2.haml +5 -0
- data/vendor/plugins/haml/test/haml/templates/_partial.haml +8 -0
- data/vendor/plugins/haml/test/haml/templates/_text_area.haml +3 -0
- data/vendor/plugins/haml/test/haml/templates/action_view.haml +47 -0
- data/vendor/plugins/haml/test/haml/templates/breakage.haml +8 -0
- data/vendor/plugins/haml/test/haml/templates/content_for_layout.haml +10 -0
- data/vendor/plugins/haml/test/haml/templates/eval_suppressed.haml +11 -0
- data/vendor/plugins/haml/test/haml/templates/filters.haml +81 -0
- data/vendor/plugins/haml/test/haml/templates/helpers.haml +69 -0
- data/vendor/plugins/haml/test/haml/templates/helpful.haml +11 -0
- data/vendor/plugins/haml/test/haml/templates/just_stuff.haml +77 -0
- data/vendor/plugins/haml/test/haml/templates/list.haml +12 -0
- data/vendor/plugins/haml/test/haml/templates/original_engine.haml +17 -0
- data/vendor/plugins/haml/test/haml/templates/partialize.haml +1 -0
- data/vendor/plugins/haml/test/haml/templates/partials.haml +12 -0
- data/vendor/plugins/haml/test/haml/templates/silent_script.haml +40 -0
- data/vendor/plugins/haml/test/haml/templates/standard.haml +42 -0
- data/vendor/plugins/haml/test/haml/templates/tag_parsing.haml +24 -0
- data/vendor/plugins/haml/test/haml/templates/very_basic.haml +4 -0
- data/vendor/plugins/haml/test/haml/templates/whitespace_handling.haml +87 -0
- data/vendor/plugins/haml/test/haml/test_helper.rb +15 -0
- data/vendor/plugins/haml/test/profile.rb +65 -0
- data/vendor/plugins/haml/test/sass/engine_test.rb +276 -0
- data/vendor/plugins/haml/test/sass/plugin_test.rb +159 -0
- data/vendor/plugins/haml/test/sass/results/alt.css +4 -0
- data/vendor/plugins/haml/test/sass/results/basic.css +9 -0
- data/vendor/plugins/haml/test/sass/results/compact.css +5 -0
- data/vendor/plugins/haml/test/sass/results/complex.css +87 -0
- data/vendor/plugins/haml/test/sass/results/compressed.css +1 -0
- data/vendor/plugins/haml/test/sass/results/constants.css +14 -0
- data/vendor/plugins/haml/test/sass/results/expanded.css +19 -0
- data/vendor/plugins/haml/test/sass/results/import.css +29 -0
- data/vendor/plugins/haml/test/sass/results/mixins.css +95 -0
- data/vendor/plugins/haml/test/sass/results/multiline.css +24 -0
- data/vendor/plugins/haml/test/sass/results/nested.css +22 -0
- data/vendor/plugins/haml/test/sass/results/parent_ref.css +13 -0
- data/vendor/plugins/haml/test/sass/results/subdir/nested_subdir/nested_subdir.css +1 -0
- data/vendor/plugins/haml/test/sass/results/subdir/subdir.css +1 -0
- data/vendor/plugins/haml/test/sass/templates/_partial.sass +2 -0
- data/vendor/plugins/haml/test/sass/templates/alt.sass +16 -0
- data/vendor/plugins/haml/test/sass/templates/basic.sass +23 -0
- data/vendor/plugins/haml/test/sass/templates/bork.sass +2 -0
- data/vendor/plugins/haml/test/sass/templates/bork2.sass +2 -0
- data/vendor/plugins/haml/test/sass/templates/compact.sass +17 -0
- data/vendor/plugins/haml/test/sass/templates/complex.sass +310 -0
- data/vendor/plugins/haml/test/sass/templates/compressed.sass +15 -0
- data/vendor/plugins/haml/test/sass/templates/constants.sass +97 -0
- data/vendor/plugins/haml/test/sass/templates/expanded.sass +17 -0
- data/vendor/plugins/haml/test/sass/templates/import.sass +11 -0
- data/vendor/plugins/haml/test/sass/templates/importee.sass +14 -0
- data/vendor/plugins/haml/test/sass/templates/mixins.sass +76 -0
- data/vendor/plugins/haml/test/sass/templates/multiline.sass +20 -0
- data/vendor/plugins/haml/test/sass/templates/nested.sass +25 -0
- data/vendor/plugins/haml/test/sass/templates/parent_ref.sass +25 -0
- data/vendor/plugins/haml/test/sass/templates/subdir/nested_subdir/nested_subdir.sass +3 -0
- data/vendor/plugins/haml/test/sass/templates/subdir/subdir.sass +6 -0
- metadata +185 -24
- data/app/views/admin/extension/index.html.erb +0 -40
- data/app/views/admin/layout/edit.html.erb +0 -39
- data/app/views/admin/layout/index.html.erb +0 -38
- data/app/views/admin/layout/remove.html.erb +0 -17
- data/app/views/admin/page/_meta_row.html.erb +0 -4
- data/app/views/admin/page/_node.html.erb +0 -28
- data/app/views/admin/page/_part.html.erb +0 -13
- data/app/views/admin/page/_tag_reference.html.erb +0 -4
- data/app/views/admin/page/children.html.erb +0 -4
- data/app/views/admin/page/edit.html.erb +0 -140
- data/app/views/admin/page/index.html.erb +0 -31
- data/app/views/admin/page/remove.html.erb +0 -14
- data/app/views/admin/snippet/edit.html.erb +0 -29
- data/app/views/admin/snippet/index.html.erb +0 -36
- data/app/views/admin/snippet/remove.html.erb +0 -16
- data/app/views/admin/user/edit.html.erb +0 -54
- data/app/views/admin/user/index.html.erb +0 -43
- data/app/views/admin/user/preferences.html.erb +0 -29
- data/app/views/admin/user/remove.html.erb +0 -16
- data/app/views/admin/welcome/login.html.erb +0 -51
- data/app/views/layouts/application.html.erb +0 -83
- data/app/views/site/not_found.html.erb +0 -3
@@ -0,0 +1,54 @@
|
|
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
|
+
<!-- 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>
|
22
|
+
<%= "Holy cow " +
|
23
|
+
"multiline " +
|
24
|
+
"tags! " +
|
25
|
+
"A pipe (|) even!" %>
|
26
|
+
<%= [1, 2, 3].collect { |n| "PipesIgnored|" } %>
|
27
|
+
<%= [1, 2, 3].collect { |n|
|
28
|
+
n.to_s
|
29
|
+
}.join("|") %>
|
30
|
+
</p>
|
31
|
+
<div class='silent'>
|
32
|
+
<% foo = String.new
|
33
|
+
foo << "this"
|
34
|
+
foo << " shouldn't"
|
35
|
+
foo << " evaluate" %>
|
36
|
+
<%= foo + "but now it should!" %>
|
37
|
+
<%# Woah crap a comment! %>
|
38
|
+
</div>
|
39
|
+
<ul class='really cool'>
|
40
|
+
<% ('a'..'f').each do |a|%>
|
41
|
+
<li><%= a %>
|
42
|
+
<% end %>
|
43
|
+
<div class='of_divs_with_underscore' id='combo'><%= @should_eval = "with this text" %></div>
|
44
|
+
<%= [ 104, 101, 108, 108, 111 ].map do |byte|
|
45
|
+
byte.chr
|
46
|
+
end %>
|
47
|
+
<div class='footer'>
|
48
|
+
<strong class='shout'>
|
49
|
+
<%= "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" +
|
50
|
+
" So, I'm just making it *really* long. God, I hope this works" %>
|
51
|
+
</strong>
|
52
|
+
</div>
|
53
|
+
</body>
|
54
|
+
</html>
|
@@ -0,0 +1,168 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require File.dirname(__FILE__) + '/test_helper'
|
3
|
+
require 'haml/template'
|
4
|
+
require File.dirname(__FILE__) + '/mocks/article'
|
5
|
+
|
6
|
+
module TestFilter
|
7
|
+
include Haml::Filters::Base
|
8
|
+
|
9
|
+
def render(text)
|
10
|
+
"TESTING HAHAHAHA!"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class TemplateTest < Test::Unit::TestCase
|
15
|
+
@@templates = %w{ very_basic standard helpers
|
16
|
+
whitespace_handling original_engine list helpful
|
17
|
+
silent_script tag_parsing just_stuff partials
|
18
|
+
filters }
|
19
|
+
|
20
|
+
def setup
|
21
|
+
Haml::Template.options = { :filters => { 'test'=>TestFilter } }
|
22
|
+
@base = ActionView::Base.new(File.dirname(__FILE__) + "/templates/", {'article' => Article.new, 'foo' => 'value one'})
|
23
|
+
@base.send(:evaluate_assigns)
|
24
|
+
|
25
|
+
# This is used by form_for.
|
26
|
+
# It's usually provided by ActionController::Base.
|
27
|
+
def @base.protect_against_forgery?; false; end
|
28
|
+
end
|
29
|
+
|
30
|
+
def render(text)
|
31
|
+
Haml::Engine.new(text).to_html(@base)
|
32
|
+
end
|
33
|
+
|
34
|
+
def load_result(name)
|
35
|
+
@result = ''
|
36
|
+
File.new(File.dirname(__FILE__) + "/results/#{name}.xhtml").each_line { |l| @result += l }
|
37
|
+
@result
|
38
|
+
end
|
39
|
+
|
40
|
+
def assert_renders_correctly(name, &render_method)
|
41
|
+
render_method ||= proc { |name| @base.render(name) }
|
42
|
+
test = Proc.new do |rendered|
|
43
|
+
load_result(name).split("\n").zip(rendered.split("\n")).each_with_index do |pair, line|
|
44
|
+
message = "template: #{name}\nline: #{line}"
|
45
|
+
assert_equal(pair.first, pair.last, message)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
begin
|
49
|
+
test.call(render_method[name])
|
50
|
+
rescue ActionView::TemplateError => e
|
51
|
+
if e.message =~ /Can't run [\w:]+ filter; required (one of|file) ((?:'\w+'(?: or )?)+)(, but none were found| not found)/
|
52
|
+
puts "\nCouldn't require #{$2}; skipping a test."
|
53
|
+
else
|
54
|
+
raise e
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_empty_render_should_remain_empty
|
60
|
+
assert_equal('', render(''))
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_templates_should_render_correctly
|
64
|
+
@@templates.each do |template|
|
65
|
+
assert_renders_correctly template
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_templates_should_render_correctly_with_render_proc
|
70
|
+
@@templates.each do |template|
|
71
|
+
assert_renders_correctly(template) do |name|
|
72
|
+
engine = Haml::Engine.new(File.read(File.dirname(__FILE__) + "/templates/#{name}.haml"), :filters => { 'test'=>TestFilter })
|
73
|
+
engine.render_proc(@base).call
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_templates_should_render_correctly_with_def_method
|
79
|
+
@@templates.each do |template|
|
80
|
+
assert_renders_correctly(template) do |name|
|
81
|
+
method = "render_haml_" + name.gsub(/[^a-zA-Z0-9]/, '_')
|
82
|
+
|
83
|
+
engine = Haml::Engine.new(File.read(File.dirname(__FILE__) + "/templates/#{name}.haml"), :filters => { 'test'=>TestFilter })
|
84
|
+
engine.def_method(@base, method)
|
85
|
+
@base.send(method)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def test_action_view_templates_render_correctly
|
91
|
+
@base.instance_variable_set("@content_for_layout", 'Lorem ipsum dolor sit amet')
|
92
|
+
assert_renders_correctly 'content_for_layout'
|
93
|
+
end
|
94
|
+
|
95
|
+
def test_instance_variables_should_work_inside_templates
|
96
|
+
@base.instance_variable_set("@content_for_layout", 'something')
|
97
|
+
assert_equal("<p>something</p>", render("%p= @content_for_layout").chomp)
|
98
|
+
|
99
|
+
@base.instance_eval("@author = 'Hampton Catlin'")
|
100
|
+
assert_equal("<div class='author'>Hampton Catlin</div>", render(".author= @author").chomp)
|
101
|
+
|
102
|
+
@base.instance_eval("@author = 'Hampton'")
|
103
|
+
assert_equal("Hampton", render("= @author").chomp)
|
104
|
+
|
105
|
+
@base.instance_eval("@author = 'Catlin'")
|
106
|
+
assert_equal("Catlin", render("= @author").chomp)
|
107
|
+
end
|
108
|
+
|
109
|
+
def test_instance_variables_should_work_inside_attributes
|
110
|
+
@base.instance_eval("@author = 'hcatlin'")
|
111
|
+
assert_equal("<p class='hcatlin'>foo</p>", render("%p{:class => @author} foo").chomp)
|
112
|
+
end
|
113
|
+
|
114
|
+
def test_template_renders_should_eval
|
115
|
+
assert_equal("2\n", render("= 1+1"))
|
116
|
+
end
|
117
|
+
|
118
|
+
def test_rhtml_still_renders
|
119
|
+
# Make sure it renders normally
|
120
|
+
res = @base.render("../rhtml/standard")
|
121
|
+
assert !(res.nil? || res.empty?)
|
122
|
+
|
123
|
+
# Register Haml stuff in @base...
|
124
|
+
@base.render("standard")
|
125
|
+
|
126
|
+
# Does it still render?
|
127
|
+
res = @base.render("../rhtml/standard")
|
128
|
+
assert !(res.nil? || res.empty?)
|
129
|
+
end
|
130
|
+
|
131
|
+
def test_haml_options
|
132
|
+
Haml::Template.options = { :suppress_eval => true }
|
133
|
+
assert_equal({ :suppress_eval => true }, Haml::Template.options)
|
134
|
+
assert_renders_correctly("eval_suppressed")
|
135
|
+
Haml::Template.options = {}
|
136
|
+
end
|
137
|
+
|
138
|
+
def test_exceptions_should_work_correctly
|
139
|
+
begin
|
140
|
+
render("- raise 'oops!'")
|
141
|
+
rescue Exception => e
|
142
|
+
assert_equal("oops!", e.message)
|
143
|
+
assert_match(/^\(haml\):1/, e.backtrace[0])
|
144
|
+
else
|
145
|
+
assert false
|
146
|
+
end
|
147
|
+
|
148
|
+
template = <<END
|
149
|
+
%p
|
150
|
+
%h1 Hello!
|
151
|
+
= "lots of lines"
|
152
|
+
= "even more!"
|
153
|
+
- raise 'oh no!'
|
154
|
+
%p
|
155
|
+
this is after the exception
|
156
|
+
%strong yes it is!
|
157
|
+
ho ho ho.
|
158
|
+
END
|
159
|
+
|
160
|
+
begin
|
161
|
+
render(template.chomp)
|
162
|
+
rescue Exception => e
|
163
|
+
assert_match(/^\(haml\):5/, e.backtrace[0])
|
164
|
+
else
|
165
|
+
assert false
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
!!!
|
2
|
+
%html{html_attrs}
|
3
|
+
%head
|
4
|
+
%title Hampton Catlin Is Totally Awesome
|
5
|
+
%meta{"http-equiv" => "Content-Type", :content => "text/html; charset=utf-8"}
|
6
|
+
%body
|
7
|
+
%h1
|
8
|
+
This is very much like the standard template,
|
9
|
+
except that it has some ActionView-specific stuff.
|
10
|
+
It's only used for benchmarking.
|
11
|
+
.crazy_partials= render :partial => 'haml/templates/av_partial_1'
|
12
|
+
/ You're In my house now!
|
13
|
+
.header
|
14
|
+
Yes, ladies and gentileman. He is just that egotistical.
|
15
|
+
Fantastic! This should be multi-line output
|
16
|
+
The question is if this would translate! Ahah!
|
17
|
+
= 1 + 9 + 8 + 2 #numbers should work and this should be ignored
|
18
|
+
#body= " Quotes should be loved! Just like people!"
|
19
|
+
- 120.times do |number|
|
20
|
+
- number
|
21
|
+
Wow.|
|
22
|
+
%p
|
23
|
+
= "Holy cow " + |
|
24
|
+
"multiline " + |
|
25
|
+
"tags! " + |
|
26
|
+
"A pipe (|) even!" |
|
27
|
+
= [1, 2, 3].collect { |n| "PipesIgnored|" }
|
28
|
+
= [1, 2, 3].collect { |n| |
|
29
|
+
n.to_s |
|
30
|
+
}.join("|") |
|
31
|
+
%div.silent
|
32
|
+
- foo = String.new
|
33
|
+
- foo << "this"
|
34
|
+
- foo << " shouldn't"
|
35
|
+
- foo << " evaluate"
|
36
|
+
= foo + " but now it should!"
|
37
|
+
-# Woah crap a comment!
|
38
|
+
|
39
|
+
-# That was a line that shouldn't close everything.
|
40
|
+
%ul.really.cool
|
41
|
+
- ('a'..'f').each do |a|
|
42
|
+
%li= a
|
43
|
+
#combo.of_divs_with_underscore= @should_eval = "with this text"
|
44
|
+
= [ 104, 101, 108, 108, 111 ].map do |byte|
|
45
|
+
- byte.chr
|
46
|
+
.footer
|
47
|
+
%strong.shout= "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. \nSo, I'm just making it *really* long. God, I hope this works"
|
@@ -0,0 +1,81 @@
|
|
1
|
+
%style
|
2
|
+
- width = 5 + 17
|
3
|
+
:sass
|
4
|
+
p
|
5
|
+
:border
|
6
|
+
:style dotted
|
7
|
+
:width #{width}px
|
8
|
+
:color #ff00ff
|
9
|
+
h1
|
10
|
+
:font-weight normal
|
11
|
+
|
12
|
+
:test
|
13
|
+
This
|
14
|
+
Should
|
15
|
+
Not
|
16
|
+
Print
|
17
|
+
|
18
|
+
:redcloth
|
19
|
+
Foo
|
20
|
+
===
|
21
|
+
|
22
|
+
This is preformatted!
|
23
|
+
Look at that!
|
24
|
+
Wowie-zowie!
|
25
|
+
|
26
|
+
*boldilicious!*
|
27
|
+
|
28
|
+
:textile
|
29
|
+
h1. Yeah
|
30
|
+
|
31
|
+
_pretty much the same as above_
|
32
|
+
|
33
|
+
%p
|
34
|
+
:javascript
|
35
|
+
function newline(str) {
|
36
|
+
return "\n" + str;
|
37
|
+
}
|
38
|
+
|
39
|
+
:plain
|
40
|
+
This
|
41
|
+
Is
|
42
|
+
Plain
|
43
|
+
Text
|
44
|
+
%strong right?
|
45
|
+
\#{not interpolated}
|
46
|
+
\\#{1 + 2}
|
47
|
+
\\\#{also not}
|
48
|
+
\\
|
49
|
+
|
50
|
+
- last = "noitalo"
|
51
|
+
%p
|
52
|
+
%pre
|
53
|
+
:preserve
|
54
|
+
This pre is pretty deeply
|
55
|
+
nested.
|
56
|
+
Does #{"interp" + last.reverse} work?
|
57
|
+
:preserve
|
58
|
+
This one is, too.
|
59
|
+
Nested, that is.
|
60
|
+
|
61
|
+
- num = 10
|
62
|
+
%ul
|
63
|
+
:erb
|
64
|
+
<% num.times do |c| %>
|
65
|
+
<li><%= (c+97).chr %></li>
|
66
|
+
<% end %>
|
67
|
+
<% res = 178 %>
|
68
|
+
|
69
|
+
.res= res
|
70
|
+
|
71
|
+
:markdown
|
72
|
+
* Foo
|
73
|
+
* Bar
|
74
|
+
* BAZ!
|
75
|
+
|
76
|
+
= "Text!"
|
77
|
+
|
78
|
+
- var = "Hello"
|
79
|
+
:ruby
|
80
|
+
printf "%s, World!\n", var
|
81
|
+
print "How are you doing today?\n"
|
@@ -0,0 +1,69 @@
|
|
1
|
+
= h("&&&&&&&&&&&") # This is an ActionView Helper... should load
|
2
|
+
- foo = capture do # This ActionView Helper is designed for ERB, but should work with haml
|
3
|
+
%div
|
4
|
+
%p.title Title
|
5
|
+
%p.text
|
6
|
+
Woah this is really crazy
|
7
|
+
I mean wow,
|
8
|
+
man.
|
9
|
+
- 3.times do
|
10
|
+
= foo
|
11
|
+
%p foo
|
12
|
+
- tab_up
|
13
|
+
%p reeeeeeeeeeeeeeeeeeeeeeeeeeeeeeally loooooooooooooooooong
|
14
|
+
- tab_down
|
15
|
+
.woah
|
16
|
+
#funky
|
17
|
+
= capture_haml do
|
18
|
+
%div
|
19
|
+
%h1 Big!
|
20
|
+
%p Small
|
21
|
+
/ Invisible
|
22
|
+
= capture do
|
23
|
+
.dilly
|
24
|
+
%p foo
|
25
|
+
%h1 bar
|
26
|
+
= surround '(', ')' do
|
27
|
+
%strong parentheses!
|
28
|
+
= precede '*' do
|
29
|
+
%span.small Not really
|
30
|
+
click
|
31
|
+
= succeed '.' do
|
32
|
+
%a{:href=>"thing"} here
|
33
|
+
%p baz
|
34
|
+
- haml_buffer.tabulation = 10
|
35
|
+
%p boom
|
36
|
+
- concat "foo\n"
|
37
|
+
- haml_buffer.tabulation = 0
|
38
|
+
- def url_for(*stuff); stuff.join(' '); end
|
39
|
+
-# The form URLs must be empty
|
40
|
+
-# because of a weird bug that causes url_for to misbehave.
|
41
|
+
%p
|
42
|
+
= form_tag ''
|
43
|
+
- form_tag '' do
|
44
|
+
%div= submit_tag 'save'
|
45
|
+
- @foo = 'value one'
|
46
|
+
= render :partial => './partial'
|
47
|
+
- form_for :article, @article, :url => '' do |f|
|
48
|
+
Title:
|
49
|
+
= f.text_field :title
|
50
|
+
Body:
|
51
|
+
= f.text_field :body
|
52
|
+
= list_of({:google => 'http://www.google.com'}) do |name, link|
|
53
|
+
%a{ :href => link }= name
|
54
|
+
%p
|
55
|
+
- puts "foo"
|
56
|
+
%div
|
57
|
+
- puts "bar"
|
58
|
+
- puts "boom"
|
59
|
+
baz
|
60
|
+
- puts "boom, again"
|
61
|
+
- haml_tag :table do
|
62
|
+
- haml_tag :tr do
|
63
|
+
- haml_tag :td, {:class => 'cell'} do
|
64
|
+
- haml_tag :strong, "strong!"
|
65
|
+
- puts "data"
|
66
|
+
- haml_tag :td do
|
67
|
+
- puts "more_data"
|
68
|
+
- haml_tag :hr
|
69
|
+
- haml_tag :div, ''
|