class Scribble::Template

Public Class Methods

new(source, format: nil, loader: nil, converters: []) click to toggle source
Calls superclass method Scribble::Partial::new
# File lib/scribble/template.rb, line 4
def initialize source, format: nil, loader: nil, converters: []
  super source, format: format
  @loader, @converters = loader, converters
end

Public Instance Methods

find_converter(from, to) click to toggle source

Find converter

# File lib/scribble/template.rb, line 57
def find_converter from, to
  @converters.find { |converter| converter.from == from && converter.to == to }
end
load(name, context) click to toggle source

Load partial

# File lib/scribble/template.rb, line 45
def load name, context
  if @loader
    if partial = @loader.load(name)
      Partial::Context.new partial, context
    end
  else
    raise 'Cannot load partial without loader'
  end
end
render(variables: {}) click to toggle source

Render

# File lib/scribble/template.rb, line 39
def render variables: {}, registers: {}, format: nil
  Context.new(self, registers, variables, format).render
end