dynamic template loading

pull/2353/head
Aniket-Engg 3 years ago
parent cde17313b8
commit 028f40e643
  1. 13
      libs/remix-ui/workspace/src/lib/actions/workspace.ts

@ -5,7 +5,6 @@ import { addInputFieldSuccess, createWorkspaceError, createWorkspaceRequest, cre
import { checkSlash, checkSpecialChars } from '@remix-ui/helper' import { checkSlash, checkSpecialChars } from '@remix-ui/helper'
import { JSONStandardInput, workspaceTemplate } from '../types' import { JSONStandardInput, workspaceTemplate } from '../types'
import { remixDefault } from '../templates'
import { QueryParams } from '@remix-project/remix-lib' import { QueryParams } from '@remix-project/remix-lib'
@ -150,12 +149,14 @@ export const loadWorkspacePreset = async (template: workspaceTemplate = 'remixDe
} }
break break
case 'remixDefault': default:
// creates a new workspace and populates it with default project template. const templateWithContent = await import('../templates')
// insert example contracts const templateList = Object.keys(templateWithContent)
for (const file in remixDefault) { if (!templateList.includes(template)) break
const files = templateWithContent[template]
for (const file in files) {
try { try {
await workspaceProvider.set(remixDefault[file].name, remixDefault[file].content) await workspaceProvider.set(files[file].name, files[file].content)
} catch (error) { } catch (error) {
console.error(error) console.error(error)
} }

Loading…
Cancel
Save