youtube / spitfire

A high-performance Python template language
BSD 3-Clause "New" or "Revised" License
404 stars 58 forks source link

Spitfire chokes on '))}' #2

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
1.) Create a spitfire file with the following content:

#def foo($s)
$s
#end def

#def bar($s)
$s
#end def

<script type="text/javascript">
var bar={ cat: $foo($bar("dog")) };
</script>

2.) Run SpitFire on it.

It produces the following error:
Trying to find START_PLACEHOLDER on line 11:
>  var bar={ cat: $foo($bar("dog")) };
>                                  ^
List of nearby tokens: 
  (@106)  PLACEHOLDER_OPEN_PAREN  =  u'('
  (@107)  START_PLACEHOLDER  =  u'$'
  (@108)  ID  =  u'bar'
  (@111)  PLACEHOLDER_OPEN_PAREN  =  u'('
  (@112)  '"'  =  u'"'
  (@113)  DOUBLE_QUOTE_STR  =  u'dog'
  (@116)  '"'  =  u'"'
  (@117)  CLOSE_PAREN  =  u')'
  (@118)  CLOSE_PAREN  =  u')'
  (@119)  PLACEHOLDER_CLOSE_BRACE  =  u' }'

3.) I expect it to produce the following:
<script type="text/javascript">
var bar={ cat: "dog" };
</script>

Original issue reported on code.google.com by mervyn.y...@gmail.com on 12 Aug 2009 at 4:54

GoogleCodeExporter commented 8 years ago
The syntax here is a little ambiguous because braces are optional when using 
$placeholder.

If you use ${placeholder} around the expression, everything will work correctly.

In this case:

var bar={ cat: ${foo($bar("dog"))} };

Original comment by ms...@gmail.com on 12 Aug 2009 at 8:17