• Blog
  • Docs
  • Pricing
  • We’re hiring!
Log inSign up
devto

devto

adportal

Unlisted
Like
adportal
Home
Code
20
api
7
controllers
3
models
2
public
6
services
5
tests
1
utils
3
views
4
README.md
REFACTORING-PHASE1.md
REFACTORING-PHASE2.md
REFACTORING-PHASE3.md
REFACTORING-PHASE4.md
REFACTORING-PHASE5.md
REFACTORING.md
TEMPLATE-FIX.md
devto-stylesheet-README.md
C
devto-stylesheet-fetcher.ts
H
devto-stylesheet-provider.ts
H
index.ts
Branches
2
Pull requests
Remixes
History
Environment variables
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Sign up now
Code
/
TEMPLATE-FIX.md
Code
/
TEMPLATE-FIX.md
Search
5/8/2025
Viewing readonly version of main branch: v443
View latest version
TEMPLATE-FIX.md

Template System Fix

This document explains the changes made to fix the template rendering issues in the DEV Partner Portal application.

The Problem

The template system was experiencing issues with nested conditionals and complex template syntax. This resulted in template code being rendered directly in the HTML output instead of being processed correctly.

Examples of issues:

  • Template variables like {{value}} appearing in the rendered output
  • Conditional statements like {{#if type == "select"}} showing up in the HTML
  • Nested conditionals not being processed correctly

The Solution

We took a two-pronged approach to fix these issues:

  1. Simplified Components: Created simplified versions of all components that avoid complex template syntax
  2. Direct HTML: Used direct HTML instead of complex conditional logic in templates

Simplified Components

We created the following simplified components:

  • /views/components/forms/simple-submission-form.html
  • /views/components/forms/simple-magic-link-form.html
  • /views/components/forms/simple-company-info-form.html
  • /views/components/ui/simple-success-message.html
  • /views/components/ui/simple-error-message.html
  • /views/components/ui/simple-account-info.html
  • /views/components/uploadcare/simple-image-gallery.html
  • /views/components/ad-creation/simple-ad-preview.html

These components use direct HTML instead of complex template syntax, making them more reliable and easier to maintain.

Simplified Templates

We also created simplified versions of the main templates:

  • /views/templates/simple-landing-template.html
  • /views/templates/simple-continue-template.html

These templates use the simplified components and avoid complex template syntax.

Updated Controllers

We updated the controllers to use the simplified templates:

// Updated renderLandingPage function export async function renderLandingPage(c: Context): Promise<Response> { const html = await renderTemplate("/views/templates/simple-landing-template.html", {}, import.meta.url); return c.html(html); } // Updated renderContinuationPage function export async function renderContinuationPage(c: Context): Promise<Response> { // ... const html = await renderTemplate("/views/templates/simple-continue-template.html", { COMPANY_NAME: submission.companyName, EMAIL: submission.email, ID: id, HOST: host }, import.meta.url); return c.html(html); }

Benefits of This Approach

  1. Reliability: Simplified templates are less prone to rendering errors
  2. Maintainability: Direct HTML is easier to understand and maintain
  3. Performance: Simpler templates are faster to render
  4. Debugging: Issues are easier to identify and fix

Future Improvements

For a more robust solution in the future, we could:

  1. Implement a more sophisticated template engine like Handlebars or EJS
  2. Create a custom component system with proper escaping and processing
  3. Add template validation to catch syntax errors before rendering
  4. Implement server-side rendering for complex components

However, the current simplified approach should be sufficient for the needs of the DEV Partner Portal application while being much more reliable than the previous implementation.

FeaturesVersion controlCode intelligenceCLIMCP
Use cases
TeamsAI agentsSlackGTM
DocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
PricingNewsletterBlogAboutCareers
We’re hiring!
Brandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Open Source Pledge
Terms of usePrivacy policyAbuse contact
© 2025 Val Town, Inc.