Faris Nasution
Faris Nasution

Reputation: 3620

Dart questions on StringBuffer

After reading the source code of hart, there's this thing I don't understand. He's using StringBuffer to create a class, here's taken from the source :

var buff = new StringBuffer('''

class View {
  Map _views;

  render(String name, Map params) {
    return _views[name](params).get();
  }

  register(String name, handler(Map params)) {
    if (_views == null) {
      _views = {};
    }
    _views[name] = handler;
  }

  View() {
''');

Can we make a class using StringBuffer because I thought StringBuffer only used as a string manipulator ?

Upvotes: 0

Views: 144

Answers (1)

Greg Lowe
Greg Lowe

Reputation: 16291

From the hart package's readme:

Dart doesn't allow any code evaluation so you have to precompile all your templates.

So looks like hart generates dart source, which can then be fed into the dart compiler.

Upvotes: 2

Related Questions