loadViewsIntoContainer method
void
loadViewsIntoContainer()
Implementation
void loadViewsIntoContainer() {
try {
var files = Directory('./views')
.listSync(recursive: true, followLinks: true)
.whereType<File>()
.where((file) => file.path.endsWith('.mustache'))
.map((file) => {
'path': file.path,
'contents': file.readAsStringSync()
});
files.forEach((file) {
var key = file['path']?.replaceAll('/', '.').replaceFirst('..views.', '').replaceFirst('.mustache', '');
container?.bind('@views.$key', (_) => file['contents']);
});
} catch (e) {
print('Failed to load views. Please ensure that there is a `views` subfolder in your application.');
}
}