datatables

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDataTablesCreateOutputProcessorFunc

func NewDataTablesCreateOutputProcessorFunc(
	lookup render.TemplateLookup,
	templateName string,
	options ...DataTablesOutputFormatterOption,
) glazed.CreateProcessorFunc

NewDataTablesCreateOutputProcessorFunc creates a glazed.CreateProcessorFunc based on a TemplateLookup and a template name.

func NewDataTablesHTMLTemplateCreateProcessorFunc

func NewDataTablesHTMLTemplateCreateProcessorFunc(
	options ...render.HTMLTemplateOutputFormatterOption,
) (glazed.CreateProcessorFunc, error)

func NewDataTablesLookupTemplate

func NewDataTablesLookupTemplate() *render.LookupTemplateFromFS

Types

type DataTables

type DataTables struct {
	Command *cmds.CommandDescription
	// LongDescription is the HTML of the rendered markdown of the long description of the command.
	LongDescription string

	Layout *layout.Layout
	Links  []layout.Link

	// Stream provides a channel where each element represents a row of the table
	// to be rendered, already formatted.
	// Per default, we will render the individual rows as HTML, but the JSRendering
	// flag will make this output individual entries of a JS array.
	//
	// TODO(manuel, 2023-06-04): Maybe we could make this be an iterator of rows that provide access to the individual
	// columns for more interesting HTML shenanigans too.
	JSStream   <-chan template.JS
	HTMLStream <-chan template.HTML
	// Configuring the template to load the table data through javascript, and provide the data itself
	// as a JSON array inlined in the HTML of the page.
	JSRendering bool

	Columns []string

	// UseDataTables is using the datatables.net framework.
	// This is an opinionated way of proposing different table layouts and javascript functionality
	// (for now). If a user wants more advanced customization, they can use the HTMLTemplateOutputFormatter
	// or use this implementation for inspiration.
	UseDataTables bool

	// AdditionalData to be passed to the rendering engine
	AdditionalData map[string]interface{}
}

DataTables describes the data passed to the template displaying the results of a glazed command. It's meant to be a more structured layer on top of the HTMLOutputTemplateFormatter that parka offers for having users provide their own template formatting.

type DataTablesOutputFormatter

type DataTablesOutputFormatter struct {
	*render.HTMLTemplateOutputFormatter
	// contains filtered or unexported fields
}

func (*DataTablesOutputFormatter) Output

type DataTablesOutputFormatterOption

type DataTablesOutputFormatterOption func(*DataTablesOutputFormatter)

func WithAdditionalData

func WithAdditionalData(data map[string]interface{}) DataTablesOutputFormatterOption
func WithAppendLinks(links ...layout.Link) DataTablesOutputFormatterOption

func WithColumns

func WithColumns(columns ...string) DataTablesOutputFormatterOption

func WithJSRendering

func WithJSRendering() DataTablesOutputFormatterOption

WithJSRendering enables JS rendering for the DataTables renderer. This means that we will render the table into the toplevel element `tableData` in javascript, and not call the parent output formatter

func WithLinks(links ...layout.Link) DataTablesOutputFormatterOption

func WithLongDescription

func WithLongDescription(desc string) DataTablesOutputFormatterOption
func WithPrependLinks(links ...layout.Link) DataTablesOutputFormatterOption

func WithReplaceAdditionalData

func WithReplaceAdditionalData(data map[string]interface{}) DataTablesOutputFormatterOption

func WithUseDataTables

func WithUseDataTables() DataTablesOutputFormatterOption

Jump to

Keyboard shortcuts

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