module Haml::Precompiler
def push_script(text, opts = {})
If `opts[:preserve_script]` is true, Haml::Helpers#find_and_flatten is run on
the scope object and the result to be added to `@buffer`.
Causes `text` to be evaluated in the context of
def push_script(text, opts = {}) raise SyntaxError.new("There's no Ruby code for = to evaluate.") if text.empty? return if options[:suppress_eval] opts[:escape_html] = options[:escape_html] if opts[:escape_html].nil? args = %w[preserve_script in_tag preserve_tag escape_html nuke_inner_whitespace] args.map! {|name| opts[name.to_sym]} args << !block_opened? << @options[:ugly] no_format = @options[:ugly] && !(opts[:preserve_script] || opts[:preserve_tag] || opts[:escape_html]) output_temp = "(haml_very_temp = haml_temp; haml_temp = nil; haml_very_temp)" out = "_hamlout.#{static_method_name(:format_script, *args)}(#{output_temp});" # Prerender tabulation unless we're in a tag push_merged_text '' unless opts[:in_tag] unless block_opened? @to_merge << [:script, no_format ? "#{text}\n" : "haml_temp = #{text}\n#{out}"] concat_merged_text("\n") unless opts[:in_tag] || opts[:nuke_inner_whitespace] @newlines -= 1 return end flush_merged_text push_silent "haml_temp = #{text}" newline_now push_and_tabulate([:loud, "_hamlout.buffer << #{no_format ? "#{output_temp}.to_s;" : out}", !(opts[:in_tag] || opts[:nuke_inner_whitespace] || @options[:ugly])]) end