Class: ActionView::DependencyTracker::ERBTracker

Inherits:
Object
  • Object
show all
Defined in:
lib/action_view/dependency_tracker.rb

Constant Summary collapse

EXPLICIT_DEPENDENCY =
/# Template Dependency: (\S+)/
RENDER_DEPENDENCY =

Matches:

render partial: "comments/comment", collection: commentable.comments
render "comments/comments"
render 'comments/comments'
render('comments/comments')

render(@topic)         => render("topics/topic")
render(topics)         => render("topics/topic")
render(message.topics) => render("topics/topic")
/
  render\s*                     # render, followed by optional whitespace
  \(?                           # start an optional parenthesis for the render call
  (partial:|:partial\s+=>)?\s*  # naming the partial, used with collection -- 1st capture
  ([@a-z"'][@\w\/\."']+)        # the template name itself -- 2nd capture
/x

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, template) ⇒ ERBTracker

Returns a new instance of ERBTracker.



49
50
51
# File 'lib/action_view/dependency_tracker.rb', line 49

def initialize(name, template)
  @name, @template = name, template
end

Class Method Details

.call(name, template) ⇒ Object



45
46
47
# File 'lib/action_view/dependency_tracker.rb', line 45

def self.call(name, template)
  new(name, template).dependencies
end

Instance Method Details

#dependenciesObject



53
54
55
# File 'lib/action_view/dependency_tracker.rb', line 53

def dependencies
  render_dependencies + explicit_dependencies
end