Permalink
Browse files

Tagging 1.5.1.

git-svn-id: svn://hamptoncatlin.com/haml/tags/rel_1-5-1@468 7063305b-7217-0410-af8c-cdc13e5119b9
  • Loading branch information...
1 parent fb95cc2 commit 524d4dbb4bbe3dc12d233e50e33671839096a40d @nex3 nex3 committed Mar 31, 2007
View
@@ -1 +1 @@
-1.5.0
+1.5.1
View
@@ -129,13 +129,6 @@ def initialize(template, options = {})
}
}
- unless @options[:suppress_eval]
- @options[:filters].merge!({
- 'erb' => ERB,
- 'ruby' => Haml::Filters::Ruby
- })
- end
-
if !NOT_LOADED.include? 'redcloth'
@options[:filters].merge!({
'redcloth' => RedCloth,
@@ -149,6 +142,14 @@ def initialize(template, options = {})
@options.rec_merge! options
+ unless @options[:suppress_eval]
+ @options[:filters].merge!({
+ 'erb' => ERB,
+ 'ruby' => Haml::Filters::Ruby
+ })
+ end
+ @options[:filters].rec_merge! options[:filters] if options[:filters]
+
@precompiled = @options[:precompiled]
@template = template.strip #String
@@ -309,8 +310,9 @@ def process_line(line, index, block_opened)
when SILENT_SCRIPT
sub_line = line[1..-1]
unless sub_line[0] == SILENT_COMMENT
- push_silent(sub_line, true)
- if @block_opened && !mid_block_keyword?(line)
+ mbk = mid_block_keyword?(line)
+ push_silent(sub_line, !mbk)
+ if (@block_opened && !mbk) || line[1..-1].split(' ', 2)[0] == "case"
push_and_tabulate([:script])
end
end
@@ -589,7 +591,7 @@ def render_tag(line)
warn(FLAT_WARNING) if flattened && !defined?(Test::Unit)
value_exists = !value.empty?
- attributes_hash = "nil" unless attributes_hash
+ attributes_hash = "nil" if attributes_hash.nil? || @options[:suppress_eval]
object_ref = "nil" unless object_ref
if @block_opened
View
@@ -8,12 +8,12 @@ module Haml
module Helpers
self.extend self
- @@action_view = false
+ @@action_view_defined = defined?(ActionView)
@@force_no_action_view = false
# Returns whether or not ActionView is installed on the system.
def self.action_view?
- @@action_view
+ @@action_view_defined
end
# Isolates the whitespace-sensitive tags in the string and uses preserve
@@ -186,11 +186,6 @@ def capture_haml(*args, &block)
end
private
-
- # Sets whether or not ActionView is installed on the system.
- def self.action_view(value) # :nodoc:
- @@action_view = value
- end
# Gets a reference to the current Haml::Buffer object.
def buffer
@@ -226,6 +221,7 @@ def capture_haml_with_buffer(local_buffer, *args, &block)
end
result.to_s
end
+ alias_method :capture_erb_with_buffer, :capture_haml_with_buffer
# Returns whether or not the current template is a Haml template.
#
@@ -235,8 +231,6 @@ def capture_haml_with_buffer(local_buffer, *args, &block)
def is_haml?
@haml_stack ? @haml_stack.size > 0 : false
end
-
- include ActionViewMods if self.const_defined? "ActionViewMods"
end
end
@@ -9,42 +9,24 @@
end
if action_view_included
- class ActionView::Base
- alias_method :old_concat, :concat unless instance_methods.include? "old_concat"
- alias_method :old_form_tag, :form_tag unless instance_methods.include? "old_form_tag"
-
- alias_method :old_form_for, :form_for unless instance_methods.include? "old_form_for"
- end
-
- module Haml
+ module ActionView
+ # This overrides various helpers in ActionView
+ # to make them work more effectively with Haml.
module Helpers
- # This module overrides various helpers in ActionView
- # to make them work more effectively with Haml.
- # It also defines several helper methods,
- # available from a Haml template,
- # which are only useful within the context of ActionView.
- # It's not available unless ActionView is installed.
- #
- #--
- # Methods in this module should be nodoc'd.
- #++
- module ActionViewMods
- def self.included(othermod) # :nodoc:
- othermod.class_eval do
- action_view(true)
- alias_method :capture_erb_with_buffer, :capture_haml_with_buffer
- end
- end
-
- def concat(string, binding = nil) # :nodoc:
+ # :stopdoc:
+ module TextHelper
+ def concat_with_haml(string, binding = nil)
if is_haml?
buffer.buffer.concat(string)
else
- old_concat(string, binding)
+ concat_without_haml(string, binding)
end
end
-
- def form_tag(url_for_options = {}, options = {}, *parameters_for_url, &proc) # :nodoc:
+ alias_method_chain :concat, :haml
+ end
+
+ module FormTagHelper
+ def form_tag_with_haml(url_for_options = {}, options = {}, *parameters_for_url, &proc)
if block_given? && is_haml?
oldproc = proc
proc = bind_proc do |*args|
@@ -54,29 +36,33 @@ def form_tag(url_for_options = {}, options = {}, *parameters_for_url, &proc) # :
tab_down
end
end
- res = old_form_tag(url_for_options, options, *parameters_for_url, &proc) + "\n"
+ res = form_tag_without_haml(url_for_options, options, *parameters_for_url, &proc) + "\n"
concat "\n" if block_given? && is_haml?
res
end
-
- def form_for(object_name, *args, &proc) # :nodoc:
+ alias_method_chain :form_tag, :haml
+ end
+
+ module FormHelper
+ def form_for_with_haml(object_name, *args, &proc)
if block_given? && is_haml?
oldproc = proc
proc = bind_proc do |*args|
tab_up
oldproc.call(*args)
tab_down
- end
+ end
end
- old_form_for(object_name, *args, &proc)
+ form_for_without_haml(object_name, *args, &proc)
concat "\n" if block_given? && is_haml?
end
-
- def generate_content_class_names
- controller.controller_name + " " + controller.action_name
- end
+ alias_method_chain :form_for, :haml
+ end
+
+ def generate_content_class_names
+ controller.controller_name + " " + controller.action_name
end
+ # :startdoc:
end
end
end
-
View
@@ -57,6 +57,15 @@ def test_multi_render
def test_stop_eval
assert_equal("", render("= 'Hello'", :suppress_eval => true))
+ assert_equal("<div id='foo' />\n", render("#foo{:yes => 'no'}/", :suppress_eval => true))
+
+ begin
+ assert_equal("", render(":ruby\n puts 'hello'", :suppress_eval => true))
+ rescue Haml::HamlError => err
+ caught = true
+ assert_equal('Filter "ruby" is not defined!', err.message)
+ end
+ assert(caught, "Rendering a ruby filter without evaluating didn't throw an error!")
end
def test_attr_wrapper
View
@@ -62,9 +62,9 @@ def test_helpers_dont_leak
begin
ActionView::Base.new.render(:inline => "<%= concat('foo') %>")
- rescue ArgumentError
+ rescue ArgumentError, NameError
proper_behavior = true
- end
+ end
assert(proper_behavior)
end
@@ -41,3 +41,5 @@ stuff followed by whitespace
Woah a period.
<![endif]-->
testtest
+<foo />
+<foo />
@@ -38,4 +38,14 @@
/[if gte IE5.2]
Woah a period.
= "test" |
- "test" |
+ "test" |
+- case :foo
+- when :bar
+ %bar/
+- when :foo
+ %foo/
+- case :foo
+ - when :bar
+ %bar/
+ - when :foo
+ %foo/

0 comments on commit 524d4db

Please sign in to comment.