class ReduxGen::Template

Attributes

name[RW]

Public Class Methods

new(component, name, test: false) click to toggle source
# File lib/redux_gen/template.rb, line 5
def initialize(component, name, test: false)
  @renderer = Template.renderer_for component, test: test
  @name = Validations.sanitize component, name
end
path(component) click to toggle source
# File lib/redux_gen/template.rb, line 18
def self.path component
  "#{template_directory}/#{component}.js.erb"
end
renderer_for(component, test: false) click to toggle source
# File lib/redux_gen/template.rb, line 26
def self.renderer_for component, test: false
  path = test ? Template.test_path(component) : Template.path(component)
  ERB.new(open(path).read)
end
template_directory() click to toggle source
# File lib/redux_gen/template.rb, line 14
def self.template_directory
  File.expand_path("../../../template", __FILE__)
end
test_path(component) click to toggle source
# File lib/redux_gen/template.rb, line 22
def self.test_path component
  "#{template_directory}/#{component}.spec.js.erb"
end

Public Instance Methods

render() click to toggle source
# File lib/redux_gen/template.rb, line 10
def render
  @renderer.result(binding)
end