Class: HappyTitles::Template
- Inherits:
-
Object
- Object
- HappyTitles::Template
- Defined in:
- lib/happy-titles/template.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(name:, without_title:, with_title:) ⇒ Template
constructor
A new instance of Template.
- #render(title:, tagline:, site:) ⇒ Object
Constructor Details
#initialize(name:, without_title:, with_title:) ⇒ Template
Returns a new instance of Template.
6 7 8 9 10 |
# File 'lib/happy-titles/template.rb', line 6 def initialize(name:, without_title:, with_title:) @name = name.to_sym @with_title = with_title @without_title = without_title end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/happy-titles/template.rb', line 4 def name @name end |
Instance Method Details
#render(title:, tagline:, site:) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/happy-titles/template.rb', line 12 def render(title:, tagline:, site:) template = (title && with_title) ? with_title : without_title substitute_placeholders( template, title: title || tagline, tagline: tagline, site: site ) end |