interpolation 0.2.1 copy "interpolation: ^0.2.1" to clipboard
interpolation: ^0.2.1 copied to clipboard

outdated

A Dart package to handle dynamic String & Json interpolation.

example/interpolation_example.dart

import 'package:interpolation/interpolation.dart';

void main() {
  var interpolation = Interpolation();
  var str = "Hi, my name is '{name}'. I'm {age}.";

  print(interpolation.eval(str, {'name': 'David', 'age': 18}));
  // output: Hi, my name is 'David'. I'm 18.

  var obj = {
    'a': 'a',
    'b': 10,
    'c': {
      'd': 'd',
      'e': 'Hello {c.d}',
      'f': 'Hi "{a}", am I deep enough, or need to show "{c.e}" with {b}'
    }
  };

  print(interpolation.resolve(obj));
  // output: {a: a, b: 10, c: {d: d, e: Hello d, f: Hi "a", am I deep enough, or need to show "Hello d" with 10}}
  print(obj);
  // original object is not changed
  // output: {a: a, b: 10, c: {d: d, e: Hello {c.d}, f: Hi "{a}", am I deep enough, or need to show "{c.e}" with {b}}}
}
9
likes
0
pub points
83%
popularity

Publisher

verified publishermarganam.com

A Dart package to handle dynamic String & Json interpolation.

Repository (GitHub)
View/report issues

License

unknown (license)

More

Packages that depend on interpolation