implement a multi-file template interpreter
This commit is contained in:
@ -0,0 +1,32 @@
|
||||
import React from 'react';
|
||||
{{if .Section.Entity}}import { {{.Section.Entity}} } from '../../types/{{.Section.Entity}}';
|
||||
{{end}}{{range .Section.Elements}}{{if .Section}}import {{.Section.Name | title}}Section from '../sections/{{.Section.Name | title}}Section';{{end}}{{if .Component}}import {{.Component.Type | title}}Component from '../{{.Component.Type | title}}Component';{{end}}{{end}}
|
||||
|
||||
interface {{.Section.Name | title}}SectionProps {
|
||||
className?: string;
|
||||
{{if .Section.Entity}}data?: {{.Section.Entity}}[];
|
||||
{{end}}
|
||||
}
|
||||
|
||||
export default function {{.Section.Name | title}}Section({
|
||||
className = ''
|
||||
{{if .Section.Entity}}, data{{end}}
|
||||
}: {{.Section.Name | title}}SectionProps) {
|
||||
return (
|
||||
<section className={`{{if .Section.Type}}{{.Section.Type}}{{else}}container{{end}} ${className}`}>
|
||||
{{if .Section.Label}}<h2 className="text-2xl font-bold mb-4">{{.Section.Label | derefString}}</h2>
|
||||
{{end}}
|
||||
|
||||
<div className="space-y-6">
|
||||
{{range .Section.Elements}}
|
||||
{{if .Component}}
|
||||
<{{.Component.Type | title}}Component />
|
||||
{{end}}
|
||||
{{if .Section}}
|
||||
<{{.Section.Name | title}}Section />
|
||||
{{end}}
|
||||
{{end}}
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
Reference in New Issue
Block a user