renderProjectTemplates static method
Renders the full project architecture from templates
Implementation
static void renderProjectTemplates(
String projectPath, Map<String, dynamic> context) {
final templateDir = Directory('lib/templates/project/lib');
if (!templateDir.existsSync()) {
throw Exception("Project templates not found at ${templateDir.path}");
}
print('📦 Rendering project templates...');
for (var entity in templateDir.listSync(recursive: true)) {
// Skip home feature while rendering project
if (entity.path.contains(p.join('features', 'home'))) continue;
if (entity is File && entity.path.endsWith('.mustache')) {
final relativePath = p.relative(entity.path, from: templateDir.path);
final targetPath =
p.join(projectPath, relativePath.replaceAll('.mustache', ''));
final targetFile = File(targetPath)..parent.createSync(recursive: true);
try {
final templateContent = entity.readAsStringSync();
final template = Template(templateContent);
final rendered = template.renderString(context);
targetFile.writeAsStringSync(rendered);
print('📄 Created: $relativePath → ${p.basename(targetPath)}');
} catch (e) {
print('❌ Failed to render $relativePath: $e');
}
}
}
}