Module: Typstify::ErbPipeline

Defined in:
lib/typstify/erb_pipeline.rb

Overview

ERB mode: .typ.erb templates are ordinary ERB whose output is Typst source. Provided for teams migrating from wicked_pdf who want their existing view habits; data mode is the one to reach for.

The distinction that matters: in data mode a user string is data all the way down and cannot change the document. Here it is spliced into source, so every dynamic value must go through typ(). That is not a style preference — an unescaped value is code injection.

Defined Under Namespace

Classes: Context

Class Method Summary collapse

Class Method Details

.render(source, data: nil, assigns: {}) ⇒ String

Returns Typst source.

Returns:

  • (String)

    Typst source



39
40
41
42
# File 'lib/typstify/erb_pipeline.rb', line 39

def render(source, data: nil, assigns: {})
  context = Context.new(data: data, assigns: assigns)
  ERB.new(source, trim_mode: "-").result(context.template_binding)
end