template() — astro Function Reference
Architecture documentation for the template() function in template.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD 4cd724a0_ec41_439e_3ac2_a00dde55ae2a["template()"] 33b7e98e_3257_427a_5948_5ab38c474d26["template.ts"] 4cd724a0_ec41_439e_3ac2_a00dde55ae2a -->|defined in| 33b7e98e_3257_427a_5948_5ab38c474d26 0fddab5d_7945_0e3f_5243_8599487fed07["copyTemplate()"] 4cd724a0_ec41_439e_3ac2_a00dde55ae2a -->|calls| 0fddab5d_7945_0e3f_5243_8599487fed07 style 4cd724a0_ec41_439e_3ac2_a00dde55ae2a fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/create-astro/src/actions/template.ts lines 47–92
export async function template(
ctx: Pick<Context, 'template' | 'prompt' | 'yes' | 'dryRun' | 'exit' | 'tasks'>,
) {
if (!ctx.template && ctx.yes) ctx.template = 'basics';
if (ctx.template) {
await info('tmpl', `Using ${color.reset(ctx.template)}${color.dim(' as project template')}`);
} else {
const { template: tmpl } = await ctx.prompt({
name: 'template',
type: 'select',
label: title('tmpl'),
message: 'How would you like to start your new project?',
initial: 'basics',
choices: [
{ value: 'basics', label: 'A basic, helpful starter project', hint: '(recommended)' },
{ value: 'blog', label: 'Use blog template' },
{ value: 'starlight', label: 'Use docs (Starlight) template' },
{ value: 'minimal', label: 'Use minimal (empty) template' },
],
});
ctx.template = tmpl;
}
if (ctx.dryRun) {
await info('--dry-run', `Skipping template copying`);
} else if (ctx.template) {
ctx.tasks.push({
pending: 'Template',
start: 'Template copying...',
end: 'Template copied',
while: () =>
copyTemplate(ctx.template!, ctx as Context).catch((e) => {
if (e instanceof Error) {
error('error', e.message);
process.exit(1);
} else {
error('error', 'Unable to clone template.');
process.exit(1);
}
}),
});
} else {
ctx.exit(1);
}
}
Domain
Subdomains
Calls
Source
Frequently Asked Questions
What does template() do?
template() is a function in the astro codebase, defined in packages/create-astro/src/actions/template.ts.
Where is template() defined?
template() is defined in packages/create-astro/src/actions/template.ts at line 47.
What does template() call?
template() calls 1 function(s): copyTemplate.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free