implement a multi-file template interpreter
This commit is contained in:
19
examples/react-app-generator/templates/react-router.tmpl
Normal file
19
examples/react-app-generator/templates/react-router.tmpl
Normal file
@ -0,0 +1,19 @@
|
||||
import React from 'react';
|
||||
import { BrowserRouter as Router, Routes, Route } from 'react-router-dom';
|
||||
{{range .AST.Definitions}}{{if .Page}}import {{.Page.Name}}Page from './pages/{{if eq .Page.Layout "admin"}}admin/{{end}}{{.Page.Name}}';
|
||||
{{end}}{{end}}
|
||||
|
||||
export default function AppRouter() {
|
||||
return (
|
||||
<Router>
|
||||
<Routes>
|
||||
{{range .AST.Definitions}}{{if .Page}}
|
||||
<Route
|
||||
path="{{.Page.Path}}"
|
||||
element={<{{.Page.Name}}Page />}
|
||||
/>
|
||||
{{end}}{{end}}
|
||||
</Routes>
|
||||
</Router>
|
||||
);
|
||||
}
|
Reference in New Issue
Block a user