Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(673)

Side by Side Diff: pkg/mustache/README.md

Issue 804973002: Add appengine/gcloud/mustache dependencies. (Closed) Base URL: git@github.com:dart-lang/pub-dartlang-dart.git@master
Patch Set: Added AUTHORS/LICENSE/PATENTS files Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pkg/mustache/LICENSE ('k') | pkg/mustache/check.sh » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Mustache templates
2
3 A Dart library to parse and render [mustache templates](http://mustache.github.c om/mustache.5.html).
4
5 [![Build Status](https://drone.io/github.com/xxgreg/mustache/status.png)](https: //drone.io/github.com/xxgreg/mustache/latest)
6
7 ## Example
8 ```dart
9 import 'package:mustache/mustache.dart' as mustache;
10
11 main() {
12 var source = '{{#names}}<div>{{lastname}}, {{firstname}}</div>{{ /names}}';
13 var template = mustache.parse(source);
14 var output = template.renderString({'names': [
15 {'firstname': 'Greg', 'lastname': 'Lowe'},
16 {'firstname': 'Bob', 'lastname': 'Johnson'}
17 ]});
18 print(output);
19 }
20 ```
21
22 ## API
23
24 ```dart
25
26 Template parse(String source, {bool lenient : false});
27
28 abstract class Template {
29 String renderString(values, {bool lenient : false, bool htmlEscapeValues : true});
30 void render(values, StringSink sink, {bool lenient : false, bool htmlEsc apeValues : true});
31 }
32
33 ```
34
35 Once a template has been created it can be rendered any number of times.
36
37 Both parse and render throw a FormatException if there is a problem with the tem plate or rendering the values.
38
39 When lenient mode is enabled tag names may use any characters, otherwise only a- z, A-Z, 0-9, underscore and minus. Lenient mode will also silently ignore nulls passed as values.
40
41 By default all variables are html escaped, this behaviour can be changed by pass ing htmlEscapeValues : false.
42
43
44 ## Supported
45 ```
46 Variables {{var-name}}
47 Sections {{#section}}Blah{{/section}}
48 Inverse sections {{^section}}Blah{{/section}}
49 Comments {{! Not output. }}
50 Unescaped variables {{{var-name}}} and {{&var-name}}
51 ```
52 See the [mustache templates tutorial](http://mustache.github.com/mustache.5.html ) for more information.
53
54 Passing all [mustache specification](https://github.com/mustache/spec/tree/maste r/specs) tests for interpolation, sections, inverted, comments. The following se ctions are not implemented: partials, lambdas and delimeters.
55
56 ## To do
57 ```
58 Lenient nulls in inverse sections - see commented out test.
59 Partial tags {{>partial}}
60 Allow functions as values (Lambdas)
61 Set Delimiter tags
62 ```
63
OLDNEW
« no previous file with comments | « pkg/mustache/LICENSE ('k') | pkg/mustache/check.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698