XU XUv0.8.8
EN

API

#text/template

import: #text/template

counts: 9 函数, 1 方法, 2 类型, 0 常量, 0 方法集

无反射模板:{{.}}、管道、if/with/range/define。

struct Template

XuAPI
pub struct Template {
    pub src string
}

用途

公开结构体 `Template`。

参数

src string
源数据

struct Dict

XuAPI
pub struct Dict {
    pub keys []string
    pub vals []string
}

用途

公开结构体 `Dict`。

参数

keys []string
字段([]string)
vals []string
字段([]string)

new

XuAPI
pub fn new(src string) Template

用途

构造该类型的新值。

参数

src string
源数据(string)

返回

Template — 该类型的值

new_dict

XuAPI
pub fn new_dict() Dict

用途

构造 dict。

参数

无

返回

Dict — 该类型的值

(&mut Dict) set

XuAPI
pub fn (d &mut Dict) set(k string, v string)

用途

在 `&mut Dict` 上调用 `set`。

参数

d &mut Dict
接收者 &mut Dict(可变借用)
k string
键或下标(string)
v string
值(string)

get

XuAPI
pub fn get(d &Dict, k string) string

用途

get,返回 string。

参数

d &Dict
d(借用,调用方仍持有;类型 &Dict)
k string
键或下标(string)

返回

string — 结果字符串

execute_str

XuAPI
pub fn execute_str(t &Template, root string) string

用途

executestr。失败时 throw。

参数

t &Template
t(借用,调用方仍持有;类型 &Template)
root string
root(string)

返回

string — 结果字符串

execute

XuAPI
pub fn execute(t &Template, d &Dict) string

用途

execute,返回 string。失败时 throw。

参数

t &Template
t(借用,调用方仍持有;类型 &Template)
d &Dict
d(借用,调用方仍持有;类型 &Dict)

返回

string — 结果字符串

execute_list

XuAPI
pub fn execute_list(t &Template, items []string) string

用途

executelist。失败时 throw。

参数

t &Template
t(借用,调用方仍持有;类型 &Template)
items []string
元素列表([]string)

返回

string — 结果字符串

execute_str_html

XuAPI
pub fn execute_str_html(t &Template, root string) string

用途

executestrHTML。失败时 throw。

参数

t &Template
t(借用,调用方仍持有;类型 &Template)
root string
root(string)

返回

string — 结果字符串

execute_html

XuAPI
pub fn execute_html(t &Template, d &Dict) string

用途

executeHTML。失败时 throw。

参数

t &Template
t(借用,调用方仍持有;类型 &Template)
d &Dict
d(借用,调用方仍持有;类型 &Dict)

返回

string — 结果字符串

execute_list_html

XuAPI
pub fn execute_list_html(t &Template, items []string) string

用途

executelistHTML。失败时 throw。

参数

t &Template
t(借用,调用方仍持有;类型 &Template)
items []string
元素列表([]string)

返回

string — 结果字符串