Mustache with non well-formed xml templates

212 views
Skip to first unread message

goo...@jamesmaggs.com

unread,
Oct 7, 2013, 11:39:26 AM10/7/13
to sca...@googlegroups.com
Hi,

I'm developing an application with Scalate using mustache templates and have run into a problem. I am wrapping a sample.mustache template with a mylayout.mustache just like the example documentation but my sample.mustache contains html5 markup that is not well formed xml. This leads to SAXParseExceptions being thrown. I've traced this back to the localVariable method on MarkupAttributeContextScope which seems to assume that the inner template can be parsed as xml.

Is this a restriction, that all inner templates must be well formed xml? Or should a different implementation of Scope.localVariable be used somehow?

I'm embedding scalate into my own application and applying the layout using my own LayoutStrategy implementation:

object MyLayoutStrategy extends LayoutStrategy {
  def layout(template: Template, context: RenderContext) {
    val source = engine.source("/template/mylayout.mustache", "mustache")
    context.attributes("scalateLayouts") = source.uri :: context.attributeOrElse[List[String]]("scalateLayouts", List())
    context.attributes("body") = context.capture(template)
    engine.load(source).render(context)
  }
}

Maybe this is causing the problem?

If anyone could provide some advice on this, it would be much appreciated.

Thanks,

-James

Reply all
Reply to author
Forward
0 new messages