parser

package
v0.1.41-alpha Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	HbConfig map[string]interface{}
)
View Source
var KnownTypes = map[string]bool{}
View Source
var (
	PostProcessedHyperScriptStoreMutex sync.RWMutex
)

Functions

func AddTemplate

func AddTemplate(metadata, content string)

AddTemplate stores a template in the global map using a unique key (metadata).

func ClearTemplateStore

func ClearTemplateStore()

ClearTemplateStore clears all templates in the global template store.

func GetHyperScriptFiles

func GetHyperScriptFiles(baseUrl string) ([]string, error)

GetHyperScriptFiles returns a list of .hyperbricks files in the specified directory.

func GetLogger

func GetLogger() *zap.SugaredLogger

GetLogger returns the singleton SugaredLogger instance

func GetTemplate

func GetTemplate(metadata string) (string, bool)

GetTemplate retrieves a template by its metadata key.

func GetTemplateStore

func GetTemplateStore() map[string]string

GetTemplateStore retrieves a copy of the current template store.

func LogTemplates

func LogTemplates()

func LookupByPath

func LookupByPath(data map[string]interface{}, path string) (interface{}, error)

LookupByPath retrieves a value from a nested map using a dot-separated key path.

func ParseHyperScript

func ParseHyperScript(input string) map[string]interface{}

ParseHyperScript parses HyperBricks input and returns a nested configuration. It now supports variable definitions and substitutions.

func PreprocessHyperScript

func PreprocessHyperScript(hyperBricks string, hyperbricksDir string, templateDir string) (string, error)

PreprocessHyperScript processes @import directives and replaces TEMPLATE tokens.

func PrintConfig

func PrintConfig(config map[string]interface{}, level int) string

PrintConfig recursively builds a structured representation of the configuration.

func PrintJSON

func PrintJSON(config map[string]interface{}) string

PrintJSON converts the configuration to an indented JSON string.

func StripCDATAAndStore

func StripCDATAAndStore(input string) string

StripCDATAAndStore extracts custom CDATA sections with metadata and content, replaces them with the metadata name, and stores them in the global templateStore via AddTemplate.

func StripComments

func StripComments(input string) string

func StripCommentsV2

func StripCommentsV2(input string) string

func StripCommentsV3

func StripCommentsV3(input string) string

Types

type HyperScriptStringArray

type HyperScriptStringArray struct {
	HyperBricksStore                  map[string]string
	PreProcessedHyperScriptStoreMutex sync.RWMutex
}

HyperScriptStringArray is a struct that holds a map of loaded HyperBricks strings and provides thread-safe access to the data.

func (*HyperScriptStringArray) GetAllHyperBricks

func (tsa *HyperScriptStringArray) GetAllHyperBricks() map[string]string

GetAllHyperBricks returns a copy of all loaded Hyperbricks contents. This method is exported (starts with an uppercase letter) to be accessible from other packages.

func (*HyperScriptStringArray) GetHyperScriptContents

func (t *HyperScriptStringArray) GetHyperScriptContents(route string) (string, bool)

GetHyperScriptContents retrieves the content of a Hyperbricks by its route (metadata key).

func (*HyperScriptStringArray) PreProcessHyperBricksFromFiles

func (t *HyperScriptStringArray) PreProcessHyperBricksFromFiles(hyperbricksDir string, templateDir string) error

PreProcessHyperBricksFromFiles loads Hyperbricks files' contents from the specified directory and stores them in the HyperScriptStringArray instance.

func (*HyperScriptStringArray) PreProcessHyperScriptFromFile

func (t *HyperScriptStringArray) PreProcessHyperScriptFromFile(hyperbricksfile string, hyperbricksDir string, templateDir string) error

PreProcessHyperScriptFromFile loads a HyperBricks file's content from the specified file path and stores it in the HyperScriptStringArray instance.

Jump to

Keyboard shortcuts

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