Patrice Chalin 1e64d9e57a docs(guide/dart): hierarchical-dependency-injection without copying
closes #1207
This uses a simpler way to render Dart prose from TS prose without
making a copy. This will make it _much_ easier to keep the two in sync.
2016-04-28 17:03:28 -07:00

33 lines
1.3 KiB
Plaintext

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})
- var adjustExamplePath = function(path) {
- var folder = getFolder(path);
- var extn = getExtn(path);
- // if(extn == 'dart') return path;
- var baseName = getBaseFileName(path);
- 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';
- return folder + '/' + baseNameNoExt + '.' + extn;
- };
- var adjustExampleTitle = function(title) {
- // Assume title is a path if it ends with an extension like '.foo'.
- if(title && title.match(/\.\w+$/) && adjustExamplePath) {
- var isAbsolutePath = title.match(/^\//);
- title = adjustExamplePath(title);
- if(!isAbsolutePath && title.match(/^\//)) title = title.substring(1);
- }
- return title;
- }