How do I create a server-side template in Dart where I can set a different <title/> for each page?
Try out mustache, a Dart implementation of mustache templates, a widely used templating syntax, with implementations in a number of languages.
Here's an example:
import 'package:mustache/mustache.dart';
main() {
var source = '{{#names}}<div>{{lastname}}, {{firstname}}</div>{{/names}}';
var template = new Template(source);
var output = template.renderString({'names': [
{'firstname': 'Greg', 'lastname': 'Lowe'},
{'firstname': 'Bob', 'lastname': 'Johnson'}
]});
print(output);
}
The Dart team is currently focused on client side development, so many basic server-side features are missing in the core libraries. However take a look at pub, there are a number of community maintained packages available.
Also see this similar package: mustache4dart.