Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Template Subsystem #14

Open
noelwelsh opened this issue Feb 4, 2025 · 0 comments
Open

Template Subsystem #14

noelwelsh opened this issue Feb 4, 2025 · 0 comments

Comments

@noelwelsh
Copy link
Contributor

What we want from a templating system:

  • Runs on both client and server
  • Provides type safety during construction
  • Allows construction of diffs for LiveView / HTML-on-the-wire style server side rendering
  • Can use standard HTML syntax, so developer can copy-and-paste examples

None of the existing systems achieve this. ScalaTags comes the closest, but it doesn't support standard HTML syntax. It would be useful to experiment with an alternative system.

A viable implementation path is:

  1. Develop a parser for HTML. We can assume a very simple structure and not allow omitting closing tags, CDATA, or other complications. This parser will need to able to splice in computed values. Look to see if Parsley can be used for this. If not, reviving Repast may be the way forward. ScalaTags is a reasonable target format for this translation.
  2. Provide the parser as a StringContext. Now we can write HTML snippets directly in code.
  3. Look at creating a SBT plugin like sbt-twirl to allow stand-alone templates.

There are a few optional extras:

  • Using scala-dom-types to provide additional type safety
  • Replacing ScalaTags with a more efficient format (e.g. one that streams directly to the response when running server side, instead of building a String in memory.)
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

No branches or pull requests

1 participant