Class: Angular::Html2js::Template

Inherits:
Tilt::Template
  • Object
show all
Defined in:
lib/angular/html2js/template.rb

Direct Known Subclasses

Engine

Constant Summary collapse

TEMPLATE =
<<-TEMPLATE
angular.module('%s', []).run(['$templateCache', function($templateCache) {
  $templateCache.put('%s',
  '%s');
}]);
TEMPLATE
SINGLE_MODULE_TPL =
<<-SINGLE_MODULE_TPL
(function(module) {
  try {
    module = angular.module('%s');
  } catch (e) {
    module = angular.module('%s', []);
  }
  module.run(['$templateCache', function($templateCache) {
    $templateCache.put('%s',
    '%s');
  }]);
})();
SINGLE_MODULE_TPL

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#fileObject

Returns the value of attribute file.



7
8
9
# File 'lib/angular/html2js/template.rb', line 7

def file
  @file
end

Class Method Details

.default_mime_typeObject



9
10
11
# File 'lib/angular/html2js/template.rb', line 9

def self.default_mime_type
  'application/javascript'
end

Instance Method Details

#configObject



35
36
37
# File 'lib/angular/html2js/template.rb', line 35

def config
  Html2js.config
end

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



41
42
43
44
45
46
47
48
49
50
# File 'lib/angular/html2js/template.rb', line 41

def evaluate(scope, locals, &block)
  @module_name = config.module_name
  @cache_id = config.cache_id || default_cache_id_proc
  @scope = scope
  if @module_name
    SINGLE_MODULE_TPL % [@module_name, @module_name, cache_id, escapeContent(data)]
  else
    TEMPLATE % [cache_id, cache_id, escapeContent(data)]
  end
end

#prepareObject



39
# File 'lib/angular/html2js/template.rb', line 39

def prepare; end