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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/site/articles/style-guide/index.markdown
diff --git a/src/site/articles/style-guide/index.markdown b/src/site/articles/style-guide/index.markdown
index 49c39db8a56ed51c56d98002048dfff2a7612d9c..43dc5a0c2fffb9f2220bc060b69cfc40b83f1d48 100644
--- a/src/site/articles/style-guide/index.markdown
+++ b/src/site/articles/style-guide/index.markdown
@@ -7,7 +7,7 @@ description: "Follow these guidelines for consistent, readable Dart code."
has-permalinks: true
article:
written_on: 2011-10-27
- updated_on: 2014-10-27
+ updated_on: 2015-02-17
collection: everyday-dart
---
@@ -18,7 +18,7 @@ article:
<em>Written by Bob Nystrom<br />
<time pubdate date="2011-10-27">October 2011</time>
-(updated October 2014)
+(updated February 2015)
</em>
@@ -1503,3 +1503,27 @@ var fooList = [1, 2,
3, 4];
{% endprettify %}
</div>
+
+
+## Strings
+
+#### AVOID using curly braces in interpolation when not needed.
+{:.no_toc}
+
+If you're just interpolating a simple identifier that's not immediately
+followed by more alphanumeric text, the `{}` can and should be omitted.
+
+<div class="good">
+{% prettify dart %}
+'Hi, $name!'
+"Wear your wildest $decade's outfit."
+'Wear your wildest ${decade}s outfit.'
+{% endprettify %}
+</div>
+
+<div class="bad">
+{% prettify dart %}
+'Hi, ${name}!'
+"Wear your wildest ${decade}'s outfit."
+{% endprettify %}
+</div>
« 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