Create a version of the mustache lib with no dependency on mirrors
diff --git a/lib/mustache.dart b/lib/mustache_no_mirrors.dart
similarity index 97%
rename from lib/mustache.dart
rename to lib/mustache_no_mirrors.dart
index 2719414..6f8f314 100644
--- a/lib/mustache.dart
+++ b/lib/mustache_no_mirrors.dart
@@ -1,7 +1,7 @@
library mustache;
-@MirrorsUsed(metaTargets: const [mustache])
-import 'dart:mirrors';
+//@MirrorsUsed(metaTargets: const [mustache])
+//import 'dart:mirrors';
part 'src/char_reader.dart';
part 'src/scanner.dart';
diff --git a/lib/src/template.dart b/lib/src/template.dart
index 18b6a20..ff5f153 100644
--- a/lib/src/template.dart
+++ b/lib/src/template.dart
@@ -216,23 +216,23 @@
if (object is List && _integerTag.hasMatch(name))
return object[int.parse(name)];
- if (_lenient && !_validTag.hasMatch(name))
- return _noSuchProperty;
+ //if (_lenient && !_validTag.hasMatch(name))
+ return _noSuchProperty;
- var instance = reflect(object);
- var field = instance.type.instanceMembers[new Symbol(name)];
- if (field == null) return _noSuchProperty;
-
- var invocation = null;
- if ((field is VariableMirror) || ((field is MethodMirror) && (field.isGetter))) {
- invocation = instance.getField(field.simpleName);
- } else if ((field is MethodMirror) && (field.parameters.length == 0)) {
- invocation = instance.invoke(field.simpleName, []);
- }
- if (invocation == null) {
- return _noSuchProperty;
- }
- return invocation.reflectee;
+// var instance = reflect(object);
+// var field = instance.type.instanceMembers[new Symbol(name)];
+// if (field == null) return _noSuchProperty;
+//
+// var invocation = null;
+// if ((field is VariableMirror) || ((field is MethodMirror) && (field.isGetter))) {
+// invocation = instance.getField(field.simpleName);
+// } else if ((field is MethodMirror) && (field.parameters.length == 0)) {
+// invocation = instance.invoke(field.simpleName, []);
+// }
+// if (invocation == null) {
+// return _noSuchProperty;
+// }
+// return invocation.reflectee;
}
_renderVariable(node, {bool escape : true}) {
diff --git a/pubspec.yaml b/pubspec.yaml
index ba8bf70..8e38cea 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,7 +1,7 @@
-name: mustache
-version: 0.1.8
+name: mustache_no_mirrors
+version: 0.1.9
author: Greg Lowe <greg@vis.net.nz>
-description: Mustache template library
+description: Mustache template library (without the dart:mirrors dependency)
homepage: https://github.com/xxgreg/mustache
environment:
sdk: '>=1.0.0 <2.0.0'
diff --git a/test/mustache_spec_test.dart b/test/mustache_spec_test.dart
index 1b096d6..1cba590 100644
--- a/test/mustache_spec_test.dart
+++ b/test/mustache_spec_test.dart
@@ -1,6 +1,6 @@
import 'dart:async';
import 'dart:io';
-import 'package:mustache/mustache.dart' as mustache;
+import 'package:mustache_no_mirrors/mustache_no_mirrors.dart' as mustache;
import 'dart:convert';
var verbose = false;
diff --git a/test/mustache_test.dart b/test/mustache_test.dart
index fc7aa0e..ef49d92 100644
--- a/test/mustache_test.dart
+++ b/test/mustache_test.dart
@@ -1,7 +1,7 @@
library mustache_test;
import 'package:unittest/unittest.dart';
-import 'package:mustache/mustache.dart';
+import 'package:mustache_no_mirrors/mustache_no_mirrors.dart';
const MISMATCHED_TAG = 'Mismatched tag';
const UNEXPECTED_EOF = 'Unexpected end of input';
@@ -364,19 +364,19 @@
});
});
- group('Mirrors', () {
- test('Simple field', () {
- var output = parse('_{{bar}}_')
- .renderString(new Foo()..bar = 'bob');
- expect(output, equals('_bob_'));
- });
-
- test('Lambda', () {
- var output = parse('_{{lambda}}_')
- .renderString(new Foo()..lambda = (_) => 'yo');
- expect(output, equals('_yo_'));
- });
- });
+// group('Mirrors', () {
+// test('Simple field', () {
+// var output = parse('_{{bar}}_')
+// .renderString(new Foo()..bar = 'bob');
+// expect(output, equals('_bob_'));
+// });
+//
+// test('Lambda', () {
+// var output = parse('_{{lambda}}_')
+// .renderString(new Foo()..lambda = (_) => 'yo');
+// expect(output, equals('_yo_'));
+// });
+// });
}
renderFail(source, values) {