Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions pagebuilder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -1010,6 +1010,20 @@ func (b *Builder) ContainerByName(name string) (r *ContainerBuilder) {
panic(fmt.Sprintf("No container: %s", name))
}

// FindContainerByName returns the container builder for the given name,
// or nil if no container with that name is registered. Unlike
// ContainerByName it does not panic, making it safe for public-facing
// routes where a stale DB row may reference a container type that has
// since been removed.
func (b *Builder) FindContainerByName(name string) *ContainerBuilder {
for _, cb := range b.containerBuilders {
if cb.name == name {
return cb
}
}
return nil
}

type ContainerBuilder struct {
builder *Builder
name string
Expand Down Expand Up @@ -1226,6 +1240,11 @@ func (b *ContainerBuilder) RenderFunc(v RenderFunc) *ContainerBuilder {
return b
}

// GetRenderFunc returns the registered render function for this container.
func (b *ContainerBuilder) GetRenderFunc() RenderFunc {
return b.renderFunc
}

func (b *ContainerBuilder) Cover(v string) *ContainerBuilder {
b.cover = v
return b
Expand Down