Skip to content

Commit

Permalink
render within the view, not the model, to prevent double render
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanfaerman committed Feb 11, 2024
1 parent 85e9f13 commit d649d1d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 0 additions & 2 deletions internal/handlers/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,6 @@ func (h account) Show(w http.ResponseWriter, r *http.Request) {

ctx := services.CSRF.GetContext(r.Context(), r)

account.About = services.Markdown.MustRenderString(account.About)

v := views.Account{
Account: account,
}
Expand Down
3 changes: 2 additions & 1 deletion internal/views/account.templ
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package views

import "github.com/ryanfaerman/netctl/internal/models"
import "github.com/ryanfaerman/netctl/internal/services"
import "github.com/ryanfaerman/netctl/web/named"

import "strings"
Expand Down Expand Up @@ -76,7 +77,7 @@ templ (v Account) Profile() {
if v.Account.About != "" {
<h3>Profile</h3>
<div class="profile-section profile-intro markdown-body">
@templ.Raw(v.Account.About)
@templ.Raw(services.Markdown.MustRenderString(v.Account.About))
</div>
} else {
<p>We'd love to tell you more about { v.Account.Name }, but they haven't shared anything.</p>
Expand Down

0 comments on commit d649d1d

Please sign in to comment.