mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
parser, fmt: fix fmt error in $tmpl(path)
(#16949)
This commit is contained in:
parent
49a434e11f
commit
329b9f1a6a
@ -1880,7 +1880,7 @@ pub fn (mut f Fmt) comptime_call(node ast.ComptimeCall) {
|
|||||||
if node.method_name == 'html' {
|
if node.method_name == 'html' {
|
||||||
f.write('\$vweb.html()')
|
f.write('\$vweb.html()')
|
||||||
} else {
|
} else {
|
||||||
f.write("\$tmpl('${node.args_var}')")
|
f.write('\$tmpl(${node.args[0].expr})')
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if node.is_embed {
|
if node.is_embed {
|
||||||
|
@ -133,7 +133,7 @@ fn (mut p Parser) comptime_call() ast.ComptimeCall {
|
|||||||
if var.expr is ast.StringLiteral {
|
if var.expr is ast.StringLiteral {
|
||||||
literal_string_param = var.expr.val
|
literal_string_param = var.expr.val
|
||||||
}
|
}
|
||||||
} else if var := p.scope.find_const(p.mod + '.' + p.tok.lit) {
|
} else if var := p.table.global_scope.find_const(p.mod + '.' + p.tok.lit) {
|
||||||
if var.expr is ast.StringLiteral {
|
if var.expr is ast.StringLiteral {
|
||||||
literal_string_param = var.expr.val
|
literal_string_param = var.expr.val
|
||||||
}
|
}
|
||||||
@ -203,6 +203,7 @@ fn (mut p Parser) comptime_call() ast.ComptimeCall {
|
|||||||
is_vweb: true
|
is_vweb: true
|
||||||
method_name: method_name
|
method_name: method_name
|
||||||
args_var: literal_string_param
|
args_var: literal_string_param
|
||||||
|
args: [arg]
|
||||||
pos: start_pos.extend(p.prev_tok.pos())
|
pos: start_pos.extend(p.prev_tok.pos())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -244,6 +245,7 @@ fn (mut p Parser) comptime_call() ast.ComptimeCall {
|
|||||||
vweb_tmpl: file
|
vweb_tmpl: file
|
||||||
method_name: method_name
|
method_name: method_name
|
||||||
args_var: literal_string_param
|
args_var: literal_string_param
|
||||||
|
args: [arg]
|
||||||
pos: start_pos.extend(p.prev_tok.pos())
|
pos: start_pos.extend(p.prev_tok.pos())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,11 +11,11 @@ fn (s SomeThing) someval(what string) string {
|
|||||||
|
|
||||||
fn (s SomeThing) template_variable() string {
|
fn (s SomeThing) template_variable() string {
|
||||||
path := 'tmpl/template.in'
|
path := 'tmpl/template.in'
|
||||||
return $tmpl('tmpl/template.in')
|
return $tmpl(path)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn (s SomeThing) template_const() string {
|
fn (s SomeThing) template_const() string {
|
||||||
return $tmpl('tmpl/template.in')
|
return $tmpl(template_path)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_tmpl_with_variable_path() {
|
fn test_tmpl_with_variable_path() {
|
||||||
|
Loading…
Reference in New Issue
Block a user