class Google::Apis::Generator::Template
ERB template for the code generator
Public Class Methods
load(template_name)
click to toggle source
Loads a template from the template dir. Automatically appends the .tmpl suffix
@param [String] template_name
Name of the template file
# File lib/google/apis/generator/template.rb, line 101 def self.load(template_name) Template.new(sprintf('%s.tmpl', template_name)) end
new(template_name)
click to toggle source
@param [String] template_name
Name of the template file
# File lib/google/apis/generator/template.rb, line 107 def initialize(template_name) file = File.join(TEMPLATE_DIR, template_name) @erb = ERB.new(File.read(file), nil, '-') end
Public Instance Methods
render(context)
click to toggle source
Render the template
@param [Hash] context
Variables to set when rendering the template
@return [String] rendered template
# File lib/google/apis/generator/template.rb, line 117 def render(context) ctx = Context.new(context) @erb.result(ctx.to_binding) end