diff --git a/third_party/packages/mustache_template/CHANGELOG.md b/third_party/packages/mustache_template/CHANGELOG.md index fd1da851da5..9159b7dc491 100644 --- a/third_party/packages/mustache_template/CHANGELOG.md +++ b/third_party/packages/mustache_template/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.0.2 + +* Emoji support. + ## 2.0.1 * Transfers the package source from https://github.com/jonahwilliams/mustache diff --git a/third_party/packages/mustache_template/lib/src/scanner.dart b/third_party/packages/mustache_template/lib/src/scanner.dart index b046c7897a2..7f889545cef 100644 --- a/third_party/packages/mustache_template/lib/src/scanner.dart +++ b/third_party/packages/mustache_template/lib/src/scanner.dart @@ -126,12 +126,12 @@ class Scanner { if (_c == _EOF) { return ''; } - final int start = _offset; + + final StringBuffer buffer = StringBuffer(); while (_peek() != _EOF && test(_peek())) { - _read(); + buffer.writeCharCode(_read()); } - final int end = _peek() == _EOF ? _source.length : _offset; - return _source.substring(start, end); + return buffer.toString(); } void _expect(int expectedCharCode) { diff --git a/third_party/packages/mustache_template/pubspec.yaml b/third_party/packages/mustache_template/pubspec.yaml index fd0de9f377d..9927217dd94 100644 --- a/third_party/packages/mustache_template/pubspec.yaml +++ b/third_party/packages/mustache_template/pubspec.yaml @@ -2,7 +2,7 @@ name: mustache_template description: A templating library that implements the Mustache template specification repository: https://github.com/flutter/packages/tree/main/third_party/packages/mustache_template issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+mustache_template%22 -version: 2.0.1 +version: 2.0.2 environment: sdk: ^3.7.0 diff --git a/third_party/packages/mustache_template/test/mustache_test.dart b/third_party/packages/mustache_template/test/mustache_test.dart index 086247bab56..ace3119fb0b 100644 --- a/third_party/packages/mustache_template/test/mustache_test.dart +++ b/third_party/packages/mustache_template/test/mustache_test.dart @@ -24,6 +24,12 @@ void main() { ).renderString({}); expect(output, equals('__')); }); + test('Emoji', () { + final String output = parse( + 'Hello! 🖖👍🏽\nBye! 🏳️‍🌈', + ).renderString({}); + expect(output, equals('Hello! 🖖👍🏽\nBye! 🏳️‍🌈')); + }); }); group('Section', () { test('Map', () { diff --git a/third_party/packages/mustache_template/test/parser_test.dart b/third_party/packages/mustache_template/test/parser_test.dart index 27ccadf96b6..7f849aab282 100644 --- a/third_party/packages/mustache_template/test/parser_test.dart +++ b/third_party/packages/mustache_template/test/parser_test.dart @@ -302,6 +302,14 @@ void main() { ]); }); + test('emoji', () { + const String source = 'Hello! 🖖👍🏽🏳️‍🌈\nEmoji'; + final Parser parser = Parser(source, 'foo', '{{ }}'); + final List nodes = parser.parse(); + // End offset includes emoji sizes + expectNodes(nodes, [TextNode('Hello! 🖖👍🏽🏳️‍🌈\nEmoji', 0, 20)]); + }); + test('toString', () { TextNode('foo', 1, 3).toString(); VariableNode('foo', 1, 3).toString();