Class: AngularRails4Templates::Processor
- Inherits:
-
Object
- Object
- AngularRails4Templates::Processor
show all
- Includes:
- CompactJavaScriptEscape
- Defined in:
- lib/angular-rails-templates/processor.rb,
lib/angular-rails4-templates/processor.rb
Constant Summary
CompactJavaScriptEscape::JS_ESCAPE_MAP
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
#escape_javascript
Constructor Details
#initialize(options = {}) ⇒ Processor
Returns a new instance of Processor.
26
27
28
|
# File 'lib/angular-rails-templates/processor.rb', line 26
def initialize(options = {})
@cache_key = [self.class.name, VERSION, options].freeze
end
|
Instance Attribute Details
#cache_key ⇒ Object
Returns the value of attribute cache_key.
20
21
22
|
# File 'lib/angular-rails-templates/processor.rb', line 20
def cache_key
@cache_key
end
|
#config ⇒ Object
Returns the value of attribute config.
20
21
22
|
# File 'lib/angular-rails-templates/processor.rb', line 20
def config
@config
end
|
Class Method Details
.cache_key ⇒ Object
16
17
18
|
# File 'lib/angular-rails-templates/processor.rb', line 16
def self.cache_key
instance.cache_key
end
|
.call(input) ⇒ Object
12
13
14
|
# File 'lib/angular-rails-templates/processor.rb', line 12
def self.call(input)
instance.call(input)
end
|
.instance ⇒ Object
8
9
10
|
# File 'lib/angular-rails-templates/processor.rb', line 8
def self.instance
@instance ||= new
end
|
Instance Method Details
#call(input) ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/angular-rails-templates/processor.rb', line 39
def call(input)
angular_template_name = template_name(input[:name])
angular_module = config.module_name
html = render_html(input)
source_file = "#{input[:filename]}".sub(/^#{Rails.root}\//,'')
erb = ERB.new(File.read("#{File.dirname __FILE__}/javascript_template.js.erb"))
result = erb.result binding
result
end
|
#render_html(input) ⇒ Object
30
31
32
|
# File 'lib/angular-rails-templates/processor.rb', line 30
def render_html(input)
escape_javascript input[:data].chomp
end
|
#template_name(name) ⇒ Object
34
35
36
37
|
# File 'lib/angular-rails-templates/processor.rb', line 34
def template_name(name)
path = name.sub /^(#{config.ignore_prefix.join('|')})/, ''
"#{path}.html"
end
|