Class: Templates::TemplateRenderer

Inherits:
Object
  • Object
show all
Defined in:
lib/bujo/templates/template_renderer.rb

Instance Method Summary collapse

Instance Method Details

#render(template_relative_path, placeholders_replacements) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/bujo/templates/template_renderer.rb', line 6

def render(template_relative_path, placeholders_replacements)
  template_path = Configuration::Structure.global_plugin_asset_path(template_relative_path)
  template = File.read(template_path)

  placeholders_replacements
      .each { |placeholder, replacement| template = template.gsub(/\${#{placeholder}}/, replacement) }

  template
end