From 851db8ea982cb52c6a4ed47f3f674f5ecf0b9709 Mon Sep 17 00:00:00 2001 From: Stephen Sigwart Date: Fri, 16 Aug 2019 15:14:07 -0400 Subject: [PATCH] Smarty completions update: - Fix {strip} - Pull variables from {foreach} --- src/udl/skel/Smarty/pylib/lang_smarty.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/udl/skel/Smarty/pylib/lang_smarty.py b/src/udl/skel/Smarty/pylib/lang_smarty.py index a3f722e2e4..9b97f8663a 100644 --- a/src/udl/skel/Smarty/pylib/lang_smarty.py +++ b/src/udl/skel/Smarty/pylib/lang_smarty.py @@ -83,7 +83,7 @@ "rdelim", "section", "sectionelse", - "string", + "strip", "textformat" ] @@ -235,13 +235,17 @@ def async_eval_at_trg(self, buf, trg, ctlr): _re_assign_var = re.compile(r'\{assign\s+(?:[^}]+\s)?name=[\'"](?P\w+)[\'"]', re.M|re.U) # Variable in form {... assign="..." _re_assign_attr_var = re.compile(r'\{[^}]+\sassign=[\'"](?P\w+)[\'"]', re.M|re.U) + # Variable in form {foreach item="..." + _re_foreach_item_var = re.compile(r'\{foreach\s+(?:[^}]+\s)?item=[\'"](?P\w+)[\'"]', re.M|re.U) + # Variable in form {foreach key="..." + _re_foreach_key_var = re.compile(r'\{foreach\s+(?:[^}]+\s)?key=[\'"](?P\w+)[\'"]', re.M|re.U) # Any variable used _re_used_var = re.compile(r'{[^}]*(?P\$\w+)', re.M|re.U) def _get_smarty_vars(self, buf): """ Get Smarty variables from this file """ smarty_vars = ["$smarty"] # Add any vars assigned in this file - for regex in [self._re_assign_var, self._re_assign_attr_var]: + for regex in [self._re_assign_var, self._re_assign_attr_var, self._re_foreach_item_var, self._re_foreach_key_var]: for match in re.finditer(regex, buf.accessor.text): groups = match.groupdict() this_var = "$" + groups['variable']