From cb136b102855cc2f843587f458f5de3020481f63 Mon Sep 17 00:00:00 2001 From: Jay Traband Date: Fri, 11 Sep 2015 00:19:23 -0700 Subject: [PATCH] reorg util-fns.jade --- public/_includes/_util-fns.jade | 51 ++++++++++++++++----------------- 1 file changed, 24 insertions(+), 27 deletions(-) diff --git a/public/_includes/_util-fns.jade b/public/_includes/_util-fns.jade index e2ba55cb44..5e7afc0830 100644 --- a/public/_includes/_util-fns.jade +++ b/public/_includes/_util-fns.jade @@ -1,6 +1,30 @@ +//- Mixins and associated functions +mixin makeExample(path, fileName, title, stylePatterns) + - var language = attributes.language || getExtn(fileName); + - var format = attributes.format || "linenums"; + - var extPath = getPathToFrags() + path + "/"; + if (title) + .example-title #{title} + code-example(language="#{language}" format="#{format}") + != getFrag(extPath + fileName + ".md", stylePatterns) + +mixin makeTabs(path, fileNames, tabNames, stylePatterns) + - fileNames = fileNames.split(","); + - tabNames = tabNames.split(",") + + code-tabs + each fileName,index in fileNames + - var tabName = tabNames[index].trim(); + - var fileName = fileNames[index].trim(); + - var language = attributes.language || getExtn(fileName); + - var format = attributes.format || "linenums"; + - var extPath = getPathToFrags() + path + "/"; + - var sps = Array.isArray(stylePatterns) ? stylePatterns[index] : stylePatterns; + code-pane(language="#{language}" name="#{tabName}" format="#{format}") + != getFrag(extPath + fileName + ".md", sps) - var getFrag = function(fileName, stylePatterns) { - var frag = partial(fileName); @@ -55,30 +79,3 @@ - // we will almost certainly never go 10 or 11 deep but ... - return current.pathToFrags || "../../../../../../../../../../../".substr(0, (currentPath.length-2)*3) + "_fragments/"; - } - -mixin makeExample(path, fileName, title, stylePatterns) - - - var language = attributes.language || getExtn(fileName); - - var format = attributes.format || "linenums"; - - var extPath = getPathToFrags() + path + "/"; - - if (title) - .example-title #{title} - code-example(language="#{language}" format="#{format}") - != getFrag(extPath + fileName + ".md", stylePatterns) - -mixin makeTabs(path, fileNames, tabNames, stylePatterns) - - 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 language = attributes.language || getExtn(fileName); - - var format = attributes.format || "linenums"; - - var extPath = getPathToFrags() + path + "/"; - - var sps = Array.isArray(stylePatterns) ? stylePatterns[index] : stylePatterns; - code-pane(language="#{language}" name="#{tabName}" format="#{format}") - != getFrag(extPath + fileName + ".md", sps)