interactive intro to open social at-me.zzstoatzz.io

architecture: css and html embedded in rust string literals #6

Closed zzstoatzz.io
Closed opened by zzstoatzz.io

problem #

all css and html templates are embedded as rust string literals in src/templates.rs.

current approach:

pub fn login_page() -> &'static str {
    r#"
<!DOCTYPE html>
<html>
<head>
    <style>
        /* ~300 lines of css */
    </style>
</head>
...
    "#
}

issues #

1. no syntax highlighting #

writing css/html in rust strings = no proper editor support

2. css duplication #

  • similar styles duplicated between login_page() and app_page()
  • css variables defined separately in each template
  • ~700 lines of css total in rust strings

3. template maintenance #

  • hard to edit/preview html
  • rust compilation required for any frontend change
  • can't use standard html/css tooling

4. no separation of concerns #

  • presentation logic mixed with backend code
  • harder to onboard frontend contributors

affected files #

  • src/templates.rs (~990 lines, mostly css/html)

notes #

this is somewhat intentional (simple deployment, no build step), but creates maintenance overhead as app grows.

Sign up or Sign in to add to the discussion.