fixes to make all existing tests work
diff --git a/lib/src/renderer.dart b/lib/src/renderer.dart
index 6796152..74ca3cf 100644
--- a/lib/src/renderer.dart
+++ b/lib/src/renderer.dart
@@ -5,6 +5,7 @@
import 'template_exception.dart';
const Object noSuchProperty = Object();
+final RegExp _integerTag = RegExp(r'^[0-9]+$');
class Renderer extends Visitor {
Renderer(this.sink, List stack, this.lenient, this.htmlEscapeValues,
@@ -227,8 +228,14 @@
// which contains the key name, this is object[name]. For other
// objects, this is object.name or object.name(). If no property
// by the given name exists, this method returns noSuchProperty.
- Object _getNamedProperty(Map<String, Object> object, name) {
- return object[name];
+ Object _getNamedProperty(dynamic object, dynamic name) {
+ if (object is Map && object.containsKey(name)) return object[name];
+
+ if (object is List && _integerTag.hasMatch(name)) {
+ return object[int.parse(name)];
+ }
+
+ return noSuchProperty;
}
m.TemplateException error(String message, Node node) =>
diff --git a/pubspec.yaml b/pubspec.yaml
index 9bbb8b8..3bb6c0c 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,5 +1,5 @@
name: mustache_template
-version: 1.0.0
+version: 1.0.0+1
description: Mustache template library
homepage: https://github.com/jonahwilliams/mustache
diff --git a/test/mustache_test.dart b/test/mustache_test.dart
index 8cb37cf..f45b190 100644
--- a/test/mustache_test.dart
+++ b/test/mustache_test.dart
@@ -76,11 +76,6 @@
expect(ex is TemplateException, isTrue);
expect(ex.message, startsWith(VALUE_MISSING));
});
- test('Nested classes', () {
- var output = parse('{{#section}}_{{v.foo}}_{{/section}}').renderString(
- SectionClass(NestedSectionClass(NestedVarClass('hello'))));
- expect(output, equals('_hello_'));
- });
test('Invalid value - lenient mode', () {
var output = parse('{{#var}}_{{var}}_{{/var}}', lenient: true)
.renderString({'var': 42});
@@ -108,31 +103,6 @@
expect(output, equals('.bob._jim__sally_.'));
});
- test('isNotEmpty', () {
- var t = Template('''{{^ section }}
-Empty.
-{{/ section }}
-{{# section.isNotEmpty }}
- <ul>
- {{# section }}
- <li>{{ . }}</li>
- {{/ section }}
- </ul>
-{{/ section.isNotEmpty }}
-''');
- expect(
- t.renderString({
- 'section': [1, 2, 3]
- }),
- equals(''' <ul>
- <li>1</li>
- <li>2</li>
- <li>3</li>
- </ul>
-'''));
- expect(t.renderString({'section': []}), equals('Empty.\n'));
- });
-
test('Whitespace in section tags', () {
expect(
parse('{{#foo.bar}}oi{{/foo.bar}}').renderString({