Method: PDK::Template.with
- Defined in:
- lib/pdk/template.rb
.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.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/pdk/template.rb', line 39 def self.with(uri, context) unless block_given? raise ArgumentError, _('%{class_name}.with must be passed a block.') % { class_name: name } end unless uri.is_a? PDK::Util::TemplateURI raise ArgumentError, _('%{class_name}.with must be passed a PDK::Util::TemplateURI, got a %{uri_type}') % { uri_type: uri.class, class_name: name } end Fetcher.with(uri) do |fetcher| template_dir = TemplateDir.instance(uri, fetcher.path, context) template_dir. = fetcher. template_type = uri.default? ? 'default' : 'custom' PDK.analytics.event('TemplateDir', 'initialize', label: template_type) yield template_dir end nil end |