struct Template
XuAPI
pub struct Template {
pub src string
}用途
公开结构体 `Template`。
参数
srcstring- 源数据
API
#text/template无反射模板:{{.}}、管道、if/with/range/define。
struct Templatepub struct Template {
pub src string
}公开结构体 `Template`。
src stringstruct Dictpub struct Dict {
pub keys []string
pub vals []string
}公开结构体 `Dict`。
keys []stringvals []stringnewpub fn new(src string) Template构造该类型的新值。
src stringTemplate — 该类型的值
new_dictpub fn new_dict() Dict构造 dict。
无
Dict — 该类型的值
(&mut Dict) setpub fn (d &mut Dict) set(k string, v string)在 `&mut Dict` 上调用 `set`。
d &mut Dictk stringv stringgetpub fn get(d &Dict, k string) stringget,返回 string。
d &Dictk stringstring — 结果字符串
execute_strpub fn execute_str(t &Template, root string) stringexecutestr。失败时 throw。
t &Templateroot stringstring — 结果字符串
executepub fn execute(t &Template, d &Dict) stringexecute,返回 string。失败时 throw。
t &Templated &Dictstring — 结果字符串
execute_listpub fn execute_list(t &Template, items []string) stringexecutelist。失败时 throw。
t &Templateitems []stringstring — 结果字符串
execute_str_htmlpub fn execute_str_html(t &Template, root string) stringexecutestrHTML。失败时 throw。
t &Templateroot stringstring — 结果字符串
execute_htmlpub fn execute_html(t &Template, d &Dict) stringexecuteHTML。失败时 throw。
t &Templated &Dictstring — 结果字符串
execute_list_htmlpub fn execute_list_html(t &Template, items []string) stringexecutelistHTML。失败时 throw。
t &Templateitems []stringstring — 结果字符串