File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -359,6 +359,19 @@ function M.RegQAUI:get_special()
359
359
return res
360
360
end
361
361
362
+ -- NOTE: jijia.nvim has some bug when rendering if logic. {% if p %} will be rendered as true if p == "";
363
+ -- So we need to patch it to convert empty string
364
+ -- - you can test by `print(require"jinja".lupa.expand("| {% if p %}GOOD{% endif %} |", {p=""}))`
365
+ function M .patch_tpl_values (tpl_values )
366
+ for k , v in pairs (tpl_values ) do
367
+ -- Convert empty string or whitespace-only values to nil
368
+ if v == " " then
369
+ tpl_values [k ] = nil
370
+ end
371
+ end
372
+ return tpl_values
373
+ end
374
+
362
375
363
376
function M .RegQAUI :get_tpl_values ()
364
377
local tpl_values = {}
@@ -388,7 +401,8 @@ function M.RegQAUI:get_q()
388
401
-- return require('jinja').lupa.expand(s, t)
389
402
return require (' jinja' ).lupa .expand (s , tab )
390
403
end
391
- return interp (M .get_tpl (), self :get_tpl_values ())
404
+
405
+ return interp (M .get_tpl (), M .patch_tpl_values (self :get_tpl_values ()))
392
406
end
393
407
394
408
--- register common keys for dialogs
You can’t perform that action at this time.
0 commit comments