Documentation
¶
Index ¶
- Variables
- func Close()
- func Compile(path string, opts map[string]interface{}) ([]byte, string, uint8, error)
- func GetOpt(name []byte, opts *map[string]interface{}, eachArgs *[]EachArgs, escape uint8, ...) interface{}
- func HasPreCompile(path string) (bool, error)
- func HasStaticCompile(path string) (bool, error)
- func InitDefault()
- func LogErr(err error)
- func PreCompile(path string, opts map[string]interface{}) error
- func SetConfig(config Config) error
- type Config
- type EachArgs
Constants ¶
This section is empty.
Variables ¶
var TagFuncs tagFuncs = tagFuncs{}
Functions ¶
func Compile ¶
Compile will return html content, (or a static path when possible)
this method will automatically run the PreCompile method as needed
Output Types (note: only []byte or string will have a non empty value. if string == "", you can assume you have an html result)
[]byte: raw html (to send to client)
string: path to static html file
uint8: compression type:
- 0: uncompressed raw html
- 1: compressed to brotli
- 2: compressed to gzip
note: putting any extra '.' in a filename (apart from the extention name) may cause conflicts with restoring old cache files
func GetOpt ¶
func GetOpt(name []byte, opts *map[string]interface{}, eachArgs *[]EachArgs, escape uint8, precomp bool, stringsOnly bool) interface{}
GetOpt handles grabbing and escaping an option (or eachArgs as needed)
escape: 0 = raw, 1 = raw arg, 2 = html, 3 = arg, 4 = html arg key
func HasPreCompile ¶
HasPreCompile returns true if a file has been PreCompiled and exists in the cache
func HasStaticCompile ¶
HasStaticCompile returns true if a file has been PreCompiled and is static (and does not need to be compiled)
note: the Compile method will automatically detect this and pull from the cache when available
func InitDefault ¶
func InitDefault()
func PreCompile ¶
PreCompile will generate a new file for the cache (or a static file when possible)
note: putting any extra '.' in a filename (apart from the extention name) may cause conflicts with restoring old cache files
Types ¶
type Config ¶
type Config struct {
// Root dir for html files
// example: "~/MySiteDir/views"
// default: "./views"
Root string
// File Extention to use for html files (without the dot)
// example: "html"
// default: "html"
Ext string
// A public/static path for js, css, and other static files
// example: "~/MySiteDir/public"
// default: "./public"
Static string
// The url where public/static files will be served from (js, css, etc)
// example: "/cdn/assets"
// default: "/"
StaticUrl string
// A dir path to store static html files, for when the precompiler produces static html
StaticHTML string
// A dir path to cache dynamic html files, for when the precompiler produces dynamically changing content
CacheDir string
// Brotli compression level for precompressed static files (0-11)
//
// Gzip will be set to this number capped between 1-9 (if val > 6 {val -= 1})
PreCompress int
// Brotli compression level for live compressed files (0-11)
//
// Gzip will be set to this number capped between 1-9 (if val > 6 {val -= 1})
Compress int
// The maximum size of the compiled output before flushing it to the result writer
CompileMaxFlush uint
// Cache Time In Minutes
CacheTime int
// Weather or not to include .md files along with the default Ext value.
//
// turbx will compile markdown regardless of whether or not it is in a .md file.
IncludeMD bool
// A folder level to consider a root domain, to prevent use of components outside a specific root folder
DomainFolder uint
// Add a limit to component recursion
RecursionLimit uint
// Debug Mode For Developers
DebugMode bool
// contains filtered or unexported fields
}