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

#compiled_path, #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)


32
33
34
# File 'lib/tilt/sigil.rb', line 32

def allows_script?
  false
end

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



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

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



10
11
# File 'lib/tilt/sigil.rb', line 10

def prepare
end