Class: HSQL::Template

Inherits:
Object
  • Object
show all
Defined in:
lib/hsql/template.rb

Overview

Given some SQL that may contain Mustache tags (e.g. variable }} ), accept a hash of data that interpolates each tag. Throws an error if one of the tag names can’t be found in the data.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input) ⇒ Template

Returns a new instance of Template.



9
10
11
# File 'lib/hsql/template.rb', line 9

def initialize(input)
  @input = input
end

Instance Attribute Details

#inputObject (readonly)

Returns the value of attribute input.



7
8
9
# File 'lib/hsql/template.rb', line 7

def input
  @input
end

Instance Method Details

#render(hash) ⇒ Object



17
18
19
# File 'lib/hsql/template.rb', line 17

def render(hash)
  Mustache.render(input, hash)
end

#variable_namesObject



13
14
15
# File 'lib/hsql/template.rb', line 13

def variable_names
  extract_variable_names(ast).uniq
end