Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

Commit b93fb12

Browse files
brandonrobertswardbell
authored andcommitted
chore(examples): Updated live example links to use helper directive
closes #2005
1 parent 531d6a8 commit b93fb12

22 files changed

+40
-37
lines changed

public/docs/js/latest/cookbook/ts-to-js.jade

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ include ../../../../_includes/_util-fns
2626

2727
[Host and Query Metadata](#other-property-metadata)
2828

29-
**Run and compare the live [TypeScript](/resources/live-examples/cb-ts-to-js/ts/plnkr.html) and
30-
[JavaScript](/resources/live-examples/cb-ts-to-js/js/plnkr.html) code shown in this cookbook.**
29+
**Run and compare the live <live-example name="cb-ts-to-js">TypeScript</live-example> and <live-example name="cb-ts-to-js" lang="js">JavaScript</live-example>
30+
code shown in this cookbook.**
3131

3232
a(id="modularity")
3333
.l-main-section

public/docs/js/latest/guide/forms-deprecated.jade

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ include ../_util-fns
3535

3636
- How to share information across controls with template local variables
3737

38-
[Live Example](/resources/live-examples/forms-deprecated/js/plnkr.html)
38+
<live-example>Live Example</live-example>
39+
3940
.l-main-section
4041
:marked
4142
## Template-Driven Forms

public/docs/js/latest/guide/forms.jade

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ include ../_util-fns
3535

3636
- How to share information across controls with template local variables
3737

38-
[Live Example](/resources/live-examples/forms/js/plnkr.html)
38+
<live-example>Live Example</live-example>
3939

4040
.l-main-section
4141
:marked

public/docs/js/latest/quickstart.jade

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ include _util-fns
1313
:marked
1414
## See It Run!
1515

16-
Running the [live example](/resources/live-examples/quickstart/js/plnkr.html)
16+
Running the <live-example></live-example>
1717
is the quickest way to see an Angular 2 app come to life.
1818

1919
Clicking that link fires up a browser, loads the sample in [plunker](http://plnkr.co/ "Plunker"),

public/docs/ts/latest/cookbook/a1-a2-quick-reference.jade

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ a(id="top")
66
syntax and its equivalent in Angular&nbsp;2.
77

88
:marked
9-
**See the Angular 2 syntax in this [live example](/resources/live-examples/cb-a1-a2-quick-reference/ts/plnkr.html)**.
9+
**See the Angular 2 syntax in this <live-example name="cb-a1-a2-quick-reference"></live-example>**.
1010

1111
## Contents
1212
This chapter covers

public/docs/ts/latest/cookbook/component-communication.jade

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ include ../_util-fns
3030
[Parent and children communicate via a service](#bidirectional-service)
3131

3232
:marked
33-
**See the [live example](/resources/live-examples/cb-component-communication/ts/plnkr.html)**.
33+
**See the <live-example name="cb-component-communication"></live-example>**.
3434

3535
.l-main-section
3636
<a id="parent-to-child"></a>

public/docs/ts/latest/cookbook/component-relative-paths.jade

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ include ../_util-fns
7575
:marked
7676
## Source
7777

78-
**We can see the [live example](/resources/live-examples/cb-component-relative-paths/ts/plnkr.html)**
78+
**We can see the <live-example name="cb-component-relative-paths"></live-example>**
7979
and download the source code from there
8080
or simply read the pertinent source here.
8181
+makeTabs(

public/docs/ts/latest/cookbook/dependency-injection.jade

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ include ../_util-fns
4545
[Break circularities with a forward class reference (*forwardRef*)](#forwardref)
4646

4747
:marked
48-
**See the [live example](/resources/live-examples/cb-dependency-injection/ts/plnkr.html)**
48+
**See the <live-example name="cb-dependency-injection"></live-example>**
4949
of the code supporting this cookbook.
5050

5151
.l-main-section
@@ -236,7 +236,7 @@ figure.image-display
236236
The getter for the `hero` property pulls the cached hero from the service.
237237
And the template displays this data-bound property.
238238

239-
Find this example in [live code](/resources/live-examples/cb-dependency-injection/ts/plnkr.html)
239+
Find this example in <live-example name="cb-dependency-injection">live code</live-example>
240240
and confirm that the three `HeroBioComponent` instances have their own cached hero data.
241241
figure.image-display
242242
img(src="/resources/images/cookbooks/dependency-injection/hero-bios.png" alt="Bios")
@@ -535,7 +535,7 @@ a(id='usefactory')
535535
:marked
536536
The function retrieves candidate heroes from the `HeroService`,
537537
takes `2` of them to be the runners-up, and returns their concatenated names.
538-
Look at the [live example](/resources/live-examples/cb-dependency-injection/ts/plnkr.html)
538+
Look at the <live-example name="cb-dependency-injection"></live-example>
539539
for the full source code.
540540

541541
a(id="tokens")
@@ -703,7 +703,7 @@ a(id='alex')
703703
+makeExample('cb-dependency-injection/ts/app/parent-finder.component.ts','cathy','parent-finder.component.ts (CathyComponent)')(format='.')
704704
:marked
705705
We added the [@Optional](#optional) qualifier for safety but
706-
the [live example](/resources/live-examples/cb-dependency-injection/ts/plnkr.html)
706+
the <live-example name="cb-dependency-injection"></live-example>
707707
confirms that the `alex` parameter is set.
708708

709709
<a id="base-parent"></a>
@@ -737,7 +737,7 @@ a(id='alex')
737737
+makeExample('cb-dependency-injection/ts/app/parent-finder.component.ts','craig','parent-finder.component.ts (CraigComponent)')(format='.')
738738
:marked
739739
Unfortunately, this does not work.
740-
The [live example](/resources/live-examples/cb-dependency-injection/ts/plnkr.html)
740+
The <live-example name="cb-dependency-injection"></live-example>
741741
confirms that the `alex` parameter is null.
742742
*We cannot inject a parent by its base class.*
743743

public/docs/ts/latest/cookbook/dynamic-form-deprecated.jade

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ include ../_util-fns
3535
[Dynamic Template](#dynamic-template)
3636

3737
:marked
38-
**See the [live example](/resources/live-examples/cb-dynamic-form-deprecated/ts/plnkr.html)**.
38+
**See the <live-example name="cb-dynamic-form-deprecated"></live-example>**.
3939

4040
.l-main-section
4141
<a id="object-model"></a>

public/docs/ts/latest/cookbook/dynamic-form.jade

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ include ../_util-fns
3737
[Dynamic Template](#dynamic-template)
3838

3939
:marked
40-
**See the [live example](/resources/live-examples/cb-dynamic-form/ts/plnkr.html)**.
40+
**See the <live-example name="cb-dynamic-form"></live-example>**.
4141

4242
.l-main-section
4343
<a id="bootstrap"></a>

public/docs/ts/latest/cookbook/set-document-title.jade

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ a(id='top')
55
Our app should be able to make the browser title bar say whatever we want it to say.
66
This cookbook explains how to do it.
77
:marked
8-
**See the [live example](/resources/live-examples/cb-set-document-title/ts/plnkr.html)**.
8+
**See the <live-example name="cb-set-document-title"></live-example>**.
99
.l-sub-section
1010
img(src='/resources/images/devguide/plunker-separate-window-button.png' alt="pop out the window" align="right" style="margin-right:-20px")
1111
:marked

public/docs/ts/latest/guide/animations.jade

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ include ../_util-fns
3737

3838
.l-sub-section
3939
:marked
40-
The examples referenced in this chapter are available as a [live example](/resources/live-examples/animations/ts/plnkr.html).
40+
The examples referenced in this chapter are available as a <live-example></live-example>.
4141

4242
a(id="example-transitioning-between-states")
4343
.l-main-section

public/docs/ts/latest/guide/forms-deprecated.jade

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ include ../_util-fns
3535

3636
- sharing information among controls with template reference variables
3737

38-
[Live Example](/resources/live-examples/forms-deprecated/ts/plnkr.html)
38+
<live-example>Live Example</live-example>
3939
.l-main-section
4040
:marked
4141
## Template-Driven Forms

public/docs/ts/latest/guide/forms.jade

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ include ../_util-fns
3737

3838
- sharing information among controls with template reference variables
3939

40-
[Live Example](/resources/live-examples/forms/ts/plnkr.html)
40+
<live-example>Live Example</live-example>
4141

4242
.l-main-section
4343
:marked

public/docs/ts/latest/guide/index.jade

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ table(width="100%")
100100
block example-links
101101
:marked
102102
Look for a link to a running version of that sample near the top of each page,
103-
such as this [live example](/resources/live-examples/architecture/ts/plnkr.html) from the [Architecture](architecture.html) chapter.
103+
such as this <live-example></live-example> from the [Architecture](architecture.html) chapter.
104104

105105
The link launches a browser-based code editor where we can inspect, modify, save, and download the code.
106106

public/docs/ts/latest/guide/router-deprecated.jade

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ include ../_util-fns
1010
as users perform application tasks.
1111

1212
We cover the router's primary features in this chapter, illustrating them through the evolution
13-
of a small application that we can [run live](/resources/live-examples/router-deprecated/ts/plnkr.html).
13+
of a small application that we can <live-example>run live</live-example>.
1414
.l-sub-section
1515
img(src='/resources/images/devguide/plunker-separate-window-button.png' alt="pop out the window" align="right" style="margin-right:-20px")
1616
:marked
@@ -207,7 +207,7 @@ table
207207
We discuss code and design decisions pertinent to routing and application design.
208208
We gloss over everything in between.
209209

210-
The full source is available in the [live example](/resources/live-examples/router-deprecated/ts/plnkr.html).
210+
The full source is available in the <live-example></live-example>
211211
:marked
212212
Our client is the Hero Employment Agency.
213213
Heroes need work and The Agency finds Crises for them to solve.
@@ -216,7 +216,7 @@ table
216216
1. A *Crisis Center* where we maintain the list of crises for assignment to heroes.
217217
1. A *Heroes* area where we maintain the list of heroes employed by The Agency.
218218

219-
Run the [live example](/resources/live-examples/router-deprecated/ts/plnkr.html).
219+
Run the <live-example></live-example>.
220220
It opens in the *Crisis Center*. We'll come back to that.
221221

222222
Click the *Heroes* link. We're presented with a list of Heroes.
@@ -1110,7 +1110,7 @@ code-example(format="." language="bash").
11101110

11111111
.l-sub-section
11121112
:marked
1113-
The [live example](/resources/live-examples/router-deprecated/ts/plnkr.html) *does* highlight the selected
1113+
The <live-example></live-example> *does* highlight the selected
11141114
row because it demonstrates the final state of the application which includes the steps we're *about* to cover.
11151115
At the moment we're describing the state of affairs *prior* to those steps.
11161116
:marked
@@ -1202,7 +1202,7 @@ code-example(format="." language="bash").
12021202
As we end our chapter, we take a parting look at
12031203
the entire application.
12041204

1205-
We can always try the [live example](/resources/live-examples/router-deprecated/ts/plnkr.html) and download the source code from there.
1205+
We can always try the <live-example></live-example> and download the source code from there.
12061206

12071207
Our final project folder structure looks like this:
12081208
.filetree

public/docs/ts/latest/guide/router.jade

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ include ../_util-fns
1010
as users perform application tasks.
1111

1212
We cover the router's primary features in this chapter, illustrating them through the evolution
13-
of a small application that we can [run live](/resources/live-examples/router/ts/plnkr.html).
13+
of a small application that we can <live-example>run live</live-example>.
1414
.l-sub-section
1515
img(src='/resources/images/devguide/plunker-separate-window-button.png' alt="pop out the window" align="right" style="margin-right:-20px")
1616
:marked
@@ -250,7 +250,7 @@ table
250250
We discuss code and design decisions pertinent to routing and application design.
251251
We gloss over everything in between.
252252

253-
The full source is available in the [live example](/resources/live-examples/router/ts/plnkr.html).
253+
The full source is available in the <live-example></live-example>.
254254
:marked
255255
Our client is the Hero Employment Agency.
256256
Heroes need work and The Agency finds Crises for them to solve.
@@ -259,7 +259,7 @@ table
259259
1. A *Crisis Center* where we maintain the list of crises for assignment to heroes.
260260
1. A *Heroes* area where we maintain the list of heroes employed by The Agency.
261261

262-
Run the [live example](/resources/live-examples/router/ts/plnkr.html).
262+
Run the <live-example></live-example>.
263263
It opens in the *Crisis Center*. We'll come back to that.
264264

265265
Click the *Heroes* link. We're presented with a list of Heroes.
@@ -1442,7 +1442,7 @@ code-example(format="." language="bash").
14421442

14431443
.l-sub-section
14441444
:marked
1445-
The [live example](/resources/live-examples/router/ts/plnkr.html) *does* highlight the selected
1445+
The <live-example></live-example> *does* highlight the selected
14461446
row because it demonstrates the final state of the application which includes the steps we're *about* to cover.
14471447
At the moment we're describing the state of affairs *prior* to those steps.
14481448
:marked
@@ -1529,7 +1529,7 @@ figure.image-display
15291529
:marked
15301530
## Wrap Up
15311531
We've covered a lot of ground in this chapter and the application is too big to reprint here.
1532-
Please visit the [live example](/resources/live-examples/router/ts/plnkr.html) and
1532+
Please visit the <live-example></live-example> and
15331533
where you can download the final source code.
15341534

15351535
.l-main-section

public/docs/ts/latest/guide/user-input.jade

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ include ../_util-fns
66
In this chapter we learn to bind to those events using the Angular
77
event binding syntax.
88

9-
[Run the live example](/resources/live-examples/user-input/ts/plnkr.html)
9+
<live-example>Run the live example</live-example>
1010

1111
:marked
1212
## Binding to user input events

public/resources/js/directives/if-docs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ angularIO.directive('ifDocs', ['ngIfDirective', '$location', function (ngIfDirec
1717
terminal: ngIf.terminal,
1818
restrict: ngIf.restrict,
1919
link: function (scope, element, attrs) {
20-
var ngIfCond = (attrs.ifDocs === 'dart') == !NgIoUtil.isDartDoc($location);
20+
var ngIfCond = (attrs.ifDocs === 'dart') == !NgIoUtil.isDoc($location, 'dart');
2121
attrs.ngIf = function () { return !ngIfCond; }
2222
ngIf.link.apply(ngIf, arguments);
2323
}

public/resources/js/directives/live-example.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,12 @@ angularIO.directive('liveExample', ['$location', function ($location) {
2828
var ex = attrs.name || NgIoUtil.getExampleName($location);
2929
var href, template;
3030

31-
var isForDart = attrs.lang === 'dart' || NgIoUtil.isDartDoc($location);
31+
var isForDart = attrs.lang === 'dart' || NgIoUtil.isDoc($location, 'dart');
32+
var isForJs = attrs.lang === 'js' || NgIoUtil.isDoc($location, 'js');
33+
var exLang = isForDart ? 'dart' : isForJs ? 'js' : 'ts';
3234
var href = isForDart
3335
? 'http://angular-examples.github.io/' + ex
34-
: '/resources/live-examples/' + ex + '/ts/plnkr.html';
36+
: '/resources/live-examples/' + ex + '/' + exLang + '/plnkr.html';
3537

3638
// Link to live example.
3739
var template = a(text, { href: href, target: '_blank' });

public/resources/js/directives/ngio-ex-path.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ angularIO.directive('ngioEx', ['$location', function ($location) {
2323

2424
compile: function (tElement, attrs) {
2525
var examplePath = attrs.path || tElement.text();
26-
if (NgIoUtil.isDartDoc($location) || attrs.lang === 'dart') {
26+
if (NgIoUtil.isDoc($location, 'dart') || attrs.lang === 'dart') {
2727
examplePath = NgIoUtil.adjustTsExamplePathForDart(examplePath);
2828
}
2929
var template = '<code>' + examplePath + '</code>';

public/resources/js/util.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ var NgIoUtil = (function () {
44

55
function NgIoUtil() { }
66

7-
NgIoUtil.isDartDoc = function ($location) {
7+
NgIoUtil.isDoc = function ($location, lang) {
88
var loc = $location.absUrl();
9-
return loc.includes('/docs/dart/');
9+
return loc.includes('/docs/' + lang + '/');
1010
};
1111

1212
// The following util functions are adapted from _utils-fn.jade.

0 commit comments

Comments
 (0)