Sha256: fa5fb30f6567a9dbfe61baa119b8d408837e54d5adfc26620114b5121ea48719

Contents?: true

Size: 859 Bytes

Versions: 17

Compression:

Stored size: 859 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

    puts I18n.t(:written_file, scope: :negroku, file: destination)
  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("../../templates/#{filename}", __FILE__)
  end

  File.read(templateFile)
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
negroku-2.4.2 lib/negroku/helpers/templates.rb
negroku-2.4.1 lib/negroku/helpers/templates.rb
negroku-2.4.0 lib/negroku/helpers/templates.rb
negroku-2.3.5 lib/negroku/helpers/templates.rb
negroku-2.3.4 lib/negroku/helpers/templates.rb
negroku-2.3.3 lib/negroku/helpers/templates.rb
negroku-2.3.2 lib/negroku/helpers/templates.rb
negroku-2.3.1 lib/negroku/helpers/templates.rb
negroku-2.3.0 lib/negroku/helpers/templates.rb
negroku-2.2.0 lib/negroku/helpers/templates.rb
negroku-2.1.0 lib/negroku/helpers/templates.rb
negroku-2.0.3 lib/negroku/helpers/templates.rb
negroku-2.0.2 lib/negroku/helpers/templates.rb
negroku-2.0.1 lib/negroku/helpers/templates.rb
negroku-2.0.0 lib/negroku/helpers/templates.rb
negroku-2.0.0.pre7 lib/negroku/helpers/templates.rb
negroku-2.0.0.pre6 lib/negroku/helpers/templates.rb