Package cssfont

import "gitlab.com/zoralab/bissetii/pkg/internal/css/cssfont"

Package cssfont is the full package for rendering @font-face css component.

The CSS template codes are written in Go’s string format under the corresponding group. This allows one to embed the CSS 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 = "css-font"

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

	// ParametersComment are the list of comment headers
	// describing inputs.
	ParametersComment = `
{{- /* .URLs                 - List of URLs                               */ -}}
{{- /* .Name                 - Font name                                  */ -}}

`
)

Full CSS are the full css codes.

const (
	// NORMAL is the normal human-readable CSS
	NORMAL = `
{{- $isFirst := true -}}

{{- if and .Name (not (eq (len .URLs) 0 )) }}
@font-face{

	font-family: {{ .Name -}};

	src: {{ range $url := .URLs -}}

		{{- if not $isFirst -}}, {{ end -}}url({{- $url -}})

		{{- $isFirst = false -}}

	{{- end -}};
}
{{- end }}
`

	// MIN is the minified CSS
	MIN = `
{{- $isFirst := true -}}

{{- if and .Name (not (eq (len .URLs) 0 )) -}}
@font-face{font-family: {{- .Name -}};src:

	{{- range $url := .URLs -}}

		{{- if not $isFirst -}}, {{- end -}}url({{- $url -}})

		{{- $isFirst = false -}}

	{{- end -}}
;}
{{- end -}}
`
)

Data

type Data struct {
	URLs []string
	Name string
}

Data is the data structure for rendering the css code.