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 library #117

Open
bouncepaw opened this issue Nov 5, 2021 · 2 comments · Fixed by #236
Open

Template library #117

bouncepaw opened this issue Nov 5, 2021 · 2 comments · Fixed by #236

Comments

@bouncepaw
Copy link
Owner

We use the quicktemplate library for almost all of HTML templating tasks in the project.

Contra:

  • Yet another dependency (all dependencies fail and are not to be trusted)
  • Yet another non-standard thing
  • We have twice as many files (.qtpl and .qtpl.go)
  • People are irritated for some reason?

Pro:

  • The core idea of the library (templates are normal Go functions) makes sense
  • The syntax of the templating language is very expressive
  • The library is quite fast, they say

I do not think changing quicktemplate to any other non-stdlib templating solution is a good idea. But what about stdlib's html/template?

=> https://godocs.io/html/template

Contra:

  • The API is ridiculous. You have to parse each template (and that may fail) and then you have to ‘execute’ it (and that may fail too). Simply unbearable
  • If we use html/template, it will be easier to implement template configuration, which is undesirable

Pro:

  • It is in stdlib
  • If we store the templates as separate .html files, every text editor will have a proper syntax highlighting. Compare with .qtpl which requires additional configuration everywhere

So, what is better? Cross your sword!

@bouncepaw
Copy link
Owner Author

After like six experiments, I'm starting to like this approach:

  • stdlib templates
  • l10n are done using {{block}} in place in English
  • they are then redefined for Russian for Russian versions of templates

Take a look at how categories views are done.

This approach also covers #138.

@bouncepaw bouncepaw linked a pull request Jun 11, 2024 that will close this issue
bouncepaw added a commit that referenced this issue Sep 7, 2024
Didn't have the chance to migrate //all// templates just yet. We'll get there.

* Implement yet another template system

* Move orphans to the new system and fix a bug in it

* Link orphans in the admin panel

* Move the backlink handlers to the web package

* Move auth routing to web

* Move /user-list to the new system

* Move change password and translate it

* Move stuff

* Move admin-related stuff to the web

* Move a lot of files into internal dir

Outside of it are web and stuff that needs further refactoring

* Fix static not loading and de-qtpl tree

* Move tree to internal

* Keep the globe on the same line #230

* Revert "Keep the globe on the same line #230"

This reverts commit ae78e5e.

* Migrate templates from hypview: delete, edit, start empty and existing WIP

The delete media view was removed, I didn't even know it still existed as a GET. A rudiment.

* Make views multi-file and break compilation

* Megarefactoring of hypha views

* Auth-related stuffs

* Fix some of those weird imports

* Migrate cat views

* Fix cat js

* Lower standards

* Internalize trauma
@bouncepaw bouncepaw reopened this Sep 7, 2024
@bouncepaw
Copy link
Owner Author

The recent pull request migrated most of the templates. Not all of them though... We'll get there.

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 a pull request may close this issue.

1 participant