mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
Merge branch 'stable'
This commit is contained in:
commit
2c23993eec
4 changed files with 52 additions and 25 deletions
|
@ -103,7 +103,7 @@ if defined?(ActionView) and not defined?(Merb::Plugins)
|
||||||
|
|
||||||
preserve = haml_buffer.options[:preserve].include?(name.to_s)
|
preserve = haml_buffer.options[:preserve].include?(name.to_s)
|
||||||
|
|
||||||
if block_given? && block_called_from_erb?(block) && preserve
|
if block_given? && block_is_haml?(block) && preserve
|
||||||
return content_tag_without_haml(name, *args) {preserve(&block)}
|
return content_tag_without_haml(name, *args) {preserve(&block)}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -302,23 +302,23 @@ HAML
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_escaped_inline_string_interpolation
|
def test_escaped_inline_string_interpolation
|
||||||
assert_equal("<p>4&3</p>\n", render("%p&== #{2+2}&#{2+1}", :escape_html => true))
|
assert_equal("<p>4&3</p>\n", render("%p&== \#{2+2}&\#{2+1}", :escape_html => true))
|
||||||
assert_equal("<p>4&3</p>\n", render("%p&== #{2+2}&#{2+1}", :escape_html => false))
|
assert_equal("<p>4&3</p>\n", render("%p&== \#{2+2}&\#{2+1}", :escape_html => false))
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_unescaped_inline_string_interpolation
|
def test_unescaped_inline_string_interpolation
|
||||||
assert_equal("<p>4&3</p>\n", render("%p!== #{2+2}&#{2+1}", :escape_html => true))
|
assert_equal("<p>4&3</p>\n", render("%p!== \#{2+2}&\#{2+1}", :escape_html => true))
|
||||||
assert_equal("<p>4&3</p>\n", render("%p!== #{2+2}&#{2+1}", :escape_html => false))
|
assert_equal("<p>4&3</p>\n", render("%p!== \#{2+2}&\#{2+1}", :escape_html => false))
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_escaped_string_interpolation
|
def test_escaped_string_interpolation
|
||||||
assert_equal("<p>\n 4&3\n</p>\n", render("%p\n &== #{2+2}&#{2+1}", :escape_html => true))
|
assert_equal("<p>\n 4&3\n</p>\n", render("%p\n &== \#{2+2}&\#{2+1}", :escape_html => true))
|
||||||
assert_equal("<p>\n 4&3\n</p>\n", render("%p\n &== #{2+2}&#{2+1}", :escape_html => false))
|
assert_equal("<p>\n 4&3\n</p>\n", render("%p\n &== \#{2+2}&\#{2+1}", :escape_html => false))
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_unescaped_string_interpolation
|
def test_unescaped_string_interpolation
|
||||||
assert_equal("<p>\n 4&3\n</p>\n", render("%p\n !== #{2+2}&#{2+1}", :escape_html => true))
|
assert_equal("<p>\n 4&3\n</p>\n", render("%p\n !== \#{2+2}&\#{2+1}", :escape_html => true))
|
||||||
assert_equal("<p>\n 4&3\n</p>\n", render("%p\n !== #{2+2}&#{2+1}", :escape_html => false))
|
assert_equal("<p>\n 4&3\n</p>\n", render("%p\n !== \#{2+2}&\#{2+1}", :escape_html => false))
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_scripts_should_respect_escape_html_option
|
def test_scripts_should_respect_escape_html_option
|
||||||
|
|
|
@ -4,6 +4,8 @@ require 'haml/template'
|
||||||
require 'sass/plugin'
|
require 'sass/plugin'
|
||||||
require File.dirname(__FILE__) + '/mocks/article'
|
require File.dirname(__FILE__) + '/mocks/article'
|
||||||
|
|
||||||
|
require 'action_pack/version'
|
||||||
|
|
||||||
module Haml::Filters::Test
|
module Haml::Filters::Test
|
||||||
include Haml::Filters::Base
|
include Haml::Filters::Base
|
||||||
|
|
||||||
|
@ -28,8 +30,10 @@ class TemplateTest < Test::Unit::TestCase
|
||||||
TEMPLATE_PATH = File.join(File.dirname(__FILE__), "templates")
|
TEMPLATE_PATH = File.join(File.dirname(__FILE__), "templates")
|
||||||
TEMPLATES = %w{ very_basic standard helpers
|
TEMPLATES = %w{ very_basic standard helpers
|
||||||
whitespace_handling original_engine list helpful
|
whitespace_handling original_engine list helpful
|
||||||
silent_script tag_parsing just_stuff partials partial_layout
|
silent_script tag_parsing just_stuff partials
|
||||||
filters nuke_outer_whitespace nuke_inner_whitespace }
|
filters nuke_outer_whitespace nuke_inner_whitespace }
|
||||||
|
# partial layouts were introduced in 2.0.0
|
||||||
|
TEMPLATES << 'partial_layout' unless ActionPack::VERSION::MAJOR < 2
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
vars = { 'article' => Article.new, 'foo' => 'value one' }
|
vars = { 'article' => Article.new, 'foo' => 'value one' }
|
||||||
|
@ -70,7 +74,7 @@ class TemplateTest < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def assert_renders_correctly(name, &render_method)
|
def assert_renders_correctly(name, &render_method)
|
||||||
render_method ||= proc { |name| @base.render(name) }
|
render_method ||= proc { |name| @base.render(:file => name) }
|
||||||
|
|
||||||
load_result(name).split("\n").zip(render_method[name].split("\n")).each_with_index do |pair, line|
|
load_result(name).split("\n").zip(render_method[name].split("\n")).each_with_index do |pair, line|
|
||||||
message = "template: #{name}\nline: #{line}"
|
message = "template: #{name}\nline: #{line}"
|
||||||
|
|
|
@ -35,16 +35,39 @@ click
|
||||||
%p boom
|
%p boom
|
||||||
- concat "foo\n"
|
- concat "foo\n"
|
||||||
- haml_buffer.tabulation = 0
|
- haml_buffer.tabulation = 0
|
||||||
- def url_for(*stuff); stuff.join(' '); end
|
-#
|
||||||
-# The form URLs must be empty
|
-# ActionPack pre-2.0 has weird url_for issues here.
|
||||||
-# because of a weird bug that causes url_for to misbehave.
|
- if ActionPack::VERSION::MAJOR < 2
|
||||||
%p
|
:plain
|
||||||
|
<p>
|
||||||
|
<form action="" method="post">
|
||||||
|
</p>
|
||||||
|
<form action="" method="post">
|
||||||
|
<div><input name="commit" type="submit" value="save" /></div>
|
||||||
|
<p>
|
||||||
|
@foo =
|
||||||
|
value one
|
||||||
|
</p>
|
||||||
|
Toplevel? false
|
||||||
|
<p>
|
||||||
|
@foo =
|
||||||
|
value three
|
||||||
|
</p>
|
||||||
|
</form>
|
||||||
|
<form action="" method="post">
|
||||||
|
Title:
|
||||||
|
<input id="article_title" name="article[title]" size="30" type="text" value="Hello" />
|
||||||
|
Body:
|
||||||
|
<input id="article_body" name="article[body]" size="30" type="text" value="World" />
|
||||||
|
</form>
|
||||||
|
- else
|
||||||
|
%p
|
||||||
= form_tag ''
|
= form_tag ''
|
||||||
- form_tag '' do
|
- form_tag '' do
|
||||||
%div= submit_tag 'save'
|
%div= submit_tag 'save'
|
||||||
- @foo = 'value one'
|
- @foo = 'value one'
|
||||||
= test_partial 'partial'
|
= test_partial 'partial'
|
||||||
- form_for :article, @article, :url => '' do |f|
|
- form_for :article, @article, :url => '' do |f|
|
||||||
Title:
|
Title:
|
||||||
= f.text_field :title
|
= f.text_field :title
|
||||||
Body:
|
Body:
|
||||||
|
|
Loading…
Add table
Reference in a new issue