@@ -159,7 +159,8 @@ fn (mut p Parser) comptime_call() ast.ComptimeCall {
159
159
pos: start_pos.extend (p.prev_tok.pos ())
160
160
}
161
161
}
162
- mut literal_string_param := if is_html { '' } else { p.tok.lit }
162
+ has_string_arg := p.tok.kind == .string
163
+ mut literal_string_param := if is_html && ! has_string_arg { '' } else { p.tok.lit }
163
164
if p.tok.kind == .name {
164
165
if var := p.scope.find_var (p.tok.lit) {
165
166
if var.expr is ast.StringLiteral {
@@ -173,7 +174,12 @@ fn (mut p Parser) comptime_call() ast.ComptimeCall {
173
174
}
174
175
path_of_literal_string_param := literal_string_param.replace ('/' , os.path_separator)
175
176
mut arg := ast.CallArg{}
176
- if ! is_html {
177
+ if is_html && ! (has_string_arg || p.tok.kind == .rpar) {
178
+ p.error ('expecting `\$ vweb.html()` for a default template path or `\$ vweb.html("/path/to/template.html")`' )
179
+ }
180
+ if is_html && p.tok.kind != .string {
181
+ // $vweb.html() can have no arguments
182
+ } else {
177
183
arg_expr := p.expr (0 )
178
184
arg = ast.CallArg{
179
185
expr: arg_expr
@@ -209,13 +215,17 @@ fn (mut p Parser) comptime_call() ast.ComptimeCall {
209
215
fn_path := p.cur_fn_name.split ('_' )
210
216
fn_path_joined := fn_path.join (os.path_separator)
211
217
compiled_vfile_path := os.real_path (p.scanner.file_path.replace ('/' , os.path_separator))
212
- tmpl_path := if is_html { '${fn_path.last()} .html' } else { path_of_literal_string_param }
218
+ tmpl_path := if is_html && ! has_string_arg {
219
+ '${fn_path.last()} .html'
220
+ } else {
221
+ path_of_literal_string_param
222
+ }
213
223
// Looking next to the vweb program
214
224
dir := os.dir (compiled_vfile_path)
215
225
mut path := os.join_path_single (dir, fn_path_joined)
216
226
path + = '.html'
217
227
path = os.real_path (path)
218
- if ! is_html {
228
+ if ! is_html || has_string_arg {
219
229
if os.is_abs_path (tmpl_path) {
220
230
path = tmpl_path
221
231
} else {
0 commit comments