Migration Guide: Smarty to Vue.js/TypeScript
omegaUp is migrating from Smarty templates to modern Vue.js components with TypeScript.
Migration Strategy
Current State
- Old: Smarty templates (
.tplfiles) - New: Vue.js components (
.vuefiles) + TypeScript
Migration Process
- Identify Template: Find Smarty template to migrate
- Create Vue Component: Build equivalent Vue component
- Update Controllers: Modify PHP to return JSON instead of rendering template
- Update Routes: Change routes to serve Vue component
- Test: Ensure functionality matches original
- Remove Old Template: Delete Smarty template after verification
Guidelines
Template Structure
Smarty Template:
{include file='header.tpl'}
<div class="problem">
<h1>{$problem.title}</h1>
<p>{$problem.description}</p>
</div>
{include file='footer.tpl'}
Vue Component:
<template>
<div class="problem">
<h1>{% raw %}{{ problem.title }}{% endraw %}</h1>
<p>{% raw %}{{ problem.description }}{% endraw %}</p>
</div>
</template>
<script lang="ts">
import { Vue, Component, Prop } from 'vue-property-decorator';
@Component
export default class ProblemView extends Vue {
@Prop({ required: true })
problem!: Problem;
}
</script>
API Changes
Controllers should return JSON instead of rendering templates:
// ❌ Old: Render template
return [
'smarty' => true,
'template' => 'problem.tpl',
'problem' => $problem,
];
// ✅ New: Return JSON
return [
'status' => 'ok',
'problem' => $problem,
];
Related Documentation
- Coding Guidelines - Vue.js standards
- Components Guide - Component development
- Frontend Architecture - Frontend structure