Class: OpenxmlDocxTemplater::DocxEruby

Inherits:
Object
  • Object
show all
Includes:
Debug
Defined in:
lib/openxml_docx_templater/docx_eruby.rb

Constant Summary collapse

EMBEDDED_PATTERN =
/\{%([=%]+)?(.*?)-?%\}/m

Instance Method Summary collapse

Methods included from Debug

#debug?, #debug_dir, #debug_file_name, #debug_file_path

Constructor Details

#initialize(template) ⇒ DocxEruby

Returns a new instance of DocxEruby.



9
10
11
12
13
14
15
# File 'lib/openxml_docx_templater/docx_eruby.rb', line 9

def initialize(template)
  @src = convert template
  return unless debug?
  File.open(debug_file_path, 'w') do |f|
    f << @src
  end
end

Instance Method Details

#evaluate(context) ⇒ Object



17
18
19
# File 'lib/openxml_docx_templater/docx_eruby.rb', line 17

def evaluate(context)
  eval(@src, context)
end