Skip to content

Commit 9e67739

Browse files
committed
parser: do import veb, only for templates that do use functions defined in veb
1 parent 75de056 commit 9e67739

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

vlib/v/parser/tmpl.v

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,7 @@ pub fn (mut p Parser) compile_template_file(template_file string, fn_name string
225225
mut source := strings.new_builder(1000)
226226
source.writeln('
227227
import strings
228-
import veb as _
229-
// === veb html template ===
228+
// === veb html template for file: ${template_file} ===
230229
fn veb_tmpl_${fn_name}() string {
231230
mut sb_${fn_name} := strings.new_builder(${lstartlength})\n
232231
@@ -457,7 +456,10 @@ fn veb_tmpl_${fn_name}() string {
457456
source.writeln('}')
458457
source.writeln('// === end of veb html template_file: ${template_file} ===')
459458

460-
result := source.str()
459+
mut result := source.str()
460+
if result.contains('veb.') {
461+
result = 'import veb\n' + result
462+
}
461463
$if trace_tmpl_expansion ? {
462464
eprintln('>>>>>>> template expanded to:')
463465
eprintln(result)

0 commit comments

Comments
 (0)