OLD | NEW |
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 import 'dart:convert'; | 5 import 'dart:convert'; |
6 import 'dart:io'; | 6 import 'dart:io'; |
7 | 7 |
8 import 'package:intl/intl.dart'; | 8 import 'package:intl/intl.dart'; |
9 | 9 |
10 /// Contains a collection of Pages. | 10 /// Contains a collection of Pages. |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 void p(String text, {String style, bool raw: false, String classes}) { | 142 void p(String text, {String style, bool raw: false, String classes}) { |
143 String c = classes == null ? '' : ' class="$classes"'; | 143 String c = classes == null ? '' : ' class="$classes"'; |
144 | 144 |
145 if (style != null) { | 145 if (style != null) { |
146 buf.writeln('<p$c style="$style">${raw ? text : escape(text)}</p>'); | 146 buf.writeln('<p$c style="$style">${raw ? text : escape(text)}</p>'); |
147 } else { | 147 } else { |
148 buf.writeln('<p$c>${raw ? text : escape(text)}</p>'); | 148 buf.writeln('<p$c>${raw ? text : escape(text)}</p>'); |
149 } | 149 } |
150 } | 150 } |
151 | 151 |
| 152 void pre(void gen(), {String classes}) { |
| 153 if (classes != null) { |
| 154 buf.write('<pre class="$classes">'); |
| 155 } else { |
| 156 buf.write('<pre>'); |
| 157 } |
| 158 gen(); |
| 159 buf.writeln('</pre>'); |
| 160 } |
| 161 |
152 void blankslate(String str) { | 162 void blankslate(String str) { |
153 div(() => buf.writeln(str), classes: 'blankslate'); | 163 div(() => buf.writeln(str), classes: 'blankslate'); |
154 } | 164 } |
155 | 165 |
156 bool isCurrentPage(String pathToTest) => path == pathToTest; | 166 bool isCurrentPage(String pathToTest) => path == pathToTest; |
157 } | 167 } |
158 | 168 |
159 String escape(String text) => text == null ? '' : HTML_ESCAPE.convert(text); | 169 String escape(String text) => text == null ? '' : HTML_ESCAPE.convert(text); |
160 | 170 |
161 final NumberFormat numberFormat = new NumberFormat.decimalPattern(); | 171 final NumberFormat numberFormat = new NumberFormat.decimalPattern(); |
162 | 172 |
163 String printInteger(int value) => numberFormat.format(value); | 173 String printInteger(int value) => numberFormat.format(value); |
164 | 174 |
165 String printMilliseconds(num value) => '${numberFormat.format(value)} ms'; | 175 String printMilliseconds(num value) => '${numberFormat.format(value)} ms'; |
166 | 176 |
167 String printPercentage(num value) => '${(value * 100).toStringAsFixed(1)}%'; | 177 String printPercentage(num value) => '${(value * 100).toStringAsFixed(1)}%'; |
OLD | NEW |