Package list

import "gitlab.com/zoralab/bissetii/pkg/internal/list"

Package list is for rendering information in an itemized listing.

The HTML template codes are written in Go’s string format under the corresponding group. This allows one to embed the HTML codes instead of parsing it from file.

Constants

Constants for managing the package as a whole.

const (
	// Name is the block name (`{{- define "this-name" -}}`).
	Name = "list"

	// AMPName is the AMP HTML block name.
	AMPName = root.AMPPrefix + Name

	// ParametersComment are the list of comment headers
	// describing inputs.
	ParametersComment = `
{{- /* .IsOrdered         = List should be ordered (true/false)     */ -}}
{{- /* .ID                = List id attribute (optional)            */ -}}
{{- /* .Class             = List class attribute (optional)         */ -}}
{{- /* .Label             = List aria-label attribute (optional)    */ -}}
{{- /* .Contents          = List of HTML contents (slice)           */ -}}
`
)

Dependencies are the dependent codes for building independent template.

This is useful for rendering portable template usage like Hugo partials where they do not share a common definition source.

const (
	// DepHTML is the vanilla HTML output type.
	DepHTML = ``

	// DepAMPHTML is the Accelerated Mobile Pages HTML output
	// type.
	DepAMPHTML = ``
)

Full HTML codes for rendering templates without needing to parse file.

const (
	// HTML is the vanilla HTML output type.
	HTML = `
{{- if .IsOrdered }}
<ol {{- if .ID }}

	id="{{- .ID -}}"
{{- end }}
{{- if .Class }}

	class="{{- .Class -}}"
{{- end }}
{{- if .Label }}

	aria-label="{{- .Label -}}"
{{- end -}}
>

{{- else }}
<ul {{- if .ID }}

	id="{{- .ID -}}"
{{- end }}
{{- if .Class }}

	class="{{- .Class -}}"
{{- end }}
{{- if .Label }}

	aria-label="{{- .Label -}}"
{{- end -}}
>

{{- end }}



{{- range $content := .Contents }}

	<li>{{- $content -}}</li>
{{- end }}



{{- if .IsOrdered }}
</ol>
{{- else }}
</ul>
{{- end }}
`

	// AMPHTML is the Accelerated Mobile Pages HTML output type.
	AMPHTML = HTML
)

Data

type Data struct {
	IsOrdered bool
	ID        string
	Class     string
	Label     string
	Contents  []string
}

Data is the data structure for rendering the component.