OLD | NEW |
(Empty) | |
| 1 library mustache; |
| 2 |
| 3 import 'dart:mirrors'; |
| 4 |
| 5 part 'char_reader.dart'; |
| 6 part 'scanner.dart'; |
| 7 part 'template.dart'; |
| 8 |
| 9 /// [Mustache template documentation](http://mustache.github.com/mustache.5.html
) |
| 10 |
| 11 /// Returns a [Template] which can be used to render the mustache template |
| 12 /// with substituted values. |
| 13 /// Tag names may only contain characters a-z, A-Z, 0-9, underscore, and minus, |
| 14 /// unless lenient mode is specified. |
| 15 /// Throws [FormatException] if the syntax of the source is invalid. |
| 16 Template parse(String source, |
| 17 {bool lenient : false}) => _parse(source, lenient: lenient)
; |
| 18 |
| 19 /// A Template can be rendered multiple times with different values. |
| 20 abstract class Template { |
| 21 /// [values] can be a combination of Map, List, String. Any non-String o
bject |
| 22 /// will be converted using toString(). Null values will cause a |
| 23 /// FormatException, unless lenient module is enabled. |
| 24 String renderString(values, {bool lenient : false, bool htmlEscapeValues
: true}); |
| 25 |
| 26 /// [values] can be a combination of Map, List, String. Any non-String o
bject |
| 27 /// will be converted using toString(). Null values will cause a |
| 28 /// FormatException, unless lenient module is enabled. |
| 29 void render(values, StringSink sink, {bool lenient : false, bool htmlEsc
apeValues : true}); |
| 30 } |
| 31 |
| 32 /// MustacheFormatException is used to obtain the line and column numbers |
| 33 /// of the token which caused parse or render to fail. |
| 34 class MustacheFormatException implements FormatException { |
| 35 final String message; |
| 36 |
| 37 /// The 1-based line number of the token where formatting error was foun
d. |
| 38 final int line; |
| 39 |
| 40 /// The 1-based column number of the token where formatting error was fo
und. |
| 41 final int column; |
| 42 |
| 43 MustacheFormatException(this.message, this.line, this.column); |
| 44 String toString() => message; |
| 45 } |
OLD | NEW |