Module: PDK::Template

Defined in:
lib/pdk/template.rb,
lib/pdk/template/fetcher.rb,
lib/pdk/template/renderer.rb,
lib/pdk/template/fetcher/git.rb,
lib/pdk/template/renderer/v1.rb,
lib/pdk/template/template_dir.rb,
lib/pdk/template/fetcher/local.rb,
lib/pdk/template/renderer/v1/renderer.rb,
lib/pdk/template/renderer/v1/template_file.rb,
lib/pdk/template/renderer/v1/legacy_template_dir.rb

Defined Under Namespace

Modules: Fetcher, Renderer Classes: TemplateDir

Constant Summary collapse

MODULE_TEMPLATE_TYPE =
:module_template

Class Method Summary collapse

Class Method Details

.with(uri, context) {|self| ... } ⇒ Object

Creates a TemplateDir object with the path or URL to the template and the block of code to run to be run while the template is available.

The template directory is only guaranteed to be available on disk within the scope of the block passed to this method.

template or a URI to a git repository.

the template available on disk.

Examples:

Using a git repository as a template

PDK::Template.with('https://github.com/puppetlabs/pdk-templates') do |t|
  t.render_module('module, PDK.context) do |filename, content, status|
    File.open(filename, 'w') do |file|
      ...
    end
  end
end

Parameters:

Yield Parameters:

Raises:



39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/pdk/template.rb', line 39

def self.with(uri, context)
  raise ArgumentError, format('%{class_name}.with must be passed a block.', class_name: name) unless block_given?
  raise ArgumentError, format('%{class_name}.with must be passed a PDK::Util::TemplateURI, got a %{uri_type}', uri_type: uri.class, class_name: name) unless uri.is_a? PDK::Util::TemplateURI

  Fetcher.with(uri) do |fetcher|
    template_dir = TemplateDir.instance(uri, fetcher.path, context)
    template_dir. = fetcher.

    yield template_dir
  end
  nil
end