Passed
Pull Request — main (#166)
by Yume
02:09
created

app/v2/views/partials/image.partial_templ.go   A

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
cc 6
eloc 22
dl 0
loc 30
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B partials.ImageOptimized 0 21 6
1
// Code generated by templ - DO NOT EDIT.
2
3
// templ: version: v0.2.543
4
package partials
5
6
//lint:file-ignore SA4006 This context is only used if a nested component is present.
7
8
import "github.com/a-h/templ"
9
import "context"
10
import "io"
11
import "bytes"
12
13
func ImageOptimized(src, alt string, width, height int, class string, lazy bool, quality int) templ.Component {
14
	return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
15
		templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
16
		if !templ_7745c5c3_IsBuffer {
17
			templ_7745c5c3_Buffer = templ.GetBuffer()
18
			defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
19
		}
20
		ctx = templ.InitializeContext(ctx)
21
		templ_7745c5c3_Var1 := templ.GetChildren(ctx)
22
		if templ_7745c5c3_Var1 == nil {
23
			templ_7745c5c3_Var1 = templ.NopComponent
24
		}
25
		ctx = templ.ClearChildren(ctx)
26
		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<picture><source srcset=\"{src}.webp\" type=\"image/webp\" data-testid=\"webp\"> <img src=\"{src}\" alt=\"{alt}\" width=\"{width}\" height=\"{height}\" class=\"{class}\" loading=\"{if lazy}lazy{else}auto{end}\" decoding=\"async\" data-testid=\"src\"></picture>")
27
		if templ_7745c5c3_Err != nil {
28
			return templ_7745c5c3_Err
29
		}
30
		if !templ_7745c5c3_IsBuffer {
31
			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W)
32
		}
33
		return templ_7745c5c3_Err
34
	})
35
}
36