class AngularRailsTemplates::Processor
Constants
- AngularJsTemplateWrapper
Attributes
cache_key[R]
Public Class Methods
cache_key()
click to toggle source
# File lib/angular-rails-templates/processor.rb, line 18 def self.cache_key instance.cache_key end
call(input)
click to toggle source
# File lib/angular-rails-templates/processor.rb, line 14 def self.call(input) instance.call(input) end
instance()
click to toggle source
# File lib/angular-rails-templates/processor.rb, line 10 def self.instance @instance ||= new end
new(options = {})
click to toggle source
# File lib/angular-rails-templates/processor.rb, line 28 def initialize(options = {}) @cache_key = [self.class.name, VERSION, options].freeze end
Public Instance Methods
call(input)
click to toggle source
# File lib/angular-rails-templates/processor.rb, line 37 def call(input) file_path = Pathname.new(input[:filename]).relative_path_from(Rails.root).to_s unless config.inside_paths.any? { |folder| file_path.match(folder.to_s) } return input[:data] end locals = {} locals[:angular_template_name] = template_name(input[:name]) locals[:angular_module] = config.module_name locals[:source_file] = "#{input[:filename]}".sub(/^#{Rails.root}\//,'') locals[:html] = escape_javascript(input[:data].chomp) AngularJsTemplateWrapper.render(nil, locals) end
config()
click to toggle source
# File lib/angular-rails-templates/processor.rb, line 24 def config Rails.configuration.angular_templates end
template_name(name)
click to toggle source
# File lib/angular-rails-templates/processor.rb, line 32 def template_name(name) path = name.sub(/^#{config.ignore_prefix.join('|')}/, '') "#{path}.#{config.extension}" end