templates

package
v0.60.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 19, 2026 License: AGPL-3.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ImgProxyKey  contextKey = "imgproxy_key"
	ImgProxySalt contextKey = "imgproxy_salt"
)
View Source
const (
	// BodyFragment is a fragment key pointing to tbe body section of a page.
	BodyFragment templFragmentKey = "body"
	// ContentFragment is a fragment key pointing to the main content of a page.
	ContentFragment templFragmentKey = "content"
	// PaginateFragment is a fragment key pointing to the content to render when paginating.
	PaginateFragment templFragmentKey = "paginate"
)
View Source
const DefaultNotificationTimeout = 5 * time.Second
View Source
const ErrorFragment templFragmentKey = "error"
View Source
const PaginateSearchFragment templFragmentKey = "paginateSearch"

Variables

View Source
var (
	// ContentID points to the element containing the main content of the page.
	ContentID = models.ElementID("content")
	// NotificationsID points to an element that can be used for displaying notifications to the user.
	NotificationsID = models.ElementID("notifications")
)

Functions

func About added in v0.21.0

func About() templ.Component

func AccountSettings

func AccountSettings(user *models.User) templ.Component

func AddCategory

func AddCategory(path, inputName string, category models.Category) templ.Component

AddCategory renders a new category item to the list of categories of a subscription.

func AddFeedSubscription

func AddFeedSubscription(request *models.AddFeedSubscriptionRequest) templ.Component

AddFeedSubscription is a page for adding a new subscription to a feed.

func AddGroupSubscription

func AddGroupSubscription(request *models.GroupSubscriptionRequest) templ.Component

AddGroupSubscription is a page for adding a new group subscription.

func AddSearchSubscription

func AddSearchSubscription(request *models.SearchSubscriptionRequest) templ.Component

AddSearchSubscription is a page for adding a new search subscription.

func CategoryManagement

func CategoryManagement(path, inputName string, suggested []models.Category, existing []models.Category) templ.Component

func CreatePage added in v0.36.0

func CreatePage(template templ.Component, options ...PageOption) templ.Component

CreatePage creates a new page with the given body template and additional options.

func DeactivateAccountModal

func DeactivateAccountModal() templ.Component

func DisplaySettings

func DisplaySettings(user *models.User) templ.Component

func Dock

func Dock(attributes templ.Attributes) templ.Component

func Document

func Document(data []byte) templ.Component

Document renders the given raw HTML data as full-page prose content. Used primarily for hosted markdown documents (i.e., privacy policy, terms of service, etc.)

func EditEmailSubscription added in v0.26.0

func EditEmailSubscription(request *models.EditEmailSubscriptionRequest) templ.Component

func EditGroupSubscription

func EditGroupSubscription(request *models.GroupSubscriptionRequest) templ.Component

EditGroupSubscription is a page for editing a group subscription.

func EditSearchSubscription

func EditSearchSubscription(request *models.SearchSubscriptionRequest) templ.Component

EditSearchSubscription is a page for editing a search subscription.

func EditSubscription

func EditSubscription(request *models.EditFeedSubscriptionRequest) templ.Component

func ExportSubscriptions

func ExportSubscriptions() templ.Component

ExportSubscriptions renders a form for exporting all subscriptions as an OPML file.

func ExternalError

func ExternalError(user *models.User, msg *models.UserMessage) templ.Component

func FilterControls

func FilterControls(path string, filters *models.ListFilters) templ.Component

func GroupSubscriptionAddSubscription added in v0.54.0

func GroupSubscriptionAddSubscription(id, name string) templ.Component

func GroupSubscriptionSuggestions added in v0.54.0

func GroupSubscriptionSuggestions(subscriptions models.Subscriptions) templ.Component

func HelpPopover

func HelpPopover(id, anchor string) templ.Component

HelpPopover can be used to render a help icon, that when clicked, will open a popover displaying informational or help text.

func ImportResults

func ImportResults(results []*models.AddFeedSubscriptionResult) templ.Component

ImportResults is a partial template that displays the results of an import.

func ImportSubscriptions

func ImportSubscriptions() templ.Component

ImportPage is a page for importing subscriptions from an external source (e.g., an OPML file).

func InternalError added in v0.36.0

func InternalError(user *models.User, msg *models.UserMessage) templ.Component

func Landing

func Landing() templ.Component

Landing is the landing page layout.

func ListArticles

func ListArticles(response *models.ListArticlesResponse) templ.Component

ListArticles renders the list of articles in a grid layout with filtering controls and an actions menu.

func ListCategoryFilters added in v0.27.0

func ListCategoryFilters(filters *models.CategoryFilters) templ.Component

func ListFavorites added in v0.39.0

func ListFavorites(response *models.ListFavoritesResponse) templ.Component

ListFavorites renders subscription and article favorites in a grid layout.

func ListSubscriptions

func ListSubscriptions(response *models.ListSubscriptionsResponse) templ.Component

ListSubscriptions renders the list of subscriptions in a grid layout with filtering controls and an actions menu.

func NewProxiedImage

func NewProxiedImage(img *types.ImageInfo, props string, options ...ElementOption) templ.Component

func NewUserHome

func NewUserHome() templ.Component

NewUserHome is a home page displayed for new users, with some instructions and actions to help them set up the app.

func NotFound

func NotFound() templ.Component

NotFound renders a layout appropriate to use for a 404 response.

func Notification

func Notification(msg *models.UserMessage, timeout time.Duration) templ.Component

Notification renders a notification with the given user message.

func PostsIndex added in v0.36.0

func PostsIndex(posts []*models.MarkdownFile) templ.Component

func RemoveSubscriptionModal

func RemoveSubscriptionModal(request *models.RemoveSubscriptionRequest) templ.Component

RemoveObjectModal renders a modal that will action an unsubscribe request when the user has confirmed.

func ReportObjectIssues

func ReportObjectIssues(objectType, id string, details *models.ReportObjectIssueRequest) templ.Component

func ReportPageIssue

func ReportPageIssue(details *models.ReportIssueRequest) templ.Component

ReportPageIssue renders a form for reporting issues with the app.

func SearchFilters

func SearchFilters(request *models.SearchRequest, attributes templ.Attributes) templ.Component

func SearchResults

func SearchResults(results *models.SearchResults) templ.Component

SearchResults renders the given articles returned from the given search in a grid layout with an actions menu.

func SearchSubscriptionAddSubscription added in v0.54.0

func SearchSubscriptionAddSubscription(id, name string) templ.Component

func SearchSubscriptionFilterSuggestions

func SearchSubscriptionFilterSuggestions(subscriptions models.Subscriptions) templ.Component

func SearchSubscriptionSuggestions added in v0.54.0

func SearchSubscriptionSuggestions(subscriptions models.Subscriptions) templ.Component

func SearchSuggestions

func SearchSuggestions(suggestions *models.SearchResults) templ.Component

SearchSuggestions will render suggestions for a given search.

func ShareArticleModal added in v0.34.1

func ShareArticleModal(request *models.ShareArticleRequest) templ.Component

func ShowSubscriptionEmail added in v0.26.0

func ShowSubscriptionEmail(email string) templ.Component
func SideBar(attributes templ.Attributes) templ.Component

func SimilarArticles

func SimilarArticles(articles models.Articles) templ.Component

SimilarArticles renders a page of articles that are the result of a search for similar articles to a given input set.

func UpdateTitle added in v0.36.0

func UpdateTitle(title string) templ.Component

func UpdatesToast

func UpdatesToast() templ.Component

UpdatesToast renders a toast notification to inform the user that updated content is available.

func UserAccountIssue

func UserAccountIssue() templ.Component

UserAccountIssuePage renders a full page with a message to the user indicating that their account has an issue that needs support to resolve. Usually, this will be displayed when a subscription plan payment has failed and requires manual intervention.

func UserAvatar

func UserAvatar(user *models.User, attributes templ.Attributes) templ.Component

func UserChooseSubscriptionPlan

func UserChooseSubscriptionPlan(user *models.User, planID string) templ.Component

UserChooseSubscriptionPlanPage renders a full page for the user to choose their subscription plan, with any previously selected option highlighted. This is displayed after a user account has been created (in Auth0) and redirects the user to Stripe for payment.

func UserHome added in v0.37.0

func UserHome(data *models.HomeResponse) templ.Component

UserHome is the default user home page.

func UserSettings added in v0.39.0

func UserSettings() templ.Component

func Viewer added in v0.21.0

func Viewer(feed *models.Feed, errMsg *models.UserMessage) templ.Component

func ViewerError added in v0.36.0

func ViewerError(msg *models.UserMessage) templ.Component

func ViewerResults added in v0.21.0

func ViewerResults(feed *models.Feed) templ.Component

Types

type Article added in v0.27.0

type Article struct {
	*models.Article
}

func NewArticleView added in v0.27.0

func NewArticleView(a *models.Article) *Article

NewArticleView wraps an Article object with additional methods for templates involving the article.

func (*Article) Card added in v0.27.0

func (a *Article) Card() templ.Component

Card renders an article as a card, for displaying in a list.

func (*Article) Content added in v0.27.0

func (a *Article) Content() templ.Component

ArticleContent renders the complete content of an article.

func (*Article) ReportIssueAttributes added in v0.27.0

func (a *Article) ReportIssueAttributes() templ.Attributes

func (*Article) SimilarArticlesAttributes added in v0.27.0

func (a *Article) SimilarArticlesAttributes() templ.Attributes

type CategoryBadge added in v0.19.0

type CategoryBadge models.Category

CategoryBadge represents a Category as a badge in the UI.

func NewCategoryBadge added in v0.19.0

func NewCategoryBadge(category models.Category) CategoryBadge

NewCategoryBadge creates a new CategoryBadge from the given Category.

func (CategoryBadge) Render added in v0.19.0

func (c CategoryBadge) Render(classes ...string) templ.Component

Render will render the CategoryBadge.

type Element added in v0.41.0

type Element struct {
	ID         models.ElementID
	Attributes templ.Attributes
	Classes    []string
	// contains filtered or unexported fields
}

Element represents any HTML element that can have attributes and classes.

func NewElement added in v0.41.0

func NewElement() *Element

func (*Element) AddClasses added in v0.41.0

func (e *Element) AddClasses(classes ...string)

func (*Element) GetAttributes added in v0.41.0

func (e *Element) GetAttributes() templ.Attributes

func (*Element) GetClasses added in v0.41.0

func (e *Element) GetClasses() string

func (*Element) GetID added in v0.41.0

func (e *Element) GetID() string

func (*Element) GetTarget added in v0.41.0

func (e *Element) GetTarget() string

func (*Element) HasAttribute added in v0.41.0

func (e *Element) HasAttribute(key string) bool

func (*Element) MergeAttributes added in v0.41.0

func (e *Element) MergeAttributes(attributes templ.Attributes)

func (*Element) SetAttribute added in v0.41.0

func (e *Element) SetAttribute(key string, value any)

func (*Element) SetID added in v0.41.0

func (e *Element) SetID(id string)

type ElementOption added in v0.41.0

type ElementOption func(*Element)

ElementOption is a functional option applied to an Element.

func WithAttribute

func WithAttribute(key string, value any) ElementOption

WithAttribute option applies the given attribute to the Element.

func WithAttributes

func WithAttributes(attributes templ.Attributes) ElementOption

WithAttributes option applies the set of attributes to the Element. It will merge the set with any existing elements (duplicate existing attributes will be overridden).

func WithClasses

func WithClasses(classes ...string) ElementOption

WithClasses option applies the given classes to the Element.

func WithID

func WithID(id string) ElementOption

type Image added in v0.50.0

type Image struct {
	*types.ImageInfo
	Width  int
	Height int
	Class  string
}

type Page

type Page struct {
	// Component is the main body content of the page.
	Component templ.Component
	// Title is a string for the (browser) titlebar.
	Title string
	// Description adds a meta tag with the given text.
	Description string
	// OGMetadata contains the Opengraph metadata for the page.
	OGMetadata *opengraph.Metadata
}

Page contains data for rendering a full HTML page.

type PageOption added in v0.21.0

type PageOption func(*Page)

PageOption is a functional option applied to a page.

func WithOGMetadata added in v0.21.0

func WithOGMetadata(metadata *opengraph.Metadata) PageOption

WithOGMetadata option sets the given metadata as appropriate Opengraph tags in the page header.

func WithPageDescription added in v0.21.0

func WithPageDescription(desc string) PageOption

WithPageDescription option sets a description meta tag in the page header.

func WithPageTitle added in v0.21.0

func WithPageTitle(title string) PageOption

WithPageTitle option sets the page title (displayed in the browser titlebar).

type ProxiedImage

type ProxiedImage struct {
	*Element
}

type SideBarComponent

type SideBarComponent struct {
	// contains filtered or unexported fields
}

type Subscription added in v0.27.0

type Subscription struct {
	*models.Subscription
}

func NewSubscriptionView added in v0.27.0

func NewSubscriptionView(s *models.Subscription) *Subscription

NewSubscriptionView wraps a Subscription object with additional methods for templates involving the subscription.

func (*Subscription) Card added in v0.27.0

func (s *Subscription) Card() templ.Component

Card renders a subscription in a card format, suitable for showing together with other subscriptions in a list/grid.

func (*Subscription) EditAttributes added in v0.27.0

func (s *Subscription) EditAttributes() templ.Attributes

EditAttributes generates a templ.Attributes object containing htmx directives for editing a subscription.

func (*Subscription) MarkAttributes added in v0.27.0

func (s *Subscription) MarkAttributes() templ.Attributes

MarkAttributes generates a templ.Attributes object containing htmx directives for marking a subscription.

func (*Subscription) ReportIssueAttributes added in v0.27.0

func (s *Subscription) ReportIssueAttributes() templ.Attributes

ReportIssueAttributes generates a templ.Attributes object containing directives for reporting an issue with the subscription.

func (*Subscription) ViewArticlesAttributes added in v0.27.0

func (s *Subscription) ViewArticlesAttributes() templ.Attributes

ViewAttributes generates a templ.Attributes object containing htmx directives for viewing a subscription.

func (*Subscription) ViewOriginAttributes added in v0.27.0

func (s *Subscription) ViewOriginAttributes() templ.Attributes

ViewOriginAttributes generates a templ.Attributes object containing htmx directives for viewing the subscription's origin URL.

Directories

Path Synopsis
helpers
mailto
Package mailto provides a method for easily constructing a mailto: string for use in links.
Package mailto provides a method for easily constructing a mailto: string for use in links.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL