vweb: @include tempaltes
							parent
							
								
									56ae3797dd
								
							
						
					
					
						commit
						6b06184ef4
					
				|  | @ -29,15 +29,6 @@ enum State { | |||
| pub fn compile_template(html_, fn_name string) string { | ||||
| 	// lines := os.read_lines(path)
 | ||||
| 	mut html := html_.trim_space() | ||||
| 	mut header := '' | ||||
| 	if os.exists('templates/header.html') && html.contains('@header') { | ||||
| 		h := os.read_file('templates/header.html') or { | ||||
| 			panic('reading file templates/header.html failed') | ||||
| 		} | ||||
| 		header = h.trim_space().replace("\'", '"') | ||||
| 		html = header + html | ||||
| 	} | ||||
| 
 | ||||
| 	mut lines := html.split_into_lines() | ||||
| 	mut s := strings.new_builder(1000) | ||||
| 	// base := path.all_after_last('/').replace('.html', '')
 | ||||
|  | @ -67,7 +58,7 @@ _ = header | |||
| 		else if line == '</script>' { | ||||
| 			state = .html | ||||
| 		} | ||||
| 		if line.contains('@include ') && false { | ||||
| 		if line.contains('@include ') { | ||||
| 			// TODO
 | ||||
| 			pos := line.index('@include ') or { | ||||
| 				continue | ||||
|  | @ -78,12 +69,14 @@ _ = header | |||
| 				panic('reading file $file_name failed') | ||||
| 			} | ||||
| 			file_content = file_content.replace("\'", '"') | ||||
| 			lines2 := file_content.split_into_lines() | ||||
| 			for l in lines2 { | ||||
| 				lines.insert(i+1, l) | ||||
| 			} | ||||
| 			include_file_lines := file_content.split_into_lines() | ||||
| 			lines_before := lines[0 .. i].clone() | ||||
| 			lines_after := lines[i + 1 .. lines.len].clone() | ||||
| 			lines = lines_before | ||||
| 			lines << include_file_lines | ||||
| 			lines << lines_after | ||||
| 			i-- | ||||
| 			continue | ||||
| 			//s.writeln(file_content)
 | ||||
| 		} else if line.contains('@js ') { | ||||
| 			pos := line.index('@js') or { | ||||
| 				continue | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue