Can I apply Dart's string interpolation dynamically?

Viewed 4499

(from the Dart discussion mailing list by Tristan McNab)

I'm trying to build a server-side MVC framework and generating views based on templates and whatnot, and I was wondering if I could apply Dart's string interpolation dynamically. For example, this would be my view template:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>${ViewData["Title"]}</title>
    <link href="/Content/css/site.css" rel="stylesheet" />
  </head>
  <body>
    <h1>${ViewData["Title"]}</h1>
    <div id="container">
      <p>Hello world!</p>
    </div>
  </body>
</html>

And I'd like to apply the ViewData variable using:

static String applyViewData(String html, Map ViewData) {
    // apply interpolation here
}

Is this at all possible at the moment? My searching for the APIs indicates that it isn't.

2 Answers
Related