Skip to content

fix: format template source codes and implement non destructive cache migration#152

Open
theblag wants to merge 1 commit into
Debmallya-03:mainfrom
theblag:fix/template-code-format
Open

fix: format template source codes and implement non destructive cache migration#152
theblag wants to merge 1 commit into
Debmallya-03:mainfrom
theblag:fix/template-code-format

Conversation

@theblag
Copy link
Copy Markdown
Contributor

@theblag theblag commented May 28, 2026

Related Issue: #117

Description

This PR formats all built-in template codes (HTML, CSS, and JS) to use clean, readable, multi-line formatting instead of the previous single-line minified layouts. It also introduces a type-safe, non-destructive upgrade migration for browser profiles that have cached template code in localStorage.

Changes

Template Code Formatting: Reformatted template contents (landing-page, interactive-card, todo-app, stopwatch, login-form, and signup-form) to make them readable.
Non-Destructive Cache Upgrade: Updated the useState initializer and loadTemplate handler to whitespace-insensitively match stored user cache against default templates. If the cached template code is unmodified, it automatically upgrades to the formatted versions.
TypeScript Compilation Fix: Resolved a type assignment error in loadTemplate where undefined was being assigned to a CodeContent type.

NOTE
Important Note on Cached Browser Memory (LocalStorage) If a user has previously loaded a template and made even a minor modification to their code (like adding a space or changing text), the code is treated as customized and will persist as-is. It will not be auto-formatted to avoid wiping out user changes. In these cases, users can format their code manually using the built-in Format code button in the UI (Ctrl + K -> "Format code") or clear their browser's local cache.

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 28, 2026

@theblag is attempting to deploy a commit to the debmallya-03's projects Team on Vercel.

A member of the Team first needs to authorize it.

@netlify
Copy link
Copy Markdown

netlify Bot commented May 28, 2026

Deploy Preview for webifynet failed. Why did it fail? →

Name Link
🔨 Latest commit 90647a3
🔍 Latest deploy log https://app.netlify.com/projects/webifynet/deploys/6a18bcb982e83d00082598be

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant