API
Core
Text
IO / OS
Net
Encoding
Crypto
Compress / image / math
Database
External packages
UI
API
#html/template
Xu 0.8.8 API
import: #html/template
counts: 6 fns, 1 methods, 2 types, 0 consts, 0 ifaces
Templates with escaped interpolation. No JS/CSS/URL context switch.
struct Template
pub struct Template {
pub src string
}
Purpose
HTML-escaping template facade over text.template. Interpolation ({{.}} / {{.Key}}) goes through html.escape_string literal markup in the template source is left unchanged. No contextual escaping (script/style/url).
Parameters
src string source
struct Dict
pub struct Dict {
pub keys []string
pub vals []string
}
Purpose
Public struct `Dict`.
Parameters
keys []string field ([]string)
vals []string field ([]string)
new
pub fn new(src string ) Template
Purpose
Construct a new value of this type.
Parameters
src string source (string)
Returns
Template — a value of this type
new_dict
Purpose
Construct dict.
Parameters
none
Returns
Dict — a value of this type
(&mut Dict) set
pub fn (d &mut Dict) set(k string , v string )
Purpose
Call `set` on `&mut Dict`.
Parameters
d &mut Dict receiver &mut Dict (exclusive borrow)
k string key or index (string)
v string value (string)
get
pub fn get(d &Dict, k string ) string
Purpose
get; returns string.
Parameters
d &Dict d (borrowed; caller keeps it; type &Dict)
k string key or index (string)
Returns
string — result string
execute_str
pub fn execute_str(t &Template, root string ) string
Purpose
Execute str.
Parameters
t &Template t (borrowed; caller keeps it; type &Template)
root string root (string)
Returns
string — result string
execute
pub fn execute(t &Template, d &Dict) string
Purpose
execute; returns string.
Parameters
t &Template t (borrowed; caller keeps it; type &Template)
d &Dict d (borrowed; caller keeps it; type &Dict)
Returns
string — result string
execute_list
pub fn execute_list(t &Template, items []string ) string
Purpose
Execute list.
Parameters
t &Template t (borrowed; caller keeps it; type &Template)
items []string items ([]string)
Returns
string — result string