Sha256: a3aae4a5fc8093e1fe842aabcac45346ceb95e74421f52edee313934acd3981f

Contents?: true

Size: 781 Bytes

Versions: 16

Compression:

Stored size: 781 Bytes

Contents

require "erb"

# Build the template
def build_template(template, destination, binding)

  template_file = get_template_file(template)

  result = ERB.new(template_file, nil, '-').result(binding)

  if destination
    File.open(destination.to_s, 'w+') do |f|
      f.write(result)
    end
  else
    return StringIO.new(result)
  end
end

# Render one nested error partial
def partial(filename, binding)
  template_file = get_template_file(filename)
  ERB.new(template_file, nil, '-', '_erbout2').result(binding)
end

# Get the template file from the project and fallback to the gem
def get_template_file(filename)
  if File.exists?(filename)
    templateFile = filename
  else
    templateFile = File.expand_path("../../#{filename}", __FILE__)
  end

  File.read(templateFile)
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
negroku-2.8.6 lib/negroku/helpers/templates.rb
negroku-2.8.5 lib/negroku/helpers/templates.rb
negroku-2.8.4 lib/negroku/helpers/templates.rb
negroku-2.8.3 lib/negroku/helpers/templates.rb
negroku-2.8.2 lib/negroku/helpers/templates.rb
negroku-2.8.1 lib/negroku/helpers/templates.rb
negroku-2.8.0 lib/negroku/helpers/templates.rb
negroku-2.7.1 lib/negroku/helpers/templates.rb
negroku-2.7.0 lib/negroku/helpers/templates.rb
negroku-2.6.0 lib/negroku/helpers/templates.rb
negroku-2.5.5 lib/negroku/helpers/templates.rb
negroku-2.5.4 lib/negroku/helpers/templates.rb
negroku-2.5.3 lib/negroku/helpers/templates.rb
negroku-2.5.2 lib/negroku/helpers/templates.rb
negroku-2.5.1 lib/negroku/helpers/templates.rb
negroku-2.5.0 lib/negroku/helpers/templates.rb