From b42c824cdbcdcba1cb6ed16b742e579472fee930 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Sat, 14 May 2022 17:46:26 +0300 Subject: [PATCH] vweb: simplify @foo by removing V_TEMPLATE rule --- vlib/v/parser/tmpl.v | 14 +++++++------- vlib/v/tests/tmpl_script_tag_interpolation_test.v | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/vlib/v/parser/tmpl.v b/vlib/v/parser/tmpl.v index 910fcb8748..64156d3da8 100644 --- a/vlib/v/parser/tmpl.v +++ b/vlib/v/parser/tmpl.v @@ -287,13 +287,13 @@ fn vweb_tmpl_${fn_name}() string { } } .js { - if line.contains('//V_TEMPLATE') { - source.writeln(insert_template_code(fn_name, tmpl_str_start, line)) - } else { - // replace `$` to `\$` at first to escape JavaScript template literal syntax - source.writeln(line.replace(r'$', r'\$').replace(r'$$', r'@').replace(r'.$', - r'.@').replace(r"'", r"\'")) - } + // if line.contains('//V_TEMPLATE') { + source.writeln(insert_template_code(fn_name, tmpl_str_start, line)) + //} else { + // replace `$` to `\$` at first to escape JavaScript template literal syntax + // source.writeln(line.replace(r'$', r'\$').replace(r'$$', r'@').replace(r'.$', + // r'.@').replace(r"'", r"\'")) + //} continue } .css { diff --git a/vlib/v/tests/tmpl_script_tag_interpolation_test.v b/vlib/v/tests/tmpl_script_tag_interpolation_test.v index a98f16cb41..a5d20b3bdc 100644 --- a/vlib/v/tests/tmpl_script_tag_interpolation_test.v +++ b/vlib/v/tests/tmpl_script_tag_interpolation_test.v @@ -20,8 +20,8 @@ fn test_template_interpolation_can_be_selectively_turned_on_in_script_tags() { text := $tmpl('tmpl/selective_interpolation_in_script_tag.html') dump(text) assert text.contains('Username: abcd') - assert text.contains('var non_interpolated_labels = @benchmark_plot_data.dates;') - assert text.contains('var non_interpolated_values = @benchmark_plot_data.numerical_result;') + assert text.contains('var non_interpolated_labels = ['2012-11-30', '2022-12-29'];') + assert text.contains('var non_interpolated_values = [5, 6, 7, 1];') assert text.contains("var real_labels = ['2012-11-30', '2022-12-29']; //V_TEMPLATE") assert text.contains('var real_values = [5, 6, 7, 1]; //V_TEMPLATE') assert text.contains('Year: 2022')