mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
vweb: allow running vweb apps from a different directory
This commit is contained in:
parent
79abc0c16f
commit
ecc8728643
@ -89,13 +89,19 @@ fn (p mut Parser) comp_time() {
|
|||||||
// Compile vweb html template to V code, parse that V code and embed the resulting V functions
|
// Compile vweb html template to V code, parse that V code and embed the resulting V functions
|
||||||
// that returns an html string
|
// that returns an html string
|
||||||
else if p.tok == .name && p.lit == 'vweb' {
|
else if p.tok == .name && p.lit == 'vweb' {
|
||||||
path := p.cur_fn.name + '.html'
|
mut path := p.cur_fn.name + '.html'
|
||||||
if p.pref.is_debug {
|
if p.pref.is_debug {
|
||||||
println('compiling tmpl $path')
|
println('compiling tmpl $path')
|
||||||
}
|
}
|
||||||
|
if !os.file_exists(path) {
|
||||||
|
// Can't find the template file in current directory,
|
||||||
|
// try looking next to the vweb program, in case it's run with
|
||||||
|
// v path/to/vweb_app.v
|
||||||
|
path = os.dir(p.scanner.file_path) + '/' + path
|
||||||
if !os.file_exists(path) {
|
if !os.file_exists(path) {
|
||||||
p.error('vweb HTML template "$path" not found')
|
p.error('vweb HTML template "$path" not found')
|
||||||
}
|
}
|
||||||
|
}
|
||||||
p.check(.name) // skip `vweb.html()` TODO
|
p.check(.name) // skip `vweb.html()` TODO
|
||||||
p.check(.dot)
|
p.check(.dot)
|
||||||
p.check(.name)
|
p.check(.name)
|
||||||
|
Loading…
Reference in New Issue
Block a user