Documentation ¶
Index ¶
- func WithDB(name string, db *sql.DB, opt *sql.TxOptions) xtemplate.Option
- func WithFS(name string, fs fs.FS) xtemplate.Option
- func WithKV(name string, kv map[string]string) xtemplate.Option
- type Dir
- type DotDB
- func (c *DotDB) Commit() (string, error)
- func (c *DotDB) Exec(query string, params ...any) (result sql.Result, err error)
- func (c *DotDB) QueryRow(query string, params ...any) (map[string]any, error)
- func (c *DotDB) QueryRows(query string, params ...any) (rows []map[string]any, err error)
- func (c *DotDB) QueryVal(query string, params ...any) (any, error)
- func (c *DotDB) Rollback() (string, error)
- type DotDBProvider
- func (dp *DotDBProvider) Cleanup(v any, err error) error
- func (d *DotDBProvider) MarshalJSON() ([]byte, error)
- func (d *DotDBProvider) MarshalText() ([]byte, error)
- func (DotDBProvider) New() xtemplate.DotProvider
- func (DotDBProvider) Type() string
- func (d *DotDBProvider) UnmarshalJSON(b []byte) error
- func (d *DotDBProvider) UnmarshalText(b []byte) error
- func (d *DotDBProvider) Value(r xtemplate.Request) (any, error)
- type DotFSProvider
- func (p *DotFSProvider) Cleanup(a any, err error) error
- func (d *DotFSProvider) MarshalJSON() ([]byte, error)
- func (fs *DotFSProvider) MarshalText() ([]byte, error)
- func (DotFSProvider) New() xtemplate.DotProvider
- func (DotFSProvider) Type() string
- func (d *DotFSProvider) UnmarshalJSON(b []byte) error
- func (fs *DotFSProvider) UnmarshalText(b []byte) error
- func (p *DotFSProvider) Value(r xtemplate.Request) (any, error)
- type DotKV
- type DotKVProvider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithFS ¶
WithFS creates an xtemplate.Option that can be used with xtemplate.Config.Server, xtemplate.Config.Instance, or xtemplate.Main to add an fs dot provider to the config.
Types ¶
type Dir ¶ added in v0.7.0
type Dir struct {
// contains filtered or unexported fields
}
Dir
func (Dir) List ¶ added in v0.7.0
List reads and returns a slice of names from the given directory relative to the FS root.
type DotDB ¶
type DotDB struct {
// contains filtered or unexported fields
}
DotDB is used to create a dot field value that can query a SQL database. When any of its statement executing methods are called, it creates a new transaction. When template execution finishes, if there were no errors it automatically commits any uncommitted transactions remaining after template execution completes, but if there were errors then it calls rollback on the transaction.
func (*DotDB) Commit ¶
Commit manually commits any implicit transactions opened by this DotDB. This is called automatically if there were no errors at the end of template execution.
func (*DotDB) Exec ¶
Exec executes a statement with parameters and returns the raw sql.Result. Note: this can be a bit difficult to use inside a template, consider using other methods that provide easier to use return values.
func (*DotDB) QueryRow ¶
QueryRow executes a query, which must return one row, and returns it as a map[string]any.
func (*DotDB) QueryRows ¶
QueryRows executes a query and buffers all rows into a []map[string]any object.
type DotDBProvider ¶
type DotDBProvider struct { *sql.DB `json:"-"` *sql.TxOptions `json:"-"` Driver string `json:"driver"` Connstr string `json:"connstr"` MaxOpenConns int `json:"max_open_conns"` }
func (*DotDBProvider) MarshalJSON ¶
func (d *DotDBProvider) MarshalJSON() ([]byte, error)
func (*DotDBProvider) MarshalText ¶
func (d *DotDBProvider) MarshalText() ([]byte, error)
func (DotDBProvider) New ¶
func (DotDBProvider) New() xtemplate.DotProvider
func (DotDBProvider) Type ¶
func (DotDBProvider) Type() string
func (*DotDBProvider) UnmarshalJSON ¶
func (d *DotDBProvider) UnmarshalJSON(b []byte) error
func (*DotDBProvider) UnmarshalText ¶
func (d *DotDBProvider) UnmarshalText(b []byte) error
type DotFSProvider ¶
DotFSProvider can configure an xtemplate dot field to provide file system access to templates. You can configure xtemplate to use it three ways:
By setting a cli flag: “
func (*DotFSProvider) Cleanup ¶ added in v0.5.1
func (p *DotFSProvider) Cleanup(a any, err error) error
func (*DotFSProvider) MarshalJSON ¶
func (d *DotFSProvider) MarshalJSON() ([]byte, error)
func (*DotFSProvider) MarshalText ¶
func (fs *DotFSProvider) MarshalText() ([]byte, error)
func (DotFSProvider) New ¶
func (DotFSProvider) New() xtemplate.DotProvider
func (DotFSProvider) Type ¶
func (DotFSProvider) Type() string
func (*DotFSProvider) UnmarshalJSON ¶
func (d *DotFSProvider) UnmarshalJSON(b []byte) error
func (*DotFSProvider) UnmarshalText ¶
func (fs *DotFSProvider) UnmarshalText(b []byte) error
type DotKVProvider ¶
func (DotKVProvider) New ¶
func (DotKVProvider) New() xtemplate.DotProvider
func (DotKVProvider) Type ¶
func (DotKVProvider) Type() string