From 6280a5fc9fdacdc043585d867fac4b62dc9e0714 Mon Sep 17 00:00:00 2001 From: Yanislav Igonin Date: Wed, 2 Feb 2022 15:03:40 +0200 Subject: [PATCH] feat: separate thread card title and text components --- templates/components/thread-card-text.html | 8 ++++++++ templates/components/thread-card-title.html | 5 +++++ templates/components/thread-card.html | 13 ++----------- 3 files changed, 15 insertions(+), 11 deletions(-) create mode 100644 templates/components/thread-card-text.html create mode 100644 templates/components/thread-card-title.html diff --git a/templates/components/thread-card-text.html b/templates/components/thread-card-text.html new file mode 100644 index 0000000..fe36304 --- /dev/null +++ b/templates/components/thread-card-text.html @@ -0,0 +1,8 @@ +{{ define "thread-card-text" }} + {{ $length := len . }} + {{ if gt $length 300 }} +

{{ slice . 0 300 }} ...

+ {{ else }} +

{{ . }}

+ {{ end }} +{{ end }} \ No newline at end of file diff --git a/templates/components/thread-card-title.html b/templates/components/thread-card-title.html new file mode 100644 index 0000000..2d1f297 --- /dev/null +++ b/templates/components/thread-card-title.html @@ -0,0 +1,5 @@ +{{ define "thread-card-title" }} + {{ if ne . "" }} +
{{ . }}
+ {{ end }} +{{ end }} \ No newline at end of file diff --git a/templates/components/thread-card.html b/templates/components/thread-card.html index 1a86f1c..28349c0 100644 --- a/templates/components/thread-card.html +++ b/templates/components/thread-card.html @@ -8,17 +8,8 @@ {{ end }}
- {{ if ne .Title "" }} -
{{.Title}}
- {{ end }} - - {{ $textLength := len .Text }} - {{ if gt $textLength 300 }} -

{{ slice .Text 0 300 }} ...

- {{ else }} -

{{.Text}}

- {{ end }} - + {{ template "thread-card-title" .Title }} + {{ template "thread-card-text" .Text }} Open