HTMLBlock uses MediaResolver interface instead of db.Queries for media metadata enrichment. Includes shared ButtonConfig, MediaValue, TemplateRenderer interface, and block helper utilities. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
55 lines
1.1 KiB
Plaintext
55 lines
1.1 KiB
Plaintext
package shared
|
|
|
|
// RenderButton renders a button or link based on ButtonConfig
|
|
templ RenderButton(btn ButtonConfig) {
|
|
if btn.URL != "" {
|
|
if btn.InlineStyle() != "" {
|
|
<a
|
|
href={ templ.SafeURL(btn.URL) }
|
|
class={ btn.Classes() }
|
|
if btn.OpenNewTab {
|
|
target="_blank"
|
|
rel="noopener noreferrer"
|
|
}
|
|
style={ btn.InlineStyle() }
|
|
>
|
|
{ btn.Text }
|
|
</a>
|
|
} else {
|
|
<a
|
|
href={ templ.SafeURL(btn.URL) }
|
|
class={ btn.Classes() }
|
|
if btn.OpenNewTab {
|
|
target="_blank"
|
|
rel="noopener noreferrer"
|
|
}
|
|
>
|
|
{ btn.Text }
|
|
</a>
|
|
}
|
|
} else {
|
|
if btn.InlineStyle() != "" {
|
|
<button type="button" class={ btn.Classes() } style={ btn.InlineStyle() }>
|
|
{ btn.Text }
|
|
</button>
|
|
} else {
|
|
<button type="button" class={ btn.Classes() }>
|
|
{ btn.Text }
|
|
</button>
|
|
}
|
|
}
|
|
}
|
|
|
|
// RenderSubmitButton renders a submit button
|
|
templ RenderSubmitButton(btn ButtonConfig) {
|
|
if btn.InlineStyle() != "" {
|
|
<button type="submit" class={ btn.Classes() } style={ btn.InlineStyle() }>
|
|
{ btn.Text }
|
|
</button>
|
|
} else {
|
|
<button type="submit" class={ btn.Classes() }>
|
|
{ btn.Text }
|
|
</button>
|
|
}
|
|
}
|