Class: ProcessIt::JsMinTemplate

Inherits:
Tilt::Template
  • Object
show all
Defined in:
lib/processit/processor/jsmin_template.rb

Overview

Tilt engine class for the JSMin compiler. Depends on the ‘jsmin` gem.

For more infomation see:

rubygems.org/gems/jsmin

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.engine_initialized?Boolean

Check to see if JSMin is loaded

Returns:

  • (Boolean)


12
13
14
# File 'lib/processit/processor/jsmin_template.rb', line 12

def self.engine_initialized?
  defined? ::JSMin
end

Instance Method Details

#evaluate(scope, locals, &block) ⇒ Object

Compile template data with JSMin compiler.



28
29
30
# File 'lib/processit/processor/jsmin_template.rb', line 28

def evaluate(scope, locals, &block)
  @output ||= ::JSMin.minify(data)
end

#initialize_engineObject

Autoload jsmin library. If the library isn’t loaded, Tilt will produce a thread safetly warning. If you intend to use ‘.js` files, you should explicitly require it.



19
20
21
# File 'lib/processit/processor/jsmin_template.rb', line 19

def initialize_engine
  require_template_library 'jsmin'
end

#prepareObject



23
24
25
# File 'lib/processit/processor/jsmin_template.rb', line 23

def prepare
		@output = nil
end