def get_pushed_value exp, default = :output
return exp unless sexp? exp
case exp.node_type
when :format
exp.node_type = :output
@current_template.add_output exp
exp
when :format_escaped
exp.node_type = :escaped_output
@current_template.add_output exp
exp
when :str, :ignore, :output, :escaped_output
exp
when :block, :rlist, :dstr
exp.map! { |e| get_pushed_value e }
when :if
clauses = [get_pushed_value(exp.then_clause), get_pushed_value(exp.else_clause)].compact
if clauses.length > 1
s(:or, *clauses)
else
clauses.first
end
else
if call? exp and exp.target == HAML_HELPERS and exp.method == :html_escape
add_escaped_output exp.first_arg
elsif @javascript and call? exp and (exp.method == :j or exp.method == :escape_javascript)
add_escaped_output exp.first_arg
else
add_output exp, default
end
end
end