2016-04-28 13:54:28 -04:00
|
|
|
include ../../../_includes/_util-fns
|
|
|
|
|
|
|
|
mixin liveExLinks(name)
|
|
|
|
:marked
|
|
|
|
[Run the live example](https://angular-examples.github.io/#{name}) |
|
|
|
|
[View its source code](https://github.com/angular-examples/#{name})
|
|
|
|
|
2016-05-04 08:18:38 -04:00
|
|
|
- var adjustExamplePath = function(_path) {
|
|
|
|
- if(!_path) return _path;
|
|
|
|
- var path = _path.trim();
|
2016-04-28 13:54:28 -04:00
|
|
|
- var folder = getFolder(path);
|
|
|
|
- var extn = getExtn(path);
|
|
|
|
- // if(extn == 'dart') return path;
|
2016-05-04 08:18:38 -04:00
|
|
|
- var baseName = getBaseFileName(path) || path; // TODO: have getBaseFileName() return path
|
2016-04-28 13:54:28 -04:00
|
|
|
- var baseNameNoExt = baseName.substr(0,baseName.length - (extn.length + 1));
|
|
|
|
- var inWebFolder = baseNameNoExt.match(/^(main|index)$/);
|
|
|
|
- // Adjust the folder path, e.g., ts -> dart
|
|
|
|
- folder = folder.replace(/(^|\/)ts\//, '$1dart/').replace(/(^|\/)app$/, inWebFolder ? '$1web' : '$1lib');
|
|
|
|
- // In file name, replace special characters with underscore
|
|
|
|
- baseNameNoExt = baseNameNoExt.replace(/[\-\.]/g, '_');
|
|
|
|
- // Adjust the file extension
|
|
|
|
- if(extn == 'ts') extn = 'dart';
|
2016-05-04 08:18:38 -04:00
|
|
|
- return (folder ? folder + '/' : '') + baseNameNoExt + (extn ? '.' + extn : '');
|
2016-04-28 13:54:28 -04:00
|
|
|
- };
|
|
|
|
|
2016-05-04 08:18:38 -04:00
|
|
|
- var adjustExampleTitle = function(_title) {
|
|
|
|
- if(!_title || !adjustExamplePath) return _title;
|
|
|
|
- var title = _title.trim();
|
|
|
|
- // Assume title is a path if it ends with an extension like '.foo',
|
|
|
|
- // optionally followed by '(excerpt)' with or without parentheses.
|
|
|
|
- var matches = title.match(/(.*\.\w+)($|\s*\(?excerpt\)?$)/);
|
|
|
|
- if(matches && matches.length == 3) {
|
|
|
|
- // e.g. matches == ['abc.ts (excerpt)', 'abc.ts', ' (excerpt)']
|
|
|
|
- var path = adjustExamplePath(matches[1]);
|
|
|
|
- title = path + matches[2];
|
2016-04-28 13:54:28 -04:00
|
|
|
- }
|
|
|
|
- return title;
|
|
|
|
- }
|