Module: Clacky::ExtensionScaffold
- Defined in:
- lib/clacky/extension/scaffold.rb,
lib/clacky/extension/scaffold/template_renderer.rb
Overview
Scaffolds extension containers for the ext new command.
Generated containers are complete, runnable examples — the best
documentation for an AI author is a working "hello panel" it can copy.
Defined Under Namespace
Classes: TemplateRenderer
Constant Summary collapse
- TEMPLATES_DIR =
File.("scaffold/templates", __dir__)
Class Method Summary collapse
-
.new_container(id, dir: Clacky::ExtensionLoader::LOCAL_DIR, full: false) ⇒ String
Create a new local container with a runnable hello panel + backend.
Class Method Details
.new_container(id, dir: Clacky::ExtensionLoader::LOCAL_DIR, full: false) ⇒ String
Create a new local container with a runnable hello panel + backend.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/clacky/extension/scaffold.rb', line 18 def new_container(id, dir: Clacky::ExtensionLoader::LOCAL_DIR, full: false) slug = slugify(id) raise ArgumentError, "invalid extension id: #{id.inspect}" if slug.empty? target = File.join(dir, slug) raise ArgumentError, "extension already exists: #{target}" if Dir.exist?(target) return new_full_container(slug, target) if full FileUtils.mkdir_p(target) TemplateRenderer.render( template_dir: File.join(TEMPLATES_DIR, "hello"), target: target, locals: { slug: slug, const_prefix: camelize(slug) } ) target end |