Class: Tilt::SigilTemplate

Inherits:
Template show all
Defined in:
lib/tilt/sigil.rb

Overview

Standalone string interpolator and template processor implementation in Go. see: github.com/gliderlabs/sigil

Instance Attribute Summary

Attributes inherited from Template

#data, #file, #line, #options

Instance Method Summary collapse

Methods inherited from Template

#basename, default_mime_type, default_mime_type=, #eval_file, #initialize, metadata, #metadata, #name, #render

Constructor Details

This class inherits a constructor from Tilt::Template

Instance Method Details

#allows_script?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/tilt/sigil.rb', line 30

def allows_script?
  false
end

#evaluate(scope, locals, &block) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/tilt/sigil.rb', line 11

def evaluate(scope, locals, &block)
  variables = locals.map {|k, v| "#{k}=#{v}" }

  cmd = ['sigil']

  unless variables.empty?
    cmd << '-p'
    cmd.concat(variables)
  end

  out, err, status = Open3.capture3(*cmd, :stdin_data => data)

  if status.success?
    out.chomp
  else
    raise err.chomp.gsub('<stdin>', file)
  end
end

#prepareObject



8
9
# File 'lib/tilt/sigil.rb', line 8

def prepare
end