Class: Typstify::ErbPipeline::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/typstify/erb_pipeline.rb

Overview

The object templates are evaluated against. Deliberately small: typ, data, and whatever instance variables the controller had.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data:, assigns: {}) ⇒ Context

Returns a new instance of Context.



18
19
20
21
# File 'lib/typstify/erb_pipeline.rb', line 18

def initialize(data:, assigns: {})
  @data = data
  assigns.each { |name, value| instance_variable_set(:"@#{name}", value) }
end

Instance Attribute Details

#dataObject (readonly)

The data hash passed to render pdf: / Typstify.render.



24
25
26
# File 'lib/typstify/erb_pipeline.rb', line 24

def data
  @data
end

Instance Method Details

#template_bindingObject



31
32
33
# File 'lib/typstify/erb_pipeline.rb', line 31

def template_binding
  binding
end

#typ(value) ⇒ Object

Escape a value so Typst renders it literally. See Typstify::Escaping.



27
28
29
# File 'lib/typstify/erb_pipeline.rb', line 27

def typ(value)
  Escaping.typ(value)
end