angular-docs-cn/public/_includes/_util-fns.jade

36 lines
1.3 KiB
Plaintext
Raw Normal View History

- var getFrag = function(fileName) {
- var frag = partial(fileName);
- if (frag == null) {
- return "BAD FILENAME: " + fileName + " Current path: " + current.path;
- } else {
- // ``` gets translated to <pre><code>.....</code></pre> and we need
- // to remove this from the fragment prefix is 11 long and suffix is 13 long
- var r = frag.substring(11, frag.length-13);
- return r;
- }
- }
- var getExtn = function(fileName) {
- var ix = fileName.lastIndexOf('.');
- return ix > 0 ? fileName.substr(ix+1) : "";
- }
// HACK: to avoid having to include a path in makeTabs calls
- var currentPath = current.path;
// need to back up to 'docs'
- var pathToFrags = "../../../../../../../../../../../".substr(0, (currentPath.length-2)*3) + "_fragments/";
mixin makeTabs(path, fileNames, tabNames)
- fileNames = fileNames.split(",");
- tabNames = tabNames.split(",")
// .p Length #{currentPath.length}
code-tabs
each fileName,index in fileNames
- var tabName = tabNames[index].trim();
- var fileName = fileNames[index].trim();
- var extn = getExtn(fileName);
// - var extPath = pathToFrags + (path.length ? path + "/" : "");
- var extPath = pathToFrags + path + "/";
code-pane(language="#{extn}" name="#{tabName}" format="linenums")
!= getFrag(extPath + fileName + ".md")