class Hippo::Templates::Latex

Constants

ALL

Attributes

id[R]

Public Class Methods

for_identifier(id) click to toggle source
# File lib/hippo/templates/latex.rb, line 11
def self.for_identifier(id)
    ALL.find{|tmpl| tmpl.identifier == id}
end
inherited(klass) click to toggle source
# File lib/hippo/templates/latex.rb, line 26
def self.inherited(klass)
    ALL << klass
end
new(id) click to toggle source
# File lib/hippo/templates/latex.rb, line 32
def initialize(id)
    @id = id
end

Public Instance Methods

as_latex() click to toggle source
# File lib/hippo/templates/latex.rb, line 46
def as_latex
    engine.compile_latex
end
as_pdf() click to toggle source
# File lib/hippo/templates/latex.rb, line 36
def as_pdf
    engine.to_stringio
rescue ErbLatex::LatexError => e
    Hippo.logger.warn e.log
    raise
rescue => e
    Hippo.logger.warn e
    raise
end
context() click to toggle source
# File lib/hippo/templates/latex.rb, line 76
def context
    Context
end
engine() click to toggle source
# File lib/hippo/templates/latex.rb, line 96
def engine
    ErbLatex::Template.new(pathname, engine_options)
end
engine_options() click to toggle source
# File lib/hippo/templates/latex.rb, line 80
def engine_options
    options = {
        data: variables,
        context: context,
        partials_path: root_path.join('partials'),
        packages_path: root_path.join('packages')

    }
    options[:layout] = layout unless layout.blank?
    options
end
extension() click to toggle source
# File lib/hippo/templates/latex.rb, line 62
def extension
    '.tex.erb'
end
layout() click to toggle source
# File lib/hippo/templates/latex.rb, line 92
def layout
    root_path.join('layout.tex.erb')
end
record() click to toggle source
# File lib/hippo/templates/latex.rb, line 58
def record
    @record ||= model.find(id)
end
render() click to toggle source
# File lib/hippo/templates/latex.rb, line 66
def render
    engine.to_stringio
rescue ErbLatex::LatexError => e
    Hippo.logger.warn e.log
    raise
rescue => e
    Hippo.logger.warn e
    raise
end
root_path() click to toggle source
Calls superclass method Hippo::Templates::Base#root_path
# File lib/hippo/templates/latex.rb, line 50
def root_path
    super.join('latex')
end
variables() click to toggle source
# File lib/hippo/templates/latex.rb, line 54
def variables
    { 'root_path' => root_path, class_as_name => record }
end