vweb: add tmpl api to compile either file or a string
parent
13a7ce9e69
commit
6118875ee3
|
@ -11,11 +11,17 @@ const (
|
||||||
str_end = "\' ) "
|
str_end = "\' ) "
|
||||||
)
|
)
|
||||||
|
|
||||||
pub fn compile_template(path string) string {
|
// compile_file compiles the content of a file by the given path as a template
|
||||||
// lines := os.read_lines(path)
|
pub fn compile_file(path string) string {
|
||||||
mut html := os.read_file(path)or{
|
mut html := os.read_file(path)or{
|
||||||
panic('html failed')
|
panic('html failed')
|
||||||
}
|
}
|
||||||
|
return compile_template(html)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn compile_template(content string) string {
|
||||||
|
// lines := os.read_lines(path)
|
||||||
|
mut html := content
|
||||||
mut header := ''
|
mut header := ''
|
||||||
if os.exists('header.html') && html.contains('@header') {
|
if os.exists('header.html') && html.contains('@header') {
|
||||||
h := os.read_file('header.html')or{
|
h := os.read_file('header.html')or{
|
||||||
|
|
Loading…
Reference in New Issue