Module: Pug::CompilationEssentials

Included in:
ShippedCompiler, SystemCompiler
Defined in:
lib/pug-ruby/compilation-essentials.rb

Overview

Used to share common things between compilers.

Instance Method Summary collapse

Instance Method Details

#process_result(source, result, options) ⇒ String

Responds for post-processing compilation result.

Parameters:

  • source (String)

    The source code of template.

  • result (String)

    The compiled code of template.

  • options (Hash)

    The compilation options.

Returns:

  • (String)


16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/pug-ruby/compilation-essentials.rb', line 16

def process_result(source, result, options)
  if options[:client]
    if options[:inline_runtime_functions]
      "(function() { #{ super }; return #{ options[:name] }; }).call(this);"
    else
      pug = "typeof pugRuntime === 'object' && pugRuntime !== null ? pugRuntime : pug"
      "(function(pug) { #{ super }; return #{ options[:name] }; }).call(this, #{ pug });"
    end
  else
    super
  end
end