angular-cn/public/docs/dart/latest/_util-fns.jade

33 lines
1.3 KiB
Plaintext
Raw Normal View History

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;
- }