Sha256: 8cd74692f1007abab51c91c82c3e842b67b08b339f9e2deffde558e6c9bd2431

Contents?: true

Size: 1.07 KB

Versions: 75

Compression:

Stored size: 1.07 KB

Contents

module Fastlane
  class ErbTemplateHelper
    require "erb"
    def self.load(template_name)
      path = "#{Fastlane::ROOT}/lib/assets/#{template_name}.erb"
      load_from_path(path)
    end

    def self.load_from_path(template_filepath)
      unless File.exist?(template_filepath)
        UI.user_error!("Could not find template at path '#{template_filepath}'")
      end
      File.read(template_filepath)
    end

    def self.render(template, template_vars_hash, trim_mode = nil)
      Fastlane::ErbalT.new(template_vars_hash, trim_mode).render(template)
    end
  end
  class ErbalT < OpenStruct
    def initialize(hash, trim_mode = nil)
      super(hash)
      @trim_mode = trim_mode
    end

    def render(template)
      # From Ruby 2.6, ERB.new takes keyword arguments and positional ones are deprecated
      # https://bugs.ruby-lang.org/issues/14256
      if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.6.0")
        ERB.new(template, trim_mode: @trim_mode).result(binding)
      else
        ERB.new(template, nil, @trim_mode).result(binding)
      end
    end
  end
end

Version data entries

75 entries across 75 versions & 4 rubygems

Version Path
fastlane-2.223.1 fastlane/lib/fastlane/erb_template_helper.rb
fastlane-2.223.0 fastlane/lib/fastlane/erb_template_helper.rb
fastlane-2.222.0 fastlane/lib/fastlane/erb_template_helper.rb
fastlane-2.221.1 fastlane/lib/fastlane/erb_template_helper.rb
fastlane-2.221.0 fastlane/lib/fastlane/erb_template_helper.rb
fastlane-2.220.0 fastlane/lib/fastlane/erb_template_helper.rb
fastlane-2.219.0 fastlane/lib/fastlane/erb_template_helper.rb
fastlane-2.218.0 fastlane/lib/fastlane/erb_template_helper.rb
fastlane-security-patched-2.216.0 fastlane/lib/fastlane/erb_template_helper.rb
fastlane-2.217.0 fastlane/lib/fastlane/erb_template_helper.rb
fastlane-2.216.0 fastlane/lib/fastlane/erb_template_helper.rb
fastlane-2.215.1 fastlane/lib/fastlane/erb_template_helper.rb
fastlane-2.215.0 fastlane/lib/fastlane/erb_template_helper.rb
fastlane-mercafacil-2.214.0 fastlane/lib/fastlane/erb_template_helper.rb
fastlane-2.214.0 fastlane/lib/fastlane/erb_template_helper.rb
fastlane-2.213.0 fastlane/lib/fastlane/erb_template_helper.rb
fastlane-2.212.2 fastlane/lib/fastlane/erb_template_helper.rb
fastlane_pricing_fix-2.212.1 fastlane/lib/fastlane/erb_template_helper.rb
fastlane-2.212.1 fastlane/lib/fastlane/erb_template_helper.rb
fastlane-2.212.0 fastlane/lib/fastlane/erb_template_helper.rb