lib/pdk/module/template_dir/base.rb
def render
          require 'pdk/template_file'

          PDK::Module::TemplateDir.files_in_template(@dirs).each do |template_file, template_loc|
            template_file = template_file.to_s
            PDK.logger.debug(_("Rendering '%{template}'...") % { template: template_file })
            dest_path = template_file.sub(%r{\.erb\Z}, '')
            config = config_for(dest_path)

            dest_status = if template_loc.start_with?(@moduleroot_init)
                            :init
                          else
                            :manage
                          end

            if config['unmanaged']
              dest_status = :unmanage
            elsif config['delete']
              dest_status = :delete
            else
              begin
                dest_content = PDK::TemplateFile.new(File.join(template_loc, template_file), configs: config, template_dir: self).render
              rescue => error
                error_msg = _(
                  "Failed to render template '%{template}'\n" \
                  '%{exception}: %{message}',
                ) % { template: template_file, exception: error.class, message: error.message }
                raise PDK::CLI::FatalError, error_msg
              end
            end

            yield dest_path, dest_content, dest_status
          end
        end
# Loop through the files in the template, yielding each rendered file to
# the supplied block.
#
# @yieldparam dest_path [String] The path of the destination file,
# relative to the root of the module.
# @yieldparam dest_content [String] The rendered content of the
# destination file.
#
# @raise [PDK::CLI::FatalError] If the template fails to render.
#
# @return [void]
#
# @api public
Loop through the files in the template, yielding each rendered file to
the supplied block.
Loop through the files in the template yielding each rendered file to the supplied block .
def render
          require 'pdk/template_file'
          PDK::Module::TemplateDir.files_in_template(@dirs).each do |template_file, template_loc|
            template_file = template_file.to_s
            PDK.logger.debug(_("Rendering '%{template}'...") % { template: template_file })
            dest_path = template_file.sub(%r{\.erb\Z}, '')
            config = config_for(dest_path)
            dest_status = if template_loc.start_with?(@moduleroot_init)
                            :init
                          else
                            :manage
                          end
            if config['unmanaged']
              dest_status = :unmanage
            elsif config['delete']
              dest_status = :delete
            else
              begin
                dest_content = PDK::TemplateFile.new(File.join(template_loc, template_file), configs: config, template_dir: self).render
              rescue => error
                error_msg = _(
                  "Failed to render template '%{template}'\n" \
                  '%{exception}: %{message}',
                ) % { template: template_file, exception: error.class, message: error.message }
                raise PDK::CLI::FatalError, error_msg
              end
            end
            yield dest_path, dest_content, dest_status
          end
        end
def render require 'pdk/template_file' PDK :: Module :: TemplateDir . files_in_template ( @dirs ) . each do | template_file , template_loc | template_file = template_file . to_s PDK . logger . debug ( _ ( "Rendering '%{template}'..." ) % { template : template_file } ) dest_path = template_file . sub ( %r{ \. erb \Z } , '' ) config = config_for ( dest_path ) dest_status = if template_loc . start_with? ( @moduleroot_init ) :init else :manage end if config [ 'unmanaged' ] dest_status = :unmanage elsif config [ 'delete' ] dest_status = :delete else begin dest_content = PDK :: TemplateFile . new ( File . join ( template_loc , template_file ) , configs : config , template_dir : self ) . render rescue => error error_msg = _ ( "Failed to render template '%{template}'\n" '%{exception}: %{message}' , ) % { template : template_file , exception : error . class , message : error . message } raise PDK :: CLI :: FatalError , error_msg end end yield dest_path , dest_content , dest_status end end
Loop through the files in the template, yielding each rendered file to
the supplied block.
Loop through the files in the template yielding each rendered file to the supplied block .
None
void
[PDK::CLI::FatalError] If the template fails to render.
[ PDK :: CLI :: FatalError ] If the template fails to render .
dest_path
The path of the destination file, relative to the root of the module.
The path of the destination file relative to the root of the module .
dest_content
The rendered content of the destination file.
The rendered content of the destination file .
api
None