fastlane/lib/fastlane/actions/erb.rb in fastlane-2.152.0 vs fastlane/lib/fastlane/actions/erb.rb in fastlane-2.153.0

- old
+ new

@@ -1,11 +1,14 @@ module Fastlane module Actions class ErbAction < Action def self.run(params) template = File.read(params[:template]) - result = ERB.new(template).result(OpenStruct.new(params[:placeholders]).instance_eval { binding }) + trim_mode = params[:trim_mode] + + result = Fastlane::ErbTemplateHelper.render(template, params[:placeholders], trim_mode) + File.open(params[:destination], 'w') { |file| file.write(result) } if params[:destination] UI.message("Successfully parsed template: '#{params[:template]}' and rendered output to: #{params[:destination]}") if params[:destination] result end @@ -43,10 +46,15 @@ short_option: "-p", env_name: "FL_ERB_PLACEHOLDERS", description: "Placeholders given as a hash", default_value: {}, is_string: false, - type: Hash) + type: Hash), + FastlaneCore::ConfigItem.new(key: :trim_mode, + short_option: "-t", + env_name: "FL_ERB_TRIM_MODE", + description: "Trim mode applied to the ERB", + optional: true) ] end def self.authors