Module: Lvr

Defined in:
lib/lvr.rb,
lib/lvr/refine.rb,
lib/lvr/version.rb,
lib/lvr/template.rb,
lib/lvr/refine/core.rb,
lib/lvr/template/tags.rb,
lib/lvr/template/filters.rb

Overview

This is free and unencumbered software released into the public domain.

Defined Under Namespace

Modules: Refine, VERSION Classes: Template

Class Method Summary collapse

Class Method Details

.codegen(output_path, template_path, **context) ⇒ Object

Codegen an output file from a given template and context.

Parameters:

  • output_path (Pathname, #to_s)

    The path to write the rendered template to

  • template_path (Pathname, #to_s)

    The template to render

  • context (Hash)

    The context to render the template with



10
11
12
13
14
15
16
# File 'lib/lvr.rb', line 10

def self.codegen(output_path, template_path, **context)
  File.open(output_path.to_s, 'w') do |output_file|
    template = Template.load(template_path.to_s)
    output = template.render(**context)
    output_file.write(output)
  end
end