Class: ReduxGen::Template
- Inherits:
-
Object
- Object
- ReduxGen::Template
- Defined in:
- lib/redux_gen/template.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(component, name) ⇒ Template
constructor
A new instance of Template.
- #render ⇒ Object
Constructor Details
#initialize(component, name) ⇒ Template
Returns a new instance of Template.
5 6 7 8 |
# File 'lib/redux_gen/template.rb', line 5 def initialize(component, name) @renderer = Template.renderer_for component @name = Validations.sanitize component, name end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/redux_gen/template.rb', line 3 def name @name end |
Class Method Details
.path(component) ⇒ Object
18 19 20 |
# File 'lib/redux_gen/template.rb', line 18 def self.path component "#{template_directory}/#{component}.js.erb" end |
.renderer_for(component) ⇒ Object
22 23 24 |
# File 'lib/redux_gen/template.rb', line 22 def self.renderer_for component ERB.new(open(Template.path(component)).read) end |
.template_directory ⇒ Object
14 15 16 |
# File 'lib/redux_gen/template.rb', line 14 def self.template_directory File.("../../../template", __FILE__) end |
Instance Method Details
#render ⇒ Object
10 11 12 |
# File 'lib/redux_gen/template.rb', line 10 def render @renderer.result(binding) end |