How to import and reuse existing ForSure files and templates.
Import other ForSure files to reuse structures and templates.
# Import common web app structure
@import "common/web-app.forsure"
# Import React component templates
@import "templates/react-components.forsure"
root:
- Type: Directory
- Name: my-project/
<description>
My custom project with imported structure
</description>Import with namespaces to avoid naming conflicts.
@import "templates/react.forsure" as react
@import "templates/vue.forsure" as vue
root:
- Type: Directory
- Name: components/
# Use React component template
- react:Button
- Name: PrimaryButton.jsx
- Props: { variant: "primary" }
# Use Vue component template
- vue:Button
- Name: PrimaryButton.vue
- Props: { type: "primary" }Import only specific items from a ForSure file.
# Import only specific templates
@import "templates/all.forsure" {
ReactComponent,
UtilityFile,
ConfigFile
}
root:
- Type: Directory
- Name: src/
# Use imported template
- ReactComponent
- Name: Header.jsx
- Props: { title: "My App" }
- UtilityFile
- Name: helpers.js
- ConfigFile
- Name: app.config.jsUse variables and conditions in import statements.
# Conditional imports
@import "templates/${FRAMEWORK}.forsure"
@import "configs/${ENVIRONMENT}.forsure" if ENVIRONMENT
# Variable-based imports
@import "user-templates/${USER_TEMPLATE}.forsure"
root:
- Type: Directory
- Name: project/
<description>
Project structure with dynamic imports
</description>ForSure resolves imports in this order:
# 1. Relative paths
@import "./local-template.forsure"
# 2. Project templates directory
@import "templates/web-app.forsure"
# 3. Global templates
@import "standard/react-app.forsure"
# 4. Remote templates (if available)
@import "https://templates.example.com/nextjs.forsure"