#246

Scaml: element attribute value cannot contain curly braces

    • Created on: Mon, Jun 06 2011 (12 months ago)
    • Reported by: ternary.expression
    • Assigned to: -
    • Milestone: -
    • Estimate: None/Small/Medium/Large None
    • Status: New
    • Priority: Normal (3)
    • Component: scalate-core: scaml
    • Permission type: None
    This occurs in Scalate 1.4.1. Using { } braces within a string used for an attribute value seems to confuse the scaml parser. For example:
    %element{:foo => {"function(){}"}}

    The exception is:
    org.fusesource.scalate.InvalidSyntaxException: `}' expected but `"' found at 1.32
    	at org.fusesource.scalate.scaml.ScamlParser.parse(ScamlParser.scala:375)
    	at org.fusesource.scalate.scaml.ScamlCodeGenerator.generate(ScamlCodeGenerator.scala:668)
    	at org.fusesource.scalate.TemplateEngine.compileAndLoad(TemplateEngine.scala:684)
    	at org.fusesource.scalate.TemplateEngine.compileAndLoadEntry(TemplateEngine.scala:637)
    	at org.fusesource.scalate.TemplateEngine.liftedTree1$1(TemplateEngine.scala:368)
    	at org.fusesource.scalate.TemplateEngine.load(TemplateEngine.scala:362)
    	at org.fusesource.scalate.TemplateEngine.load(TemplateEngine.scala:432)
    	at org.fusesource.scalate.RenderContext$$anonfun$render$1$$anonfun$apply$mcV$sp$1.apply(RenderContext.scala:367)
    	at org.fusesource.scalate.RenderContext$$anonfun$render$1$$anonfun$apply$mcV$sp$1.apply(RenderContext.scala:367)
    	at org.fusesource.scalate.RenderContext$class.withUri(RenderContext.scala:423)
    	at org.fusesource.scalate.DefaultRenderContext.withUri(DefaultRenderContext.scala:30)
    	at org.fusesource.scalate.RenderContext$$anonfun$render$1.apply(RenderContext.scala:366)
    	at org.fusesource.scalate.RenderContext$$anonfun$render$1.apply(RenderContext.scala:366)
    	at org.fusesource.scalate.RenderContext$class.withAttributes(RenderContext.scala:397)
    	at org.fusesource.scalate.DefaultRenderContext.withAttributes(DefaultRenderContext.scala:30)
    	at org.fusesource.scalate.RenderContext$class.render(RenderContext.scala:365)
    	at org.fusesource.scalate.DefaultRenderContext.render(DefaultRenderContext.scala:30)

    It looks like the use of the braces for expression evaluation is what causes the problem. The following will work fine:
    %element{:foo => "function(){}"}

    One workaround would be to introduce a variable within the page to store the string value I want, and then use that variable as the attribute's value.
  • Followers
     
    Ico-users ternary.expression 
     
    Attachments
    No attachments
    Associations
     
    No associations
    Activity
    Time Expenditure
    Loading