lib/pdk/module/templatedir.rb
def config_for(dest_path)
        if @config.nil?
          config_path = File.join(@path, 'config_defaults.yml')

          if File.file?(config_path) && File.readable?(config_path)
            begin
              @config = YAML.safe_load(File.read(config_path), [], [], true)
            rescue StandardError => e
              PDK.logger.warn(_("'%{file}' is not a valid YAML file: %{message}") % { file: config_path, message: e.message })
              @config = {}
            end
          else
            @config = {}
          end
        end

        file_config = @config.fetch(:global, {})
        file_config['module_metadata'] = @module_metadata
        file_config.merge!(@config.fetch(dest_path, {})) unless dest_path.nil?
        file_config
      end
# Generate a hash of data to be used when rendering the specified
# template.
#
# Read `config_defaults.yml` from the root of the template directory (if
# it exists) build a hash of values by merging the value of the `:global`
# key with the value of the key that matches `dest_path`.
#
# @param dest_path [String] The destination path of the file that the
# data is for, relative to the root of the module.
#
# @return [Hash] The data that will be available to the template via the
# `@configs` instance variable.
#
# @api private
Generate a hash of data to be used when rendering the specified
template.


Generate a hash of data to be used when rendering the specified template .
def config_for(dest_path)
        if @config.nil?
          config_path = File.join(@path, 'config_defaults.yml')
          if File.file?(config_path) && File.readable?(config_path)
            begin
              @config = YAML.safe_load(File.read(config_path), [], [], true)
            rescue StandardError => e
              PDK.logger.warn(_("'%{file}' is not a valid YAML file: %{message}") % { file: config_path, message: e.message })
              @config = {}
            end
          else
            @config = {}
          end
        end
        file_config = @config.fetch(:global, {})
        file_config['module_metadata'] = @module_metadata
        file_config.merge!(@config.fetch(dest_path, {})) unless dest_path.nil?
        file_config
      end
def config_for ( dest_path ) if @config . nil? config_path = File . join ( @path , 'config_defaults.yml' ) if File . file? ( config_path ) && File . readable? ( config_path ) begin @config = YAML . safe_load ( File . read ( config_path ) , [ ] , [ ] , true ) rescue StandardError => e PDK . logger . warn ( _ ( "'%{file}' is not a valid YAML file: %{message}" ) % { file : config_path , message : e . message } ) @config = { } end else @config = { } end end file_config = @config . fetch ( :global , { } ) file_config [ 'module_metadata' ] = @module_metadata file_config . merge! ( @config . fetch ( dest_path , { } ) ) unless dest_path . nil? file_config end
Generate a hash of data to be used when rendering the specified
template.
Generate a hash of data to be used when rendering the specified template .
The data that will be available to the template via the `@configs` instance variable.
The data that will be available to the template via the ` @configs ` instance variable .
Hash
dest_path
The destination path of the file that the data is for, relative to the root of the module.
The destination path of the file that the data is for relative to the root of the module .
api
None