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

Side by Side Diff: src/site/articles/style-guide/index.markdown

Issue 913733003: Add guideline for {} in interpolation (Closed) Base URL: https://github.com/dart-lang/www.dartlang.org.git@master
Patch Set: Move the guidelines to a new Strings section Created 5 years, 10 months 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 --- 1 ---
2 layout: article 2 layout: article
3 title: "Dart Style Guide" 3 title: "Dart Style Guide"
4 rel: 4 rel:
5 author: bob-nystrom 5 author: bob-nystrom
6 description: "Follow these guidelines for consistent, readable Dart code." 6 description: "Follow these guidelines for consistent, readable Dart code."
7 has-permalinks: true 7 has-permalinks: true
8 article: 8 article:
9 written_on: 2011-10-27 9 written_on: 2011-10-27
10 updated_on: 2014-10-27 10 updated_on: 2015-02-17
11 collection: everyday-dart 11 collection: everyday-dart
12 --- 12 ---
13 13
14 {% include toc.html %} 14 {% include toc.html %}
15 {% include breadcrumbs.html %} 15 {% include breadcrumbs.html %}
16 16
17 # {{ page.title }} 17 # {{ page.title }}
18 18
19 <em>Written by Bob Nystrom<br /> 19 <em>Written by Bob Nystrom<br />
20 <time pubdate date="2011-10-27">October 2011</time> 20 <time pubdate date="2011-10-27">October 2011</time>
21 (updated October 2014) 21 (updated February 2015)
22 </em> 22 </em>
23 23
24 24
25 As we build up an ecosystem of Dart code, it's helpful if it follows a 25 As we build up an ecosystem of Dart code, it's helpful if it follows a
26 consistent coding style. A dedicated style guide for Dart helps us make 26 consistent coding style. A dedicated style guide for Dart helps us make
27 the most of the features unique to the language and makes it easier for 27 the most of the features unique to the language and makes it easier for
28 users to collaborate. 28 users to collaborate.
29 29
30 There will likely be things you disagree with in this guide. As the author, 30 There will likely be things you disagree with in this guide. As the author,
31 there are things even I disagree with. I hope you'll agree that consistency is 31 there are things even I disagree with. I hope you'll agree that consistency is
(...skipping 1464 matching lines...) Expand 10 before | Expand all | Expand 10 after
1496 1496
1497 var fooList = [ 1497 var fooList = [
1498 1, 1498 1,
1499 2, 1499 2,
1500 3]; 1500 3];
1501 1501
1502 var fooList = [1, 2, 1502 var fooList = [1, 2,
1503 3, 4]; 1503 3, 4];
1504 {% endprettify %} 1504 {% endprettify %}
1505 </div> 1505 </div>
1506
1507
1508 ## Strings
1509
1510 #### AVOID using curly braces in interpolation when not needed.
1511 {:.no_toc}
1512
1513 If you're just interpolating a simple identifier that's not immediately
1514 followed by more alphanumeric text, the `{}` can and should be omitted.
1515
1516 <div class="good">
1517 {% prettify dart %}
1518 'Hi, $name!'
1519 "Wear your wildest $decade's outfit."
1520 'Wear your wildest ${decade}s outfit.'
1521 {% endprettify %}
1522 </div>
1523
1524 <div class="bad">
1525 {% prettify dart %}
1526 'Hi, ${name}!'
1527 "Wear your wildest ${decade}'s outfit."
1528 {% endprettify %}
1529 </div>
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698