Skip to content

Commit

Permalink
Retain inner } braces, useful for templates
Browse files Browse the repository at this point in the history
When div{{{title}}} is mapped it will become <div>{{title}}</div>
  • Loading branch information
maurizi committed Sep 20, 2013
1 parent 047fd15 commit 2fa779e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion sparkup
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,7 @@ class Token:

# Try looking for text
text = None
for text in re.findall('\{([^\}]*)\}', self.str):
for text in re.findall('\{(.*?)\}(?!\})', self.str):
self.str = self.str.replace("{" + text + "}", "")
if text is not None:
self.text = text
Expand Down
6 changes: 5 additions & 1 deletion sparkup-unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class SparkupTest:
},
'Multiplier test 2': {
'input': 'ul > li.item-$*3',
'output': '<ul>\n <li class="item-1">$1</li>\n <li class="item-2">$2</li>\n <li class="item-3">$3</li>\n</ul>$0'
'output': '<ul>\n <li class="item-1">$1</li>\n <li class="item-2">$2</li>\n <li class="item-3">$3</li>\n</ul>$0'
},
'Multiplier test 3': {
'input': 'ul > li.item-$*3 > a',
Expand Down Expand Up @@ -99,6 +99,10 @@ class SparkupTest:
'input': 'p [attrib=text.com]',
'output': '<p attrib="text.com">$1</p>$0'
},
'Nested curly braces test': {
'input': 'p{{{ title }}}',
'output': '<p>{{ title }}</p>$0'
},
# Add: text test, broken test, multi-attribute tests, indentation test, start and end comments test
}
def run(self):
Expand Down
2 changes: 1 addition & 1 deletion vim/ftplugin/html/sparkup.py
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,7 @@ def _init_element(self):

# Try looking for text
text = None
for text in re.findall('\{([^\}]*)\}', self.str):
for text in re.findall('\{(.*?)\}(?!\})', self.str):
self.str = self.str.replace("{" + text + "}", "")
if text is not None:
self.text = text
Expand Down

0 comments on commit 2fa779e

Please sign in to comment.