lib/pdk/module/templatedir.rb
def render
        files_in_template.each do |template_file|
          PDK.logger.debug(_("Rendering '%{template}'...") % { template: template_file })
          dest_path = template_file.sub(%r{\.erb\Z}, '')

          begin
            dest_content = PDK::TemplateFile.new(File.join(@moduleroot_dir, template_file), configs: config_for(dest_path)).render
          rescue => e
            error_msg = _(
              "Failed to render template '%{template}'\n" \
              '%{exception}: %{message}',
            ) % { template: template_file, exception: e.class, message: e.message }
            raise PDK::CLI::FatalError, error_msg
          end

          yield dest_path, dest_content
        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
        files_in_template.each do |template_file|
          PDK.logger.debug(_("Rendering '%{template}'...") % { template: template_file })
          dest_path = template_file.sub(%r{\.erb\Z}, '')
          begin
            dest_content = PDK::TemplateFile.new(File.join(@moduleroot_dir, template_file), configs: config_for(dest_path)).render
          rescue => e
            error_msg = _(
              "Failed to render template '%{template}'\n" \
              '%{exception}: %{message}',
            ) % { template: template_file, exception: e.class, message: e.message }
            raise PDK::CLI::FatalError, error_msg
          end
          yield dest_path, dest_content
        end
      end
def render files_in_template . each do | template_file | PDK . logger . debug ( _ ( "Rendering '%{template}'..." ) % { template : template_file } ) dest_path = template_file . sub ( %r{ \. erb \Z } , '' ) begin dest_content = PDK :: TemplateFile . new ( File . join ( @moduleroot_dir , template_file ) , configs : config_for ( dest_path ) ) . render rescue => e error_msg = _ ( "Failed to render template '%{template}'\n" '%{exception}: %{message}' , ) % { template : template_file , exception : e . class , message : e . message } raise PDK :: CLI :: FatalError , error_msg end yield dest_path , dest_content 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