Skip to content

Commit

Permalink
Fixed some instance variable not initialized warnings.
Browse files Browse the repository at this point in the history
See issue #515

Signed-off-by: Norman Clarke <norman@njclarke.com>
  • Loading branch information
Cristian Rasch authored and norman committed Apr 29, 2012
1 parent 3329fbb commit 97d8ff6
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 7 deletions.
3 changes: 2 additions & 1 deletion lib/haml/compiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,8 @@ def rstrip_buffer!(index = -1)
end

def compile(node)
parent, @node = @node, node
parent = instance_variable_defined?('@node') ? @node : nil
@node = node
if node.children.empty?
send(:"compile_#{node.type}")
else
Expand Down
3 changes: 2 additions & 1 deletion lib/haml/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ def initialize(template, options = {})
# @param block [#to_proc] A block that can be yielded to within the template
# @return [String] The rendered template
def render(scope = Object.new, locals = {}, &block)
buffer = Haml::Buffer.new(scope.instance_variable_get('@haml_buffer'), options_for_buffer)
parent = scope.instance_variable_defined?('@haml_buffer') ? scope.instance_variable_get('@haml_buffer') : nil
buffer = Haml::Buffer.new(parent, options_for_buffer)

if scope.is_a?(Binding) || scope.is_a?(Proc)
scope_object = eval("self", scope)
Expand Down
2 changes: 1 addition & 1 deletion lib/haml/filters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def lazy_require(*reqs)
private

def resolve_lazy_requires
return unless @lazy_requires
return unless instance_variable_defined?('@lazy_requires')

@lazy_requires[0...-1].each do |req|
begin
Expand Down
3 changes: 2 additions & 1 deletion lib/haml/helpers/action_view_extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ def page_class
# @yield A block in which all input to `#haml_concat` is treated as raw.
# @see Haml::Util#rails_xss_safe?
def with_raw_haml_concat
@_haml_concat_raw, old = true, @_haml_concat_raw
@_haml_concat_raw = true
old = @_haml_concat_raw
yield
ensure
@_haml_concat_raw = old
Expand Down
3 changes: 2 additions & 1 deletion lib/haml/helpers/xss_mods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ def capture_haml_with_haml_xss(*args, &block)

# Input is escaped
def haml_concat_with_haml_xss(text = "")
haml_concat_without_haml_xss(@_haml_concat_raw ? text : haml_xss_html_escape(text))
raw = instance_variable_defined?('@_haml_concat_raw') ? @_haml_concat_raw : false
haml_concat_without_haml_xss(raw ? text : haml_xss_html_escape(text))
end

# Output is always HTML safe
Expand Down
5 changes: 3 additions & 2 deletions lib/haml/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -613,9 +613,10 @@ def next_line
# `flat?' here is a little outdated,
# so we have to manually check if either the previous or current line
# closes the flat block, as well as whether a new block is opened.
@line.tabs if @line
line_defined = instance_variable_defined?('@line')
@line.tabs if line_defined
unless (flat? && !closes_flat?(line) && !closes_flat?(@line)) ||
(@line && @line.text[0] == ?: && line.full =~ %r[^#{@line.full[/^\s+/]}\s])
(line_defined && @line.text[0] == ?: && line.full =~ %r[^#{@line.full[/^\s+/]}\s])
return next_line if line.text.empty?

handle_multiline(line)
Expand Down

0 comments on commit 97d8ff6

Please sign in to comment.