HEX
Server: Apache
System: Linux pdx1-shared-a1-38 6.6.104-grsec-jammy+ #3 SMP Tue Sep 16 00:28:11 UTC 2025 x86_64
User: mmickelson (3396398)
PHP: 8.1.31
Disabled: NONE
Upload Files
File: //usr/lib/ruby/vendor_ruby/tilt/sigil.rb
require 'open3'
require 'shellwords'

module Tilt
  # Standalone string interpolator and template processor implementation in Go.
  # see: https://github.com/gliderlabs/sigil
  class SigilTemplate < Template
    def prepare
    end

    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

    def allows_script?
      false
    end
  end
end