author
int64
658
755k
date
stringlengths
19
19
timezone
int64
-46,800
43.2k
hash
stringlengths
40
40
message
stringlengths
5
490
mods
list
language
stringclasses
20 values
license
stringclasses
3 values
repo
stringlengths
5
68
original_message
stringlengths
12
491
699
24.09.2018 21:57:52
18,000
ca2ab6fa5dc177bf483747af62dadf93290508c4
Unnecessary var
[ { "change_type": "MODIFY", "old_path": "cmd.js", "new_path": "cmd.js", "diff": "@@ -10,7 +10,7 @@ require(\"please-upgrade-node\")(pkg, {\n});\nif (process.env.DEBUG) {\n- let timeRequire = require(\"time-require\");\n+ require(\"time-require\");\n}\nconst EleventyErrorHandler = require(\"./src/EleventyErrorHandler\");\n" } ]
JavaScript
MIT License
11ty/eleventy
Unnecessary var
699
24.09.2018 22:03:54
18,000
9bc0efbaf4eb422794409f8345c826d26169879d
Fixes normalizes front matter tags to always be an array when fetched. Maintains backwards compatibility.
[ { "change_type": "MODIFY", "old_path": "src/TemplateCollection.js", "new_path": "src/TemplateCollection.js", "diff": "@@ -58,6 +58,7 @@ class TemplateCollection extends Sortable {\nmatch = true;\n}\n});\n+ // This branch should no longer be necessary per TemplateContent.cleanupFrontMatterData\n} else if (typeof item.data.tags === \"string\") {\nmatch = item.data.tags === tagName;\n}\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateContent.js", "new_path": "src/TemplateContent.js", "diff": "@@ -58,12 +58,19 @@ class TemplateContent {\nreturn this.frontMatter.content;\n}\n+ cleanupFrontMatterData(data) {\n+ if (\"tags\" in data && typeof data.tags === \"string\") {\n+ data.tags = [data.tags];\n+ }\n+ return data;\n+ }\n+\nasync getFrontMatterData() {\nif (!this.frontMatter) {\nawait this.read();\n}\n- return this.frontMatter.data || {};\n+ return this.cleanupFrontMatterData(this.frontMatter.data || {});\n}\nasync getEngineOverride() {\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateMap.js", "new_path": "src/TemplateMap.js", "diff": "@@ -134,6 +134,7 @@ class TemplateMap {\nfor (let tag of tags) {\nallTags[tag] = true;\n}\n+ // This branch should no longer be necessary per TemplateContent.cleanupFrontMatterData\n} else if (tags) {\nallTags[tags] = true;\n}\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateTest.js", "new_path": "test/TemplateTest.js", "diff": "@@ -1141,3 +1141,23 @@ test(\"permalink: false\", async t => {\nfalse\n);\n});\n+\n+test(\"Front Matter Tags (Single)\", async t => {\n+ let tmpl = new Template(\n+ \"./test/stubs/templatetest-frontmatter/single.njk\",\n+ \"./test/stubs/\",\n+ \"dist\"\n+ );\n+ let frontmatter = await tmpl.getFrontMatterData();\n+ t.deepEqual(frontmatter.tags, [\"single-tag\"]);\n+});\n+\n+test(\"Front Matter Tags (Multiple)\", async t => {\n+ let tmpl = new Template(\n+ \"./test/stubs/templatetest-frontmatter/multiple.njk\",\n+ \"./test/stubs/\",\n+ \"dist\"\n+ );\n+ let frontmatter = await tmpl.getFrontMatterData();\n+ t.deepEqual(frontmatter.tags, [\"multi-tag\", \"multi-tag-2\"]);\n+});\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/templatetest-frontmatter/multiple.njk", "diff": "+---\n+tags:\n+ - multi-tag\n+ - multi-tag-2\n+---\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/templatetest-frontmatter/single.njk", "diff": "+---\n+tags: single-tag\n+---\n" } ]
JavaScript
MIT License
11ty/eleventy
Fixes #246, normalizes front matter tags to always be an array when fetched. Maintains backwards compatibility.
699
26.09.2018 07:22:14
18,000
d558b5fb5de5c69b335b92e5c601349812cb8122
Better debug error stack trace formatting
[ { "change_type": "MODIFY", "old_path": "src/EleventyErrorHandler.js", "new_path": "src/EleventyErrorHandler.js", "diff": "@@ -25,7 +25,7 @@ class EleventyErrorHandler {\n`${ref.message} (${ref.name})`,\ntype\n);\n- debug(`(${type} stack): %O`, ref.stack);\n+ debug(`(${type} stack): ${ref.stack}`);\nref = ref.originalError;\n}\n}\n" } ]
JavaScript
MIT License
11ty/eleventy
Better debug error stack trace formatting
699
26.09.2018 08:10:07
18,000
545ea7b7d49e521dc0e55e3c4c50bbab85451154
Config tests have side effects, need to be .reset() until refactored
[ { "change_type": "MODIFY", "old_path": "src/UserConfig.js", "new_path": "src/UserConfig.js", "diff": "@@ -131,6 +131,7 @@ class UserConfig {\n// Support the nunjucks style syntax for asynchronous filter add\naddNunjucksFilter(name, callback, isAsync) {\nif (isAsync) {\n+ // namespacing happens downstream\nthis.addNunjucksAsyncFilter(name, callback);\n} else {\nname = this.getNamespacedName(name);\n@@ -171,6 +172,8 @@ class UserConfig {\naddFilter(name, callback) {\ndebug(\"Adding universal filter %o\", this.getNamespacedName(name));\n+\n+ // namespacing happens downstream\nthis.addLiquidFilter(name, callback);\nthis.addNunjucksFilter(name, callback);\n@@ -232,7 +235,7 @@ class UserConfig {\nthis.collections[name] = callback;\n}\n- addPlugin(pluginCallback, initializer) {\n+ addPlugin(pluginCallback) {\ndebug(\"Adding plugin (unknown name: check your config file).\");\nif (typeof pluginCallback !== \"function\") {\nthrow new UserConfigError(\n@@ -240,7 +243,7 @@ class UserConfig {\n);\n}\n- pluginCallback(this, initializer);\n+ pluginCallback(this);\n}\ngetNamespacedName(name) {\n@@ -248,10 +251,17 @@ class UserConfig {\n}\nnamespace(pluginNamespace, callback) {\n+ let validNamespace = pluginNamespace && typeof pluginNamespace === \"string\";\n+ if (validNamespace) {\nthis.activeNamespace = pluginNamespace || \"\";\n+ }\n+\ncallback();\n+\n+ if (validNamespace) {\nthis.activeNamespace = \"\";\n}\n+ }\n/**\n* Adds a path to a file or directory to the list of pass-through copies\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateConfigTest.js", "new_path": "test/TemplateConfigTest.js", "diff": "@@ -34,6 +34,7 @@ test(\"Template Config local config overrides base config\", async t => {\n});\ntest(\"Add liquid tag\", t => {\n+ eleventyConfig.reset();\neleventyConfig.addLiquidTag(\"myTagName\", function() {});\nlet templateCfg = new TemplateConfig(\n@@ -45,6 +46,7 @@ test(\"Add liquid tag\", t => {\n});\ntest(\"Add nunjucks tag\", t => {\n+ eleventyConfig.reset();\neleventyConfig.addNunjucksTag(\"myNunjucksTag\", function() {});\nlet templateCfg = new TemplateConfig(\n@@ -56,6 +58,7 @@ test(\"Add nunjucks tag\", t => {\n});\ntest(\"Add liquid filter\", t => {\n+ eleventyConfig.reset();\neleventyConfig.addLiquidFilter(\"myFilterName\", function(liquidEngine) {\nreturn {};\n});\n@@ -69,6 +72,7 @@ test(\"Add liquid filter\", t => {\n});\ntest(\"Add handlebars helper\", t => {\n+ eleventyConfig.reset();\neleventyConfig.addHandlebarsHelper(\"myHelperName\", function() {});\nlet templateCfg = new TemplateConfig(\n@@ -80,6 +84,7 @@ test(\"Add handlebars helper\", t => {\n});\ntest(\"Add nunjucks filter\", t => {\n+ eleventyConfig.reset();\neleventyConfig.addNunjucksFilter(\"myFilterName\", function() {});\nlet templateCfg = new TemplateConfig(\n@@ -91,6 +96,7 @@ test(\"Add nunjucks filter\", t => {\n});\ntest(\"Add universal filter\", t => {\n+ eleventyConfig.reset();\neleventyConfig.addFilter(\"myFilterName\", function() {});\nlet templateCfg = new TemplateConfig(\n@@ -104,6 +110,7 @@ test(\"Add universal filter\", t => {\n});\ntest(\"Add namespaced universal filter\", t => {\n+ eleventyConfig.reset();\neleventyConfig.namespace(\"testNamespace\", function() {\neleventyConfig.addFilter(\"MyFilterName\", function() {});\n});\n@@ -128,6 +135,7 @@ test(\"Add namespaced universal filter\", t => {\n});\ntest(\"Add namespaced universal filter using underscore\", t => {\n+ eleventyConfig.reset();\neleventyConfig.namespace(\"testNamespace_\", function() {\neleventyConfig.addFilter(\"myFilterName\", function() {});\n});\n@@ -151,6 +159,66 @@ test(\"Add namespaced universal filter using underscore\", t => {\n);\n});\n+test(\"Empty namespace\", t => {\n+ eleventyConfig.reset();\n+ eleventyConfig.namespace(\"\", function() {\n+ eleventyConfig.addNunjucksFilter(\"myFilterName\", function() {});\n+ });\n+\n+ let templateCfg = new TemplateConfig(\n+ require(\"../config.js\"),\n+ \"./test/stubs/config.js\"\n+ );\n+ let cfg = templateCfg.getConfig();\n+ t.not(Object.keys(cfg.nunjucksFilters).indexOf(\"myFilterName\"), -1);\n+});\n+\n+test(\"Nested Empty Inner namespace\", t => {\n+ eleventyConfig.reset();\n+ eleventyConfig.namespace(\"testNs\", function() {\n+ eleventyConfig.namespace(\"\", function() {\n+ eleventyConfig.addNunjucksFilter(\"myFilterName\", function() {});\n+ });\n+ });\n+\n+ let templateCfg = new TemplateConfig(\n+ require(\"../config.js\"),\n+ \"./test/stubs/config.js\"\n+ );\n+ let cfg = templateCfg.getConfig();\n+ t.not(Object.keys(cfg.nunjucksFilters).indexOf(\"testNsmyFilterName\"), -1);\n+});\n+\n+test(\"Nested Empty Outer namespace\", t => {\n+ eleventyConfig.reset();\n+ eleventyConfig.namespace(\"\", function() {\n+ eleventyConfig.namespace(\"testNs\", function() {\n+ eleventyConfig.addNunjucksFilter(\"myFilterName\", function() {});\n+ });\n+ });\n+\n+ let templateCfg = new TemplateConfig(\n+ require(\"../config.js\"),\n+ \"./test/stubs/config.js\"\n+ );\n+ let cfg = templateCfg.getConfig();\n+ t.not(Object.keys(cfg.nunjucksFilters).indexOf(\"testNsmyFilterName\"), -1);\n+});\n+\n+test(\"Non-string namespaces are ignored\", t => {\n+ eleventyConfig.reset();\n+ eleventyConfig.namespace([\"lkdsjflksd\"], function() {\n+ eleventyConfig.addNunjucksFilter(\"myFilterName\", function() {});\n+ });\n+\n+ let templateCfg = new TemplateConfig(\n+ require(\"../config.js\"),\n+ \"./test/stubs/config.js\"\n+ );\n+ let cfg = templateCfg.getConfig();\n+ t.not(Object.keys(cfg.nunjucksFilters).indexOf(\"myFilterName\"), -1);\n+});\n+\ntest(\"Test url universal filter with custom pathPrefix (no slash)\", t => {\nlet templateCfg = new TemplateConfig(\nrequire(\"../config.js\"),\n@@ -162,6 +230,7 @@ test(\"Test url universal filter with custom pathPrefix (no slash)\", t => {\n});\ntest(\"setTemplateFormats(string)\", t => {\n+ eleventyConfig.reset();\neleventyConfig.setTemplateFormats(\"ejs,njk, liquid\");\nlet templateCfg = new TemplateConfig(\n@@ -173,6 +242,7 @@ test(\"setTemplateFormats(string)\", t => {\n});\ntest(\"setTemplateFormats(array)\", t => {\n+ eleventyConfig.reset();\neleventyConfig.setTemplateFormats([\"ejs\", \"njk\", \"liquid\"]);\nlet templateCfg = new TemplateConfig(\n@@ -184,6 +254,7 @@ test(\"setTemplateFormats(array)\", t => {\n});\ntest(\"setTemplateFormats(array, size 1)\", t => {\n+ eleventyConfig.reset();\neleventyConfig.setTemplateFormats([\"liquid\"]);\nlet templateCfg = new TemplateConfig(\n@@ -195,6 +266,7 @@ test(\"setTemplateFormats(array, size 1)\", t => {\n});\ntest(\"setTemplateFormats(empty array)\", t => {\n+ eleventyConfig.reset();\neleventyConfig.setTemplateFormats([]);\nlet templateCfg = new TemplateConfig(\n" } ]
JavaScript
MIT License
11ty/eleventy
Config tests have side effects, need to be .reset() until refactored
699
28.09.2018 09:01:48
18,000
5a81ba65b4319283ca65e50ccfa5fc620c7a4179
Adds new plugin options to support new features for eleventy-plugin-syntaxhighlight v2.0.0
[ { "change_type": "MODIFY", "old_path": "src/UserConfig.js", "new_path": "src/UserConfig.js", "diff": "@@ -235,15 +235,21 @@ class UserConfig {\nthis.collections[name] = callback;\n}\n- addPlugin(pluginCallback) {\n+ addPlugin(plugin, options = {}) {\ndebug(\"Adding plugin (unknown name: check your config file).\");\n- if (typeof pluginCallback !== \"function\") {\n+ if (typeof plugin === \"function\") {\n+ plugin(this);\n+ } else if (plugin && plugin.configFunction) {\n+ if (typeof options.init === \"function\") {\n+ options.init.call(this, plugin.initArguments || {});\n+ }\n+\n+ plugin.configFunction(this, options);\n+ } else {\nthrow new UserConfigError(\n- \"EleventyConfig.addPlugin expects the first argument to be a function.\"\n+ \"Invalid EleventyConfig.addPlugin signature. Should be a function or a valid Eleventy plugin object.\"\n);\n}\n-\n- pluginCallback(this);\n}\ngetNamespacedName(name) {\n" } ]
JavaScript
MIT License
11ty/eleventy
Adds new plugin options to support new features for eleventy-plugin-syntaxhighlight v2.0.0
699
29.09.2018 22:55:52
18,000
00ec80f49554995022374139e965130a6cf47dd9
Adds tests for the failing ones are skipped until the dependency issue is fixed.
[ { "change_type": "MODIFY", "old_path": "test/TemplateRenderLiquidTest.js", "new_path": "test/TemplateRenderLiquidTest.js", "diff": "@@ -424,3 +424,13 @@ test(\"Liquid Missing Filter Issue #183\", async t => {\nt.pass(\"Threw an error.\");\n}\n});\n+\n+test.skip(\"Liquid Render Date, Issue #258\", async t => {\n+ let fn = await new TemplateRender(\"liquid\").getCompiledTemplate(\n+ \"<p>{{ myDate }}</p>\"\n+ );\n+ t.is(\n+ await fn({ myDate: new Date(Date.UTC(2016, 0, 1, 0, 0, 0)) }),\n+ \"<p>2016-01-01T00:00:00.000Z</p>\"\n+ );\n+});\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateTest.js", "new_path": "test/TemplateTest.js", "diff": "@@ -1161,3 +1161,31 @@ test(\"Front Matter Tags (Multiple)\", async t => {\nlet frontmatter = await tmpl.getFrontMatterData();\nt.deepEqual(frontmatter.tags, [\"multi-tag\", \"multi-tag-2\"]);\n});\n+\n+test.skip(\"Front matter date with quotes (liquid), issue #258\", async t => {\n+ let tmpl = new Template(\n+ \"./test/stubs/frontmatter-date/test.liquid\",\n+ \"./test/stubs/\",\n+ \"dist\"\n+ );\n+\n+ let data = await tmpl.getData();\n+ t.is(data.mydate.toISOString(), \"2009-04-15T00:34:34.000Z\");\n+\n+ let pages = await tmpl.getRenderedTemplates(data);\n+ t.is(pages[0].templateContent.trim(), `2009-04-15T00:34:34.000Z`);\n+});\n+\n+test(\"Front matter date with quotes (njk), issue #258\", async t => {\n+ let tmpl = new Template(\n+ \"./test/stubs/frontmatter-date/test.njk\",\n+ \"./test/stubs/\",\n+ \"dist\"\n+ );\n+\n+ let data = await tmpl.getData();\n+ t.is(data.mydate.toISOString(), \"2009-04-15T00:34:34.000Z\");\n+\n+ let pages = await tmpl.getRenderedTemplates(data);\n+ t.is(pages[0].templateContent.trim(), `2009-04-15T00:34:34.000Z`);\n+});\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/frontmatter-date/test.liquid", "diff": "+---\n+mydate: 2009-04-15T01:34:34+01:00\n+---\n+{{ mydate | date: \"%Y-%m-%d %H:%M:%S\" }}\n\\ No newline at end of file\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/frontmatter-date/test.njk", "diff": "+---\n+mydate: 2009-04-15T01:34:34+01:00\n+---\n+{{ mydate.toISOString() }}\n\\ No newline at end of file\n" } ]
JavaScript
MIT License
11ty/eleventy
Adds tests for #258, the failing ones are skipped until the dependency issue is fixed.
699
04.10.2018 08:43:49
18,000
c380cfc78da76f7a2115ff1e21929d1f4a74a16d
Working example of
[ { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "\"lodash.get\": \"^4.4.2\",\n\"lodash.isobject\": \"^3.0.2\",\n\"lodash.merge\": \"^4.6.1\",\n+ \"lodash.mergewith\": \"^4.6.1\",\n\"lodash.set\": \"^4.3.2\",\n\"lodash.uniq\": \"^4.5.0\",\n\"luxon\": \"^1.4.1\",\n" }, { "change_type": "MODIFY", "old_path": "src/Engines/Ejs.js", "new_path": "src/Engines/Ejs.js", "diff": "const ejsLib = require(\"ejs\");\nconst TemplateEngine = require(\"./TemplateEngine\");\n-const lodashMerge = require(\"lodash.merge\");\nconst config = require(\"../Config\");\nconst path = require(\"path\");\n@@ -31,7 +30,7 @@ class Ejs extends TemplateEngine {\ngetEjsOptions() {\nlet inputDir = super.getInputDir();\n- return lodashMerge(\n+ return Object.assign(\n{\nroot: \"./\" + inputDir,\ncompileDebug: true,\n" }, { "change_type": "MODIFY", "old_path": "src/Engines/Liquid.js", "new_path": "src/Engines/Liquid.js", "diff": "const LiquidLib = require(\"liquidjs\");\nconst TemplateEngine = require(\"./TemplateEngine\");\n-const lodashMerge = require(\"lodash.merge\");\nconst config = require(\"../Config\");\n// const debug = require(\"debug\")(\"Eleventy:Liquid\");\n@@ -44,7 +43,7 @@ class Liquid extends TemplateEngine {\nstrict_filters: false\n};\n- let options = lodashMerge(defaults, this.liquidOptions || {});\n+ let options = Object.assign(defaults, this.liquidOptions || {});\n// debug(\"Liquid constructor options: %o\", options);\nreturn options;\n" }, { "change_type": "MODIFY", "old_path": "src/Engines/Markdown.js", "new_path": "src/Engines/Markdown.js", "diff": "const markdownIt = require(\"markdown-it\");\nconst TemplateEngine = require(\"./TemplateEngine\");\n-const lodashMerge = require(\"lodash.merge\");\nconst config = require(\"../Config\");\n// const debug = require(\"debug\")(\"Eleventy:Markdown\");\n@@ -38,7 +37,7 @@ class Markdown extends TemplateEngine {\nreturn this.markdownOptions;\n}\n- return lodashMerge(\n+ return Object.assign(\n{\nhtml: true\n},\n" }, { "change_type": "MODIFY", "old_path": "src/Engines/Pug.js", "new_path": "src/Engines/Pug.js", "diff": "const PugLib = require(\"pug\");\nconst TemplateEngine = require(\"./TemplateEngine\");\n-const lodashMerge = require(\"lodash.merge\");\nconst config = require(\"../Config\");\nclass Pug extends TemplateEngine {\n@@ -26,7 +25,7 @@ class Pug extends TemplateEngine {\ngetPugOptions() {\nlet inputDir = super.getInputDir();\n- return lodashMerge(\n+ return Object.assign(\n{\nbasedir: inputDir,\nfilename: inputDir\n" }, { "change_type": "MODIFY", "old_path": "src/Template.js", "new_path": "src/Template.js", "diff": "const fs = require(\"fs-extra\");\nconst parsePath = require(\"parse-filepath\");\nconst normalize = require(\"normalize-path\");\n-const _isObject = require(\"lodash.isobject\");\n+const lodashIsObject = require(\"lodash.isobject\");\nconst { DateTime } = require(\"luxon\");\n+const TemplateData = require(\"./TemplateData\");\nconst TemplateContent = require(\"./TemplateContent\");\nconst TemplatePath = require(\"./TemplatePath\");\nconst TemplatePermalink = require(\"./TemplatePermalink\");\n@@ -150,7 +151,7 @@ class Template extends TemplateContent {\narr.push(await this.mapDataAsRenderedTemplates(data[j], templateData));\n}\nreturn arr;\n- } else if (_isObject(data)) {\n+ } else if (lodashIsObject(data)) {\nlet obj = {};\nfor (let value in data) {\nobj[value] = await this.mapDataAsRenderedTemplates(\n@@ -181,7 +182,7 @@ class Template extends TemplateContent {\nreturn {};\n}\n- async getData(localData) {\n+ async getData() {\nif (!this.dataCache) {\ndebugDev(\"%o getData()\", this.inputPath);\nlet localData = {};\n@@ -191,12 +192,15 @@ class Template extends TemplateContent {\ndebugDev(\"%o getData() getLocalData\", this.inputPath);\n}\n- Object.assign(localData, await this.getFrontMatterData());\n+ let frontMatterData = await this.getFrontMatterData();\n+ let foundLayout =\n+ frontMatterData[this.config.keys.layout] ||\n+ localData[this.config.keys.layout];\nlet mergedLayoutData = {};\n- if (localData[this.config.keys.layout]) {\n+ if (foundLayout) {\nlet layout = TemplateLayout.getTemplate(\n- localData[this.config.keys.layout],\n+ foundLayout,\nthis.getInputDir()\n);\nmergedLayoutData = await layout.getData();\n@@ -206,7 +210,12 @@ class Template extends TemplateContent {\n);\n}\n- let mergedData = Object.assign({}, mergedLayoutData, localData);\n+ let mergedData = TemplateData.merge(\n+ {},\n+ mergedLayoutData,\n+ localData,\n+ frontMatterData\n+ );\nmergedData = await this.addPageDate(mergedData);\nmergedData = this.addPageData(mergedData);\ndebugDev(\"%o getData() mergedData\", this.inputPath);\n@@ -214,7 +223,7 @@ class Template extends TemplateContent {\nthis.dataCache = mergedData;\n}\n- return Object.assign({}, this.dataCache, localData, this.paginationData);\n+ return TemplateData.merge({}, this.dataCache, this.paginationData);\n}\nasync addPageDate(data) {\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateLayout.js", "new_path": "src/TemplateLayout.js", "diff": "const TemplateLayoutPathResolver = require(\"./TemplateLayoutPathResolver\");\nconst TemplateContent = require(\"./TemplateContent\");\n+const TemplateData = require(\"./TemplateData\");\nconst templateCache = require(\"./TemplateCache\");\nconst config = require(\"./Config\");\n@@ -76,11 +77,14 @@ class TemplateLayout extends TemplateContent {\nreturn this.dataCache;\n}\n- let data = {};\nlet map = await this.getTemplateLayoutMap();\n+ let dataToMerge = [];\nfor (let j = map.length - 1; j >= 0; j--) {\n- Object.assign(data, map[j].frontMatterData);\n+ dataToMerge.push(map[j].frontMatterData);\n}\n+\n+ // Deep merge of layout front matter\n+ let data = TemplateData.merge({}, ...dataToMerge);\ndelete data[this.config.keys.layout];\nthis.dataCache = data;\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateDataTest.js", "new_path": "test/TemplateDataTest.js", "diff": "@@ -276,3 +276,17 @@ test(\"getTemplateDataFileGlob\", async t => {\n\"./test/stubs/**/*.11tydata.js\"\n]);\n});\n+\n+test(\"TemplateData.merge\", t => {\n+ t.deepEqual(\n+ TemplateData.merge(\n+ {\n+ tags: [1, 2, 3]\n+ },\n+ {\n+ tags: [4, 5, 6]\n+ }\n+ ),\n+ { tags: [1, 2, 3, 4, 5, 6] }\n+ );\n+});\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateTest.js", "new_path": "test/TemplateTest.js", "diff": "import test from \"ava\";\nimport fs from \"fs-extra\";\n+import pretty from \"pretty\";\nimport TemplateData from \"../src/TemplateData\";\nimport Template from \"../src/Template\";\n-import pretty from \"pretty\";\nimport templateConfig from \"../src/Config\";\nconst config = templateConfig.getConfig();\n@@ -161,29 +161,6 @@ test(\"Test that getData() works\", async t => {\nt.is(data.key3, \"value3\");\n});\n-test(\"More advanced getData()\", async t => {\n- let dataObj = new TemplateData(\"./test/stubs/\");\n- let tmpl = new Template(\n- \"./test/stubs/templateFrontMatter.ejs\",\n- \"./test/stubs/\",\n- \"dist\",\n- dataObj\n- );\n- let data = await tmpl.getData({\n- key1: \"value1override\",\n- key2: \"value2\"\n- });\n-\n- t.is(data[config.keys.package].name, \"@11ty/eleventy\");\n- t.is(\n- data.key1,\n- \"value1override\",\n- \"local data argument overrides front matter\"\n- );\n- t.is(data.key2, \"value2\", \"local data argument, no front matter\");\n- t.is(data.key3, \"value3\", \"front matter only\");\n-});\n-\ntest(\"One Layout (using new content var)\", async t => {\nlet dataObj = new TemplateData(\"./test/stubs/\");\nlet tmpl = new Template(\n@@ -1189,3 +1166,48 @@ test(\"Front matter date with quotes (njk), issue #258\", async t => {\nlet pages = await tmpl.getRenderedTemplates(data);\nt.is(pages[0].templateContent.trim(), `2009-04-15T00:34:34.000Z`);\n});\n+\n+test(\"Data Cascade\", async t => {\n+ let dataObj = new TemplateData();\n+ await dataObj.cacheData();\n+\n+ let tmpl = new Template(\n+ \"./test/stubs/data-cascade/template.njk\",\n+ \"./test/stubs/\",\n+ \"./dist\",\n+ dataObj\n+ );\n+\n+ let data = await tmpl.getData();\n+ t.deepEqual(Object.keys(data).sort(), [\n+ \"datafile\",\n+ \"frontmatter\",\n+ \"page\",\n+ \"parent\",\n+ \"pkg\",\n+ \"tags\"\n+ ]);\n+\n+ t.deepEqual(Object.keys(data.parent).sort(), [\n+ \"child\",\n+ \"datafile\",\n+ \"frontmatter\"\n+ ]);\n+\n+ t.is(data.parent.child, -2);\n+});\n+\n+test(\"Data Cascade Tag Merge\", async t => {\n+ let dataObj = new TemplateData();\n+ await dataObj.cacheData();\n+\n+ let tmpl = new Template(\n+ \"./test/stubs/data-cascade/template.njk\",\n+ \"./test/stubs/\",\n+ \"./dist\",\n+ dataObj\n+ );\n+\n+ let data = await tmpl.getData();\n+ t.deepEqual(data.tags.sort(), [\"tagA\", \"tagB\", \"tagC\", \"tagD\"]);\n+});\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/data-cascade/template.11tydata.js", "diff": "+module.exports = {\n+ parent: {\n+ child: 2,\n+ datafile: true\n+ },\n+ datafile: true,\n+ tags: [\"tagC\", \"tagD\"]\n+};\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/data-cascade/template.njk", "diff": "+---\n+parent:\n+ child: -2\n+ frontmatter: true\n+frontmatter: true\n+tags:\n+ - tagA\n+ - tagB\n+---\n\\ No newline at end of file\n" } ]
JavaScript
MIT License
11ty/eleventy
Working example of #147
699
06.10.2018 14:20:57
18,000
ef4e3526053eba9f922164b1dcc098985809cf57
Test, fixes
[ { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "\"hamljs\": \"^0.6.2\",\n\"handlebars\": \"^4.0.12\",\n\"javascript-stringify\": \"^1.6.0\",\n- \"liquidjs\": \"^6.0.0\",\n+ \"liquidjs\": \"^6.0.1\",\n\"lodash.chunk\": \"^4.2.0\",\n\"lodash.clone\": \"^4.5.0\",\n\"lodash.get\": \"^4.4.2\",\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateRenderLiquidTest.js", "new_path": "test/TemplateRenderLiquidTest.js", "diff": "@@ -425,12 +425,12 @@ test(\"Liquid Missing Filter Issue #183\", async t => {\n}\n});\n-test.skip(\"Liquid Render Date, Issue #258\", async t => {\n+test(\"Liquid Render Date, Issue #258\", async t => {\nlet fn = await new TemplateRender(\"liquid\").getCompiledTemplate(\n\"<p>{{ myDate }}</p>\"\n);\n- t.is(\n- await fn({ myDate: new Date(Date.UTC(2016, 0, 1, 0, 0, 0)) }),\n- \"<p>2016-01-01T00:00:00.000Z</p>\"\n- );\n+ let dateStr = await fn({ myDate: new Date(Date.UTC(2016, 0, 1, 0, 0, 0)) });\n+ t.is(dateStr.substr(0, 3), \"<p>\");\n+ t.is(dateStr.substr(-4), \"</p>\");\n+ t.not(dateStr.substr(2, 1), '\"');\n});\n" } ]
JavaScript
MIT License
11ty/eleventy
Test, fixes #258
699
06.10.2018 21:04:24
18,000
0dac4389936a7d7bdbafd369cd660095dddd30c7
Adds DATA_DEEP_MERGE experiment. Opt-in to global deep-merging behavior with `eleventyConfig.addExperiment("DATA_DEEP_MERGE")`
[ { "change_type": "MODIFY", "old_path": "src/Template.js", "new_path": "src/Template.js", "diff": "@@ -175,7 +175,8 @@ class Template extends TemplateContent {\nif (frontMatterData[this.config.keys.layout]) {\nlet layout = TemplateLayout.getTemplate(\nfrontMatterData[this.config.keys.layout],\n- this.getInputDir()\n+ this.getInputDir(),\n+ this.config\n);\nreturn await layout.getData();\n}\n@@ -201,7 +202,8 @@ class Template extends TemplateContent {\nif (foundLayout) {\nlet layout = TemplateLayout.getTemplate(\nfoundLayout,\n- this.getInputDir()\n+ this.getInputDir(),\n+ this.config\n);\nmergedLayoutData = await layout.getData();\ndebugDev(\n@@ -210,7 +212,8 @@ class Template extends TemplateContent {\n);\n}\n- let mergedData = TemplateData.merge(\n+ let mergedData = TemplateData.mergeExperiment(\n+ this.config,\n{},\nmergedLayoutData,\nlocalData,\n@@ -223,7 +226,12 @@ class Template extends TemplateContent {\nthis.dataCache = mergedData;\n}\n- return TemplateData.merge({}, this.dataCache, this.paginationData);\n+ return TemplateData.mergeExperiment(\n+ this.config,\n+ {},\n+ this.dataCache,\n+ this.paginationData\n+ );\n}\nasync addPageDate(data) {\n@@ -295,7 +303,11 @@ class Template extends TemplateContent {\nasync renderLayout(tmpl, tmplData) {\nlet layoutKey = tmplData[tmpl.config.keys.layout];\n- let layout = TemplateLayout.getTemplate(layoutKey, this.getInputDir());\n+ let layout = TemplateLayout.getTemplate(\n+ layoutKey,\n+ this.getInputDir(),\n+ this.config\n+ );\ndebug(\"%o is using layout %o\", this.inputPath, layoutKey);\n// TODO reuse templateContent from templateMap\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateContent.js", "new_path": "src/TemplateContent.js", "diff": "@@ -25,6 +25,11 @@ class TemplateContent {\nthis.templateRender = new TemplateRender(this.inputPath, this.inputDir);\n}\n+ /* Used by tests */\n+ _setConfig(config) {\n+ this.config = config;\n+ }\n+\ngetInputPath() {\nreturn this.inputPath;\n}\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateData.js", "new_path": "src/TemplateData.js", "diff": "@@ -26,6 +26,11 @@ class TemplateData {\nthis.globalData = null;\n}\n+ /* Used by tests */\n+ _setConfig(config) {\n+ this.config = config;\n+ }\n+\nsetInputDir(inputDir) {\nthis.inputDirNeedsCheck = true;\nthis.inputDir = inputDir;\n@@ -178,7 +183,7 @@ class TemplateData {\n}\nfor (let path of localDataPaths) {\nlet dataForPath = await this.getDataValue(path, null, true);\n- TemplateData.merge(localData, dataForPath);\n+ TemplateData.mergeExperiment(this.config, localData, dataForPath);\n// debug(\"`combineLocalData` (iterating) for %o: %O\", path, localData);\n}\nreturn localData;\n@@ -288,6 +293,14 @@ class TemplateData {\nreturn lodashUniq(paths).reverse();\n}\n+ static mergeExperiment(config, target, ...source) {\n+ if (config.experiments.has(\"DATA_DEEP_MERGE\")) {\n+ return TemplateData.merge(target, ...source);\n+ } else {\n+ return Object.assign(target, ...source);\n+ }\n+ }\n+\nstatic merge(target, ...source) {\nreturn lodashMergeWith(target, ...source, function dataMergeCustomizer(\ntarget,\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateLayout.js", "new_path": "src/TemplateLayout.js", "diff": "@@ -28,7 +28,7 @@ class TemplateLayout extends TemplateContent {\nreturn inputDir + key;\n}\n- static getTemplate(key, inputDir) {\n+ static getTemplate(key, inputDir, config) {\nlet fullKey = TemplateLayout.resolveFullKey(key, inputDir);\nif (templateCache.has(fullKey)) {\ndebugDev(\"Found %o in TemplateCache\", key);\n@@ -36,6 +36,7 @@ class TemplateLayout extends TemplateContent {\n}\nlet tmpl = new TemplateLayout(key, inputDir);\n+ tmpl._setConfig(config);\ntemplateCache.add(fullKey, tmpl);\nreturn tmpl;\n@@ -62,7 +63,8 @@ class TemplateLayout extends TemplateContent {\nwhile (mapEntry.frontMatterData && cfgKey in mapEntry.frontMatterData) {\nlet layout = TemplateLayout.getTemplate(\nmapEntry.frontMatterData[cfgKey],\n- this.inputDir\n+ this.inputDir,\n+ this.config\n);\nmapEntry = await layout.getTemplateLayoutMapEntry();\nmap.push(mapEntry);\n@@ -84,7 +86,7 @@ class TemplateLayout extends TemplateContent {\n}\n// Deep merge of layout front matter\n- let data = TemplateData.merge({}, ...dataToMerge);\n+ let data = TemplateData.mergeExperiment(this.config, {}, ...dataToMerge);\ndelete data[this.config.keys.layout];\nthis.dataCache = data;\n" }, { "change_type": "MODIFY", "old_path": "src/UserConfig.js", "new_path": "src/UserConfig.js", "diff": "@@ -47,6 +47,7 @@ class UserConfig {\nthis.DateTime = DateTime;\nthis.dynamicPermalinks = true;\nthis.useGitIgnore = true;\n+ this.experiments = new Set();\n}\nversionCheck(expected) {\n@@ -432,6 +433,10 @@ class UserConfig {\n);\n}\n+ addExperiment(key) {\n+ this.experiments.add(key);\n+ }\n+\ngetMergingConfigObject() {\nreturn {\ntemplateFormats: this.templateFormats,\n@@ -458,7 +463,8 @@ class UserConfig {\nmarkdownHighlighter: this.markdownHighlighter,\nlibraryOverrides: this.libraryOverrides,\ndynamicPermalinks: this.dynamicPermalinks,\n- useGitIgnore: this.useGitIgnore\n+ useGitIgnore: this.useGitIgnore,\n+ experiments: this.experiments\n};\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateTest.js", "new_path": "test/TemplateTest.js", "diff": "@@ -1167,8 +1167,12 @@ test(\"Front matter date with quotes (njk), issue #258\", async t => {\nt.is(pages[0].templateContent.trim(), `2009-04-15T00:34:34.000Z`);\n});\n-test(\"Data Cascade\", async t => {\n+test(\"Data Cascade (Deep merge)\", async t => {\n+ let newConfig = Object.assign({}, config);\n+ newConfig.experiments = new Set([\"DATA_DEEP_MERGE\"]);\n+\nlet dataObj = new TemplateData();\n+ dataObj._setConfig(newConfig);\nawait dataObj.cacheData();\nlet tmpl = new Template(\n@@ -1177,6 +1181,7 @@ test(\"Data Cascade\", async t => {\n\"./dist\",\ndataObj\n);\n+ tmpl._setConfig(newConfig);\nlet data = await tmpl.getData();\nt.deepEqual(Object.keys(data).sort(), [\n@@ -1197,7 +1202,7 @@ test(\"Data Cascade\", async t => {\nt.is(data.parent.child, -2);\n});\n-test(\"Data Cascade Tag Merge\", async t => {\n+test(\"Data Cascade (Shallow merge)\", async t => {\nlet dataObj = new TemplateData();\nawait dataObj.cacheData();\n@@ -1208,6 +1213,52 @@ test(\"Data Cascade Tag Merge\", async t => {\ndataObj\n);\n+ let data = await tmpl.getData();\n+ t.deepEqual(Object.keys(data).sort(), [\n+ \"datafile\",\n+ \"frontmatter\",\n+ \"page\",\n+ \"parent\",\n+ \"pkg\",\n+ \"tags\"\n+ ]);\n+\n+ t.deepEqual(Object.keys(data.parent).sort(), [\"child\", \"frontmatter\"]);\n+\n+ t.is(data.parent.child, -2);\n+});\n+\n+test(\"Data Cascade Tag Merge (Deep merge)\", async t => {\n+ let newConfig = Object.assign({}, config);\n+ newConfig.experiments = new Set([\"DATA_DEEP_MERGE\"]);\n+\n+ let dataObj = new TemplateData();\n+ dataObj._setConfig(newConfig);\n+ await dataObj.cacheData();\n+\n+ let tmpl = new Template(\n+ \"./test/stubs/data-cascade/template.njk\",\n+ \"./test/stubs/\",\n+ \"./dist\",\n+ dataObj\n+ );\n+ tmpl._setConfig(newConfig);\n+\nlet data = await tmpl.getData();\nt.deepEqual(data.tags.sort(), [\"tagA\", \"tagB\", \"tagC\", \"tagD\"]);\n});\n+\n+test(\"Data Cascade Tag Merge (Shallow merge)\", async t => {\n+ let dataObj = new TemplateData();\n+ await dataObj.cacheData();\n+\n+ let tmpl = new Template(\n+ \"./test/stubs/data-cascade/template.njk\",\n+ \"./test/stubs/\",\n+ \"./dist\",\n+ dataObj\n+ );\n+\n+ let data = await tmpl.getData();\n+ t.deepEqual(data.tags.sort(), [\"tagA\", \"tagB\"]);\n+});\n" } ]
JavaScript
MIT License
11ty/eleventy
Adds DATA_DEEP_MERGE experiment. Opt-in to global deep-merging behavior with `eleventyConfig.addExperiment("DATA_DEEP_MERGE")`
699
07.10.2018 19:59:20
18,000
9b4e94759ce136b168f67b70c00f9d8da38e8ee8
Adds `override:` prefix to any data key to allow it to override upstream values (not deep merge)
[ { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "\"gray-matter\": \"^4.0.1\",\n\"hamljs\": \"^0.6.2\",\n\"handlebars\": \"^4.0.12\",\n+ \"is-plain-object\": \"^2.0.4\",\n\"javascript-stringify\": \"^1.6.0\",\n\"liquidjs\": \"^6.0.1\",\n\"lodash.chunk\": \"^4.2.0\",\n\"lodash.get\": \"^4.4.2\",\n\"lodash.isobject\": \"^3.0.2\",\n\"lodash.merge\": \"^4.6.1\",\n- \"lodash.mergewith\": \"^4.6.1\",\n\"lodash.set\": \"^4.3.2\",\n\"lodash.uniq\": \"^4.5.0\",\n\"luxon\": \"^1.4.1\",\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateData.js", "new_path": "src/TemplateData.js", "diff": "@@ -2,8 +2,8 @@ const fs = require(\"fs-extra\");\nconst fastglob = require(\"fast-glob\");\nconst parsePath = require(\"parse-filepath\");\nconst lodashset = require(\"lodash.set\");\n-const lodashMergeWith = require(\"lodash.mergewith\");\nconst lodashUniq = require(\"lodash.uniq\");\n+const merge = require(\"./Util/Merge\");\nconst TemplateRender = require(\"./TemplateRender\");\nconst TemplatePath = require(\"./TemplatePath\");\nconst TemplateGlob = require(\"./TemplateGlob\");\n@@ -302,14 +302,7 @@ class TemplateData {\n}\nstatic merge(target, ...source) {\n- return lodashMergeWith(target, ...source, function dataMergeCustomizer(\n- target,\n- source\n- ) {\n- if (Array.isArray(target)) {\n- return target.concat(source);\n- }\n- });\n+ return merge(target, ...source);\n}\n}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "src/Util/Merge.js", "diff": "+const isPlainObject = require(\"is-plain-object\");\n+const OVERRIDE_PREFIX = \"override:\";\n+\n+function getMergedItem(target, source, parentKey) {\n+ // if key is prefixed with OVERRIDE_PREFIX, it just keeps the new source value (no merging)\n+ if (parentKey && parentKey.indexOf(OVERRIDE_PREFIX) === 0) {\n+ return source;\n+ }\n+\n+ if (!target) {\n+ return source;\n+ } else if (Array.isArray(target) && Array.isArray(source)) {\n+ return target.concat(source);\n+ } else if (isPlainObject(target)) {\n+ if (isPlainObject(source)) {\n+ for (var key in source) {\n+ let newKey = key;\n+ if (key.indexOf(OVERRIDE_PREFIX) === 0) {\n+ newKey = key.substr(OVERRIDE_PREFIX.length);\n+ }\n+ target[newKey] = getMergedItem(target[key], source[key], newKey);\n+ }\n+ }\n+ return target;\n+ } else {\n+ // number, string, class instance, etc\n+ return source;\n+ }\n+}\n+function Merge(target, ...sources) {\n+ // Remove override prefixes from root target.\n+ if (isPlainObject(target)) {\n+ for (var key in target) {\n+ if (key.indexOf(OVERRIDE_PREFIX) === 0) {\n+ target[key.substr(OVERRIDE_PREFIX.length)] = target[key];\n+ delete target[key];\n+ }\n+ }\n+ }\n+\n+ for (var source of sources) {\n+ if (!source) {\n+ continue;\n+ }\n+ target = getMergedItem(target, source);\n+ }\n+\n+ return target;\n+}\n+\n+module.exports = Merge;\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/MergeTest.js", "diff": "+import test from \"ava\";\n+import Merge from \"../src/Util/Merge\";\n+\n+test(\"Shallow Merge\", t => {\n+ t.deepEqual(Merge({}, {}), {});\n+ t.deepEqual(Merge({ a: 1 }, { a: 2 }), { a: 2 });\n+ t.deepEqual(Merge({ a: 1 }, { a: 2 }, { a: 3 }), { a: 3 });\n+\n+ t.deepEqual(Merge({ a: 1 }, { b: 1 }), { a: 1, b: 1 });\n+ t.deepEqual(Merge({ a: 1 }, { b: 1 }, { c: 1 }), { a: 1, b: 1, c: 1 });\n+\n+ t.deepEqual(Merge({ a: [1] }, { a: [2] }), { a: [1, 2] });\n+});\n+\n+test(\"Invalid\", t => {\n+ t.deepEqual(Merge({}, 1), {});\n+ t.deepEqual(Merge({}, [1]), {});\n+ t.deepEqual(Merge({}, \"string\"), {});\n+});\n+\n+test(\"Deep\", t => {\n+ t.deepEqual(Merge({ a: { b: 1 } }, { a: { c: 1 } }), { a: { b: 1, c: 1 } });\n+});\n+\n+test(\"Deep, override: prefix\", t => {\n+ t.deepEqual(Merge({ a: { b: [1, 2] } }, { a: { b: [3, 4] } }), {\n+ a: { b: [1, 2, 3, 4] }\n+ });\n+ t.deepEqual(Merge({ a: [1] }, { a: [2] }), { a: [1, 2] });\n+ t.deepEqual(Merge({ a: [1] }, { \"override:a\": [2] }), { a: [2] });\n+ t.deepEqual(Merge({ a: { b: [1, 2] } }, { a: { \"override:b\": [3, 4] } }), {\n+ a: { b: [3, 4] }\n+ });\n+});\n+\n+test(\"Deep, override: prefix at root\", t => {\n+ t.deepEqual(Merge({ \"override:a\": [1] }, { a: [2] }), { a: [1, 2] });\n+});\n+\n+test(\"Deep, override: prefix at other placements\", t => {\n+ t.deepEqual(\n+ Merge(\n+ {\n+ a: {\n+ a: [1]\n+ }\n+ },\n+ {\n+ a: {\n+ a: [2]\n+ }\n+ }\n+ ),\n+ {\n+ a: {\n+ a: [1, 2]\n+ }\n+ }\n+ );\n+\n+ t.deepEqual(\n+ Merge(\n+ {\n+ a: {\n+ a: [1]\n+ }\n+ },\n+ {\n+ a: {\n+ \"override:a\": [2]\n+ }\n+ }\n+ ),\n+ {\n+ a: {\n+ a: [2]\n+ }\n+ }\n+ );\n+\n+ t.deepEqual(\n+ Merge(\n+ {\n+ \"override:a\": {\n+ a: [1]\n+ }\n+ },\n+ {\n+ a: {\n+ a: [2]\n+ }\n+ }\n+ ),\n+ {\n+ a: {\n+ a: [1, 2]\n+ }\n+ }\n+ );\n+\n+ t.deepEqual(\n+ Merge(\n+ {\n+ a: {\n+ a: [1],\n+ b: [1]\n+ }\n+ },\n+ {\n+ \"override:a\": {\n+ a: [2]\n+ }\n+ }\n+ ),\n+ {\n+ a: {\n+ a: [2]\n+ }\n+ }\n+ );\n+\n+ t.deepEqual(\n+ Merge(\n+ {\n+ a: {\n+ a: {\n+ a: [1]\n+ }\n+ }\n+ },\n+ {\n+ a: {\n+ \"override:a\": {\n+ a: [2]\n+ }\n+ }\n+ }\n+ ),\n+ {\n+ a: {\n+ a: {\n+ a: [2]\n+ }\n+ }\n+ }\n+ );\n+});\n" } ]
JavaScript
MIT License
11ty/eleventy
Adds `override:` prefix to any data key to allow it to override upstream values (not deep merge)
699
10.10.2018 08:19:03
18,000
f5d78d866f81a5d57871b3bb23744a5d3a222396
A few more badges
[ { "change_type": "MODIFY", "old_path": "README.md", "new_path": "README.md", "diff": "@@ -13,7 +13,7 @@ Works with HTML, Markdown, Liquid, Nunjucks, Handlebars, Mustache, EJS, Haml, Pu\n- [@11ty on npm](https://www.npmjs.com/org/11ty)\n- [@11ty on GitHub](https://github.com/11ty)\n-[![Build Status](https://img.shields.io/travis/11ty/eleventy/master.svg?style=for-the-badge)](https://travis-ci.org/11ty/eleventy) [![GitHub issues](https://img.shields.io/github/issues/11ty/eleventy.svg?style=for-the-badge)](https://github.com/11ty/eleventy/issues) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=for-the-badge)](https://github.com/prettier/prettier)\n+[![Build Status](https://img.shields.io/travis/11ty/eleventy/master.svg?style=for-the-badge)](https://travis-ci.org/11ty/eleventy) [![GitHub issues](https://img.shields.io/github/issues/11ty/eleventy.svg?style=for-the-badge)](https://github.com/11ty/eleventy/issues) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=for-the-badge)](https://github.com/prettier/prettier) ![npm Version](https://img.shields.io/npm/v/@11ty/eleventy.svg?style=flat-square)](https://www.npmjs.com/package/@11ty/eleventy) ![npm Downloads](https://img.shields.io/npm/dt/@11ty/eleventy.svg?style=flat-square)](https://www.npmjs.com/package/@11ty/eleventy)\n## Tests\n" } ]
JavaScript
MIT License
11ty/eleventy
A few more badges
699
10.10.2018 08:20:46
18,000
3367e8e5e22ced9989322247d0057e9fd11eacc1
Markdown error
[ { "change_type": "MODIFY", "old_path": "README.md", "new_path": "README.md", "diff": "@@ -13,7 +13,7 @@ Works with HTML, Markdown, Liquid, Nunjucks, Handlebars, Mustache, EJS, Haml, Pu\n- [@11ty on npm](https://www.npmjs.com/org/11ty)\n- [@11ty on GitHub](https://github.com/11ty)\n-[![Build Status](https://img.shields.io/travis/11ty/eleventy/master.svg?style=for-the-badge)](https://travis-ci.org/11ty/eleventy) [![GitHub issues](https://img.shields.io/github/issues/11ty/eleventy.svg?style=for-the-badge)](https://github.com/11ty/eleventy/issues) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=for-the-badge)](https://github.com/prettier/prettier) ![npm Version](https://img.shields.io/npm/v/@11ty/eleventy.svg?style=flat-square)](https://www.npmjs.com/package/@11ty/eleventy) ![npm Downloads](https://img.shields.io/npm/dt/@11ty/eleventy.svg?style=flat-square)](https://www.npmjs.com/package/@11ty/eleventy)\n+[![Build Status](https://img.shields.io/travis/11ty/eleventy/master.svg?style=for-the-badge)](https://travis-ci.org/11ty/eleventy) [![GitHub issues](https://img.shields.io/github/issues/11ty/eleventy.svg?style=for-the-badge)](https://github.com/11ty/eleventy/issues) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=for-the-badge)](https://github.com/prettier/prettier) [![npm Version](https://img.shields.io/npm/v/@11ty/eleventy.svg?style=for-the-badge)](https://www.npmjs.com/package/@11ty/eleventy) [![npm Downloads](https://img.shields.io/npm/dt/@11ty/eleventy.svg?style=for-the-badge)](https://www.npmjs.com/package/@11ty/eleventy)\n## Tests\n" } ]
JavaScript
MIT License
11ty/eleventy
Markdown error
671
15.10.2018 11:55:35
-7,200
12d7ebecdd975479a3202cf21d14aa9b91718129
Check whether file exists before isDirectory check This adds a file exists check before statting the file. This avoids an exception being thrown, but more importantly, allows glob arguments to be passed as `--input`, fixing in the process.
[ { "change_type": "MODIFY", "old_path": "src/TemplatePath.js", "new_path": "src/TemplatePath.js", "diff": "@@ -133,7 +133,7 @@ TemplatePath.stripPathFromDir = function(targetDir, prunedPath) {\n};\nTemplatePath.isDirectorySync = function(path) {\n- return fs.statSync(path).isDirectory();\n+ return fs.existsSync(path) && fs.statSync(path).isDirectory();\n};\nTemplatePath.convertToGlob = function(path) {\n" }, { "change_type": "MODIFY", "old_path": "test/EleventyFilesTest.js", "new_path": "test/EleventyFilesTest.js", "diff": "@@ -48,6 +48,16 @@ test(\"Single File Input (shallow path)\", async t => {\nt.is(files[0], \"./README.md\");\n});\n+test(\"Glob Input\", async t => {\n+ let evf = new EleventyFiles(\"./test/stubs/glob-pages/!(contact.md)\", \"./test/stubs/_site\", [\"md\"]);\n+\n+ let globs = evf.getFileGlobs();\n+ let files = await fastglob.async(globs);\n+ t.is(files.length, 2);\n+ t.is(files[0], \"./test/stubs/glob-pages/about.md\");\n+ t.is(files[1], \"./test/stubs/glob-pages/home.md\");\n+});\n+\ntest(\".eleventyignore parsing\", t => {\nlet ignores = EleventyFiles.getFileIgnores(\"./test/stubs/.eleventyignore\");\nt.is(ignores.length, 2);\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/glob-pages/about.md", "diff": "+---\n+title: \"About\"\n+---\n+\n+About\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/glob-pages/contact.md", "diff": "+---\n+title: \"Contact\"\n+---\n+\n+Contact\n+\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/glob-pages/home.md", "diff": "+---\n+title: \"Home\"\n+---\n+\n+Home\n" } ]
JavaScript
MIT License
11ty/eleventy
Check whether file exists before isDirectory check This adds a file exists check before statting the file. This avoids an exception being thrown, but more importantly, allows glob arguments to be passed as `--input`, fixing #173 in the process.
692
30.10.2018 20:10:49
0
89129752c966bcc9b9f81bfddde831ee7324f21e
Added two helper variables to the Pagination plugin Changes to Pagination: * Added firstPageLink * Added lastPageLink
[ { "change_type": "MODIFY", "old_path": "src/Plugins/Pagination.js", "new_path": "src/Plugins/Pagination.js", "diff": "@@ -176,6 +176,11 @@ Pagination.prototype.getPageTemplates = async function() {\noverrides[pageNumber].pagination.next =\noverrides[pageNumber].pagination.nextPageLink;\n+ overrides[pageNumber].pagination.firstPageLink =\n+ links.length > 0 ? links[0] : null;\n+ overrides[pageNumber].pagination.lastPageLink =\n+ links.length > 0 ? links[links.length - 1] : null;\n+\noverrides[pageNumber].pagination.links = links;\n// todo deprecated, consistency with collections and use links instead\noverrides[pageNumber].pagination.pageLinks = links;\n" }, { "change_type": "MODIFY", "old_path": "test/PaginationTest.js", "new_path": "test/PaginationTest.js", "diff": "@@ -211,6 +211,51 @@ test(\"Permalink with pagination variables (numeric, one indexed)\", async t => {\nt.is(page1Data.pagination.pageLinks.length, 2);\n});\n+test(\"Permalink first and last page link with pagination variables (numeric)\", async t => {\n+ let tmpl = new Template(\n+ \"./test/stubs/paged/pagedpermalinknumeric.njk\",\n+ \"./test/stubs/\",\n+ \"./dist\"\n+ );\n+\n+ let data = await tmpl.getData();\n+ let paging = new Pagination(data);\n+ paging.setTemplate(tmpl);\n+ let pages = await paging.getPageTemplates();\n+\n+ let page0Data = await pages[0].getData();\n+ t.is(await pages[0].getOutputPath(), \"./dist/paged/page-0/index.html\");\n+ t.is(page0Data.pagination.firstPageLink, \"/paged/page-0/index.html\");\n+ t.is(page0Data.pagination.lastPageLink, \"/paged/page-1/index.html\");\n+\n+ let page1Data = await pages[1].getData();\n+ t.is(await pages[1].getOutputPath(), \"./dist/paged/page-1/index.html\");\n+ t.is(page1Data.pagination.firstPageLink, \"/paged/page-0/index.html\");\n+ t.is(page1Data.pagination.lastPageLink, \"/paged/page-1/index.html\");\n+});\n+\n+test(\"Permalink first and last page link with pagination variables (numeric, one indexed)\", async t => {\n+ let tmpl = new Template(\n+ \"./test/stubs/paged/pagedpermalinknumericoneindexed.njk\",\n+ \"./test/stubs/\",\n+ \"./dist\"\n+ );\n+\n+ let data = await tmpl.getData();\n+ let paging = new Pagination(data);\n+ paging.setTemplate(tmpl);\n+ let pages = await paging.getPageTemplates();\n+\n+ let page0Data = await pages[0].getData();\n+ t.is(await pages[0].getOutputPath(), \"./dist/paged/page-1/index.html\");\n+ t.is(page0Data.pagination.firstPageLink, \"/paged/page-1/index.html\");\n+ t.is(page0Data.pagination.lastPageLink, \"/paged/page-2/index.html\");\n+\n+ let page1Data = await pages[1].getData();\n+ t.is(page0Data.pagination.firstPageLink, \"/paged/page-1/index.html\");\n+ t.is(page0Data.pagination.lastPageLink, \"/paged/page-2/index.html\");\n+});\n+\ntest(\"Alias to page data\", async t => {\nlet tmpl = new Template(\n\"./test/stubs/paged/pagedalias.njk\",\n" } ]
JavaScript
MIT License
11ty/eleventy
Added two helper variables to the Pagination plugin Changes to Pagination: * Added firstPageLink * Added lastPageLink
699
19.11.2018 17:30:10
21,600
87f725ef9d8846788fa6dae11e589c235499b95d
Adds first and page href shortcuts for pagination. Related to
[ { "change_type": "MODIFY", "old_path": "src/Plugins/Pagination.js", "new_path": "src/Plugins/Pagination.js", "diff": "@@ -194,6 +194,11 @@ Pagination.prototype.getPageTemplates = async function() {\noverrides[pageNumber].pagination.nextPageHref =\npageNumber < templates.length - 1 ? hrefs[pageNumber + 1] : null;\n+ overrides[pageNumber].pagination.firstPageHref =\n+ hrefs.length > 0 ? hrefs[0] : null;\n+ overrides[pageNumber].pagination.lastPageHref =\n+ hrefs.length > 0 ? hrefs[hrefs.length - 1] : null;\n+\noverrides[pageNumber].pagination.hrefs = hrefs;\ncloned.setPaginationData(overrides[pageNumber]);\n" }, { "change_type": "MODIFY", "old_path": "test/PaginationTest.js", "new_path": "test/PaginationTest.js", "diff": "@@ -174,6 +174,10 @@ test(\"Permalink with pagination variables (numeric)\", async t => {\nlet pages = await paging.getPageTemplates();\nlet page0Data = await pages[0].getData();\n+ t.truthy(page0Data.pagination.firstPageLink);\n+ t.truthy(page0Data.pagination.firstPageHref);\n+ t.truthy(page0Data.pagination.lastPageLink);\n+ t.truthy(page0Data.pagination.lastPageHref);\nt.is(await pages[0].getOutputPath(), \"./dist/paged/page-0/index.html\");\nt.falsy(page0Data.pagination.previousPageLink);\nt.is(page0Data.pagination.nextPageLink, \"/paged/page-1/index.html\");\n" } ]
JavaScript
MIT License
11ty/eleventy
Adds first and page href shortcuts for pagination. Related to #312, #285
699
20.11.2018 08:42:07
21,600
bc707ad3e768208aeffd2286b01ed77dc37f9346
Fixes (switches away from experiment to a top level configuration option)
[ { "change_type": "MODIFY", "old_path": "src/Template.js", "new_path": "src/Template.js", "diff": "@@ -212,7 +212,7 @@ class Template extends TemplateContent {\n);\n}\n- let mergedData = TemplateData.mergeExperiment(\n+ let mergedData = TemplateData.mergeDeep(\nthis.config,\n{},\nmergedLayoutData,\n@@ -226,7 +226,7 @@ class Template extends TemplateContent {\nthis.dataCache = mergedData;\n}\n- return TemplateData.mergeExperiment(\n+ return TemplateData.mergeDeep(\nthis.config,\n{},\nthis.dataCache,\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateData.js", "new_path": "src/TemplateData.js", "diff": "@@ -183,7 +183,7 @@ class TemplateData {\n}\nfor (let path of localDataPaths) {\nlet dataForPath = await this.getDataValue(path, null, true);\n- TemplateData.mergeExperiment(this.config, localData, dataForPath);\n+ TemplateData.mergeDeep(this.config, localData, dataForPath);\n// debug(\"`combineLocalData` (iterating) for %o: %O\", path, localData);\n}\nreturn localData;\n@@ -293,8 +293,8 @@ class TemplateData {\nreturn lodashUniq(paths).reverse();\n}\n- static mergeExperiment(config, target, ...source) {\n- if (config.experiments.has(\"DATA_DEEP_MERGE\")) {\n+ static mergeDeep(config, target, ...source) {\n+ if (config.dataDeepMerge) {\nreturn TemplateData.merge(target, ...source);\n} else {\nreturn Object.assign(target, ...source);\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateLayout.js", "new_path": "src/TemplateLayout.js", "diff": "@@ -86,7 +86,7 @@ class TemplateLayout extends TemplateContent {\n}\n// Deep merge of layout front matter\n- let data = TemplateData.mergeExperiment(this.config, {}, ...dataToMerge);\n+ let data = TemplateData.mergeDeep(this.config, {}, ...dataToMerge);\ndelete data[this.config.keys.layout];\nthis.dataCache = data;\n" }, { "change_type": "MODIFY", "old_path": "src/UserConfig.js", "new_path": "src/UserConfig.js", "diff": "@@ -437,6 +437,10 @@ class UserConfig {\nthis.experiments.add(key);\n}\n+ setDataDeepMerge(deepMerge) {\n+ this.dataDeepMerge = !!deepMerge;\n+ }\n+\ngetMergingConfigObject() {\nreturn {\ntemplateFormats: this.templateFormats,\n@@ -464,6 +468,7 @@ class UserConfig {\nlibraryOverrides: this.libraryOverrides,\ndynamicPermalinks: this.dynamicPermalinks,\nuseGitIgnore: this.useGitIgnore,\n+ dataDeepMerge: this.dataDeepMerge,\nexperiments: this.experiments\n};\n}\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateTest.js", "new_path": "test/TemplateTest.js", "diff": "@@ -1169,7 +1169,7 @@ test(\"Front matter date with quotes (njk), issue #258\", async t => {\ntest(\"Data Cascade (Deep merge)\", async t => {\nlet newConfig = Object.assign({}, config);\n- newConfig.experiments = new Set([\"DATA_DEEP_MERGE\"]);\n+ newConfig.dataDeepMerge = true;\nlet dataObj = new TemplateData();\ndataObj._setConfig(newConfig);\n@@ -1230,7 +1230,7 @@ test(\"Data Cascade (Shallow merge)\", async t => {\ntest(\"Data Cascade Tag Merge (Deep merge)\", async t => {\nlet newConfig = Object.assign({}, config);\n- newConfig.experiments = new Set([\"DATA_DEEP_MERGE\"]);\n+ newConfig.dataDeepMerge = true;\nlet dataObj = new TemplateData();\ndataObj._setConfig(newConfig);\n" } ]
JavaScript
MIT License
11ty/eleventy
Fixes #147 (switches away from experiment to a top level configuration option)
699
21.11.2018 17:33:56
21,600
eadea6626c68f3140a2dbc32f07839f865684d75
Normalize on .11ty.js
[ { "change_type": "MODIFY", "old_path": "test/TemplateRenderJavaScriptTest.js", "new_path": "test/TemplateRenderJavaScriptTest.js", "diff": "@@ -3,19 +3,22 @@ import TemplateRender from \"../src/TemplateRender\";\ntest(\"JS\", t => {\nt.is(new TemplateRender(\"js\").getEngineName(), \"js\");\n- t.is(new TemplateRender(\"./test/stubs/filename.js\").getEngineName(), \"js\");\n+ t.is(\n+ new TemplateRender(\"./test/stubs/filename.11ty.js\").getEngineName(),\n+ \"js\"\n+ );\n});\ntest(\"JS Render a string (no data)\", async t => {\nlet fn = await new TemplateRender(\n- \"../../test/stubs/string.js\"\n+ \"../../test/stubs/string.11ty.js\"\n).getCompiledTemplate();\nt.is(await fn({ name: \"Bill\" }), \"<p>Zach</p>\");\n});\ntest(\"JS Render a function\", async t => {\nlet fn = await new TemplateRender(\n- \"../../test/stubs/template-literal.js\"\n+ \"../../test/stubs/template-literal.11ty.js\"\n).getCompiledTemplate();\nt.is(await fn({ name: \"Zach\" }), \"<p>Zach</p>\");\nt.is(await fn({ name: \"Bill\" }), \"<p>Bill</p>\");\n@@ -23,7 +26,7 @@ test(\"JS Render a function\", async t => {\ntest(\"JS Render with a Class\", async t => {\nlet fn = await new TemplateRender(\n- \"../../test/stubs/class-template-literal.js\"\n+ \"../../test/stubs/class-template-literal.11ty.js\"\n).getCompiledTemplate();\nt.is(await fn({ name: \"Zach\" }), \"<p>Zach</p>\");\nt.is(await fn({ name: \"Bill\" }), \"<p>Bill</p>\");\n@@ -31,7 +34,7 @@ test(\"JS Render with a Class\", async t => {\ntest(\"JS Render with a Class, async render\", async t => {\nlet fn = await new TemplateRender(\n- \"../../test/stubs/class-template-literal-async.js\"\n+ \"../../test/stubs/class-template-literal-async.11ty.js\"\n).getCompiledTemplate();\nt.is(await fn({ name: \"Zach\" }), \"<p>Zach</p>\");\nt.is(await fn({ name: \"Bill\" }), \"<p>Bill</p>\");\n@@ -39,7 +42,7 @@ test(\"JS Render with a Class, async render\", async t => {\ntest(\"JS Render with a Class and Data getter\", async t => {\nlet fn = await new TemplateRender(\n- \"../../test/stubs/class-template-literal-data.js\"\n+ \"../../test/stubs/class-template-literal-data.11ty.js\"\n).getCompiledTemplate();\nt.is(await fn(), \"<p>Ted</p>\");\nt.is(await fn({ name: \"Bill\" }), \"<p>Ted</p>\");\n@@ -47,7 +50,7 @@ test(\"JS Render with a Class and Data getter\", async t => {\ntest(\"JS Render with a Class and Data function\", async t => {\nlet fn = await new TemplateRender(\n- \"../../test/stubs/class-template-literal-data-fn.js\"\n+ \"../../test/stubs/class-template-literal-data-fn.11ty.js\"\n).getCompiledTemplate();\nt.is(await fn(), \"<p>Ted</p>\");\nt.is(await fn({ name: \"Bill\" }), \"<p>Ted</p>\");\n@@ -55,7 +58,7 @@ test(\"JS Render with a Class and Data function\", async t => {\ntest(\"JS Render using Vue\", async t => {\nlet fn = await new TemplateRender(\n- \"../../test/stubs/vue.js\"\n+ \"../../test/stubs/vue.11ty.js\"\n).getCompiledTemplate();\nt.is(\nawait fn({ name: \"Zach\" }),\n@@ -69,7 +72,7 @@ test(\"JS Render using Vue\", async t => {\ntest(\"JS Render using Vue (with a layout)\", async t => {\nlet fn = await new TemplateRender(\n- \"../../test/stubs/vue-layout.js\"\n+ \"../../test/stubs/vue-layout.11ty.js\"\n).getCompiledTemplate();\nt.is(\nawait fn({ name: \"Zach\" }),\n@@ -81,7 +84,7 @@ test(\"JS Render using Vue (with a layout)\", async t => {\ntest(\"JS Render using ViperHTML\", async t => {\nlet fn = await new TemplateRender(\n- \"../../test/stubs/viperhtml.js\"\n+ \"../../test/stubs/viperhtml.11ty.js\"\n).getCompiledTemplate();\nt.is(\nawait fn({ name: \"Zach\", html: \"<strong>Hi</strong>\" }),\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateRenderTest.js", "new_path": "test/TemplateRenderTest.js", "diff": "@@ -15,7 +15,7 @@ test(t => {\nt.true(TemplateRender.hasEngine(\"ejs\"));\nt.is(new TemplateRender(\"ejs\").getEngineName(), \"ejs\");\n- t.is(TemplateRender.cleanupEngineName(\"sldkjfkldsj\"), \"sldkjfkldsj\");\n+ t.falsy(TemplateRender.cleanupEngineName(\"sldkjfkldsj\"));\nt.false(TemplateRender.hasEngine(\"sldkjfkldsj\"));\n});\n" }, { "change_type": "RENAME", "old_path": "test/stubs/class-template-literal-async.js", "new_path": "test/stubs/class-template-literal-async.11ty.js", "diff": "" }, { "change_type": "RENAME", "old_path": "test/stubs/class-template-literal-data-fn.js", "new_path": "test/stubs/class-template-literal-data-fn.11ty.js", "diff": "" }, { "change_type": "RENAME", "old_path": "test/stubs/class-template-literal-data.js", "new_path": "test/stubs/class-template-literal-data.11ty.js", "diff": "" }, { "change_type": "RENAME", "old_path": "test/stubs/class-template-literal.js", "new_path": "test/stubs/class-template-literal.11ty.js", "diff": "" }, { "change_type": "RENAME", "old_path": "test/stubs/string.js", "new_path": "test/stubs/string.11ty.js", "diff": "" }, { "change_type": "RENAME", "old_path": "test/stubs/template-literal.js", "new_path": "test/stubs/template-literal.11ty.js", "diff": "" }, { "change_type": "RENAME", "old_path": "test/stubs/viperhtml.js", "new_path": "test/stubs/viperhtml.11ty.js", "diff": "" }, { "change_type": "RENAME", "old_path": "test/stubs/vue-layout.js", "new_path": "test/stubs/vue-layout.11ty.js", "diff": "" }, { "change_type": "RENAME", "old_path": "test/stubs/vue.js", "new_path": "test/stubs/vue.11ty.js", "diff": "" } ]
JavaScript
MIT License
11ty/eleventy
Normalize on .11ty.js
699
21.11.2018 18:18:23
21,600
ec7f468d9acd3e2e72d92ae288227bd4370ad9f1
Consolidate lodash to a single module
[ { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "\"is-plain-object\": \"^2.0.4\",\n\"javascript-stringify\": \"^1.6.0\",\n\"liquidjs\": \"^6.0.1\",\n- \"lodash.chunk\": \"^4.2.0\",\n- \"lodash.clone\": \"^4.5.0\",\n- \"lodash.get\": \"^4.4.2\",\n- \"lodash.isobject\": \"^3.0.2\",\n- \"lodash.merge\": \"^4.6.1\",\n- \"lodash.set\": \"^4.3.2\",\n- \"lodash.uniq\": \"^4.5.0\",\n+ \"lodash\": \"^4.17.11\",\n\"luxon\": \"^1.4.1\",\n\"markdown-it\": \"^8.4.2\",\n\"minimist\": \"^1.2.0\",\n" }, { "change_type": "MODIFY", "old_path": "src/Plugins/Pagination.js", "new_path": "src/Plugins/Pagination.js", "diff": "-const lodashChunk = require(\"lodash.chunk\");\n-const lodashGet = require(\"lodash.get\");\n-const lodashSet = require(\"lodash.set\");\n+const lodashChunk = require(\"lodash/chunk\");\n+const lodashGet = require(\"lodash/get\");\n+const lodashSet = require(\"lodash/set\");\nconst config = require(\"../Config\");\nfunction Pagination(data) {\n" }, { "change_type": "MODIFY", "old_path": "src/Template.js", "new_path": "src/Template.js", "diff": "const fs = require(\"fs-extra\");\nconst parsePath = require(\"parse-filepath\");\nconst normalize = require(\"normalize-path\");\n-const lodashIsObject = require(\"lodash.isobject\");\n+const lodashIsObject = require(\"lodash/isobject\");\nconst { DateTime } = require(\"luxon\");\nconst TemplateData = require(\"./TemplateData\");\nconst TemplateContent = require(\"./TemplateContent\");\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateConfig.js", "new_path": "src/TemplateConfig.js", "diff": "const fs = require(\"fs-extra\");\nconst chalk = require(\"chalk\");\n-const lodashMerge = require(\"lodash.merge\");\n+const lodashMerge = require(\"lodash/merge\");\nconst TemplatePath = require(\"./TemplatePath\");\nconst EleventyBaseError = require(\"./EleventyBaseError\");\nconst eleventyConfig = require(\"./EleventyConfig\");\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateData.js", "new_path": "src/TemplateData.js", "diff": "const fs = require(\"fs-extra\");\nconst fastglob = require(\"fast-glob\");\nconst parsePath = require(\"parse-filepath\");\n-const lodashset = require(\"lodash.set\");\n-const lodashUniq = require(\"lodash.uniq\");\n+const lodashset = require(\"lodash/set\");\n+const lodashUniq = require(\"lodash/uniq\");\nconst merge = require(\"./Util/Merge\");\nconst TemplateRender = require(\"./TemplateRender\");\nconst TemplatePath = require(\"./TemplatePath\");\n" } ]
JavaScript
MIT License
11ty/eleventy
Consolidate lodash to a single module
699
21.11.2018 18:18:45
21,600
af8a635f85a45328c8936fb3837af08c4e697965
Updated deps (minor)
[ { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "{\n\"name\": \"@11ty/eleventy\",\n- \"version\": \"0.5.4\",\n+ \"version\": \"0.6.0\",\n\"description\": \"Transform a directory of templates into HTML.\",\n\"main\": \"src/Eleventy.js\",\n\"license\": \"MIT\",\n\"multimatch\": \"^2.1.0\",\n\"mustache\": \"^2.3.0\",\n\"normalize-path\": \"^3.0.0\",\n- \"nunjucks\": \"^3.1.3\",\n+ \"nunjucks\": \"^3.1.4\",\n\"parse-filepath\": \"^1.0.2\",\n\"please-upgrade-node\": \"^3.1.1\",\n\"pretty\": \"^2.0.0\",\n" }, { "change_type": "MODIFY", "old_path": "src/TemplatePassthrough.js", "new_path": "src/TemplatePassthrough.js", "diff": "const copy = require(\"recursive-copy\");\nconst TemplatePath = require(\"./TemplatePath\");\n-// const debug = require(\"debug\")(\"Eleventy:TemplatePassthrough\");\n+const debug = require(\"debug\")(\"Eleventy:TemplatePassthrough\");\nclass TemplatePassthrough {\nconstructor(inputPath, outputDir, inputDir) {\n@@ -29,6 +29,8 @@ class TemplatePassthrough {\n// );\nif (!this.isDryRun) {\n+ debug(\"Copying %o\", this.path);\n+\nreturn copy(this.path, this.getOutputPath(), {\noverwrite: true,\ndot: true,\n" }, { "change_type": "MODIFY", "old_path": "src/TemplatePassthroughManager.js", "new_path": "src/TemplatePassthroughManager.js", "diff": "@@ -43,9 +43,11 @@ class TemplatePassthroughManager {\nlet paths = [];\nlet target = this.config.passthroughCopies || {};\n+ debug(\"`passthroughFileCopy` config paths: %o\", target);\nfor (let path in target) {\npaths.push(TemplatePath.addLeadingDotSlash(path));\n}\n+ debug(\"`passthroughFileCopy` config normalized paths: %o\", paths);\nreturn paths;\n}\n" } ]
JavaScript
MIT License
11ty/eleventy
Updated deps (minor)
699
21.11.2018 20:48:18
21,600
378b1230336e42aa49f05e72c04a1eca8763e56b
Travis is case sensitive with files
[ { "change_type": "MODIFY", "old_path": "src/Template.js", "new_path": "src/Template.js", "diff": "const fs = require(\"fs-extra\");\nconst parsePath = require(\"parse-filepath\");\nconst normalize = require(\"normalize-path\");\n-const lodashIsObject = require(\"lodash/isobject\");\n+const lodashIsObject = require(\"lodash/isObject\");\nconst { DateTime } = require(\"luxon\");\nconst TemplateData = require(\"./TemplateData\");\nconst TemplateContent = require(\"./TemplateContent\");\n" }, { "change_type": "MODIFY", "old_path": "src/Util/Merge.js", "new_path": "src/Util/Merge.js", "diff": "+// TODO: switch to lodash/isPlainObject\nconst isPlainObject = require(\"is-plain-object\");\nconst OVERRIDE_PREFIX = \"override:\";\n" } ]
JavaScript
MIT License
11ty/eleventy
Travis is case sensitive with files
699
21.11.2018 21:15:02
21,600
e84e957e3f362a9a49460f919d743e352b5bb2a6
Fixes dataDeepMerge: true with pagination data. See
[ { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "\"gray-matter\": \"^4.0.1\",\n\"hamljs\": \"^0.6.2\",\n\"handlebars\": \"^4.0.12\",\n- \"is-plain-object\": \"^2.0.4\",\n\"javascript-stringify\": \"^1.6.0\",\n\"liquidjs\": \"^6.0.1\",\n\"lodash\": \"^4.17.11\",\n" }, { "change_type": "MODIFY", "old_path": "src/Util/Merge.js", "new_path": "src/Util/Merge.js", "diff": "-// TODO: switch to lodash/isPlainObject\n-const isPlainObject = require(\"is-plain-object\");\n+const isPlainObject = require(\"lodash/isPlainObject\");\nconst OVERRIDE_PREFIX = \"override:\";\nfunction getMergedItem(target, source, parentKey) {\n" }, { "change_type": "MODIFY", "old_path": "test/PaginationTest.js", "new_path": "test/PaginationTest.js", "diff": "@@ -521,3 +521,41 @@ test(\"Page over an object (filtered, string)\", async t => {\n\"<ol><li>item6</li><li>item7</li><li>item8</li><li>item9</li></ol>\"\n);\n});\n+\n+test(\"Pagination with deep data merge #147\", async t => {\n+ let tmpl = new Template(\n+ \"./test/stubs/paged/pagedinlinedata.njk\",\n+ \"./test/stubs/\",\n+ \"./dist\"\n+ );\n+ tmpl._setConfig({\n+ keys: {\n+ layout: \"layout\"\n+ },\n+ dataDeepMerge: true\n+ });\n+\n+ let data = await tmpl.getData();\n+ let paging = new Pagination(data);\n+ paging.setTemplate(tmpl);\n+ let pages = await paging.getPageTemplates();\n+ t.is(pages.length, 2);\n+\n+ t.is(\n+ await pages[0].getOutputPath(),\n+ \"./dist/paged/pagedinlinedata/index.html\"\n+ );\n+ t.is(\n+ (await pages[0].render()).trim(),\n+ \"<ol><li>item1</li><li>item2</li><li>item3</li><li>item4</li></ol>\"\n+ );\n+\n+ t.is(\n+ await pages[1].getOutputPath(),\n+ \"./dist/paged/pagedinlinedata/1/index.html\"\n+ );\n+ t.is(\n+ (await pages[1].render()).trim(),\n+ \"<ol><li>item5</li><li>item6</li><li>item7</li><li>item8</li></ol>\"\n+ );\n+});\n" } ]
JavaScript
MIT License
11ty/eleventy
Fixes dataDeepMerge: true with pagination data. See https://github.com/11ty/eleventy/issues/147#issuecomment-440802454
699
22.11.2018 13:44:35
21,600
5922547af4a6a9204aaee39687762d63b5784681
Additional test for using pagination aliasing
[ { "change_type": "MODIFY", "old_path": "test/PaginationTest.js", "new_path": "test/PaginationTest.js", "diff": "@@ -559,3 +559,29 @@ test(\"Pagination with deep data merge #147\", async t => {\n\"<ol><li>item5</li><li>item6</li><li>item7</li><li>item8</li></ol>\"\n);\n});\n+\n+test(\"Pagination with deep data merge with alias #147\", async t => {\n+ let tmpl = new Template(\n+ \"./test/stubs/paged/pagedalias.njk\",\n+ \"./test/stubs/\",\n+ \"./dist\"\n+ );\n+ tmpl._setConfig({\n+ keys: {\n+ layout: \"layout\",\n+ permalink: \"permalink\"\n+ },\n+ dynamicPermalinks: true,\n+ dataDeepMerge: true\n+ });\n+\n+ let data = await tmpl.getData();\n+ let paging = new Pagination(data);\n+ paging.setTemplate(tmpl);\n+ let pages = await paging.getPageTemplates();\n+ t.is(await pages[0].getOutputPath(), \"./dist/pagedalias/item1/index.html\");\n+ t.is(await pages[1].getOutputPath(), \"./dist/pagedalias/item2/index.html\");\n+\n+ t.is((await pages[0].render()).trim(), \"item1\");\n+ t.is((await pages[1].render()).trim(), \"item2\");\n+});\n" } ]
JavaScript
MIT License
11ty/eleventy
Additional test for #147 using pagination aliasing
699
25.11.2018 21:25:06
21,600
dc666fd8793bcbe949fe4aa9f1e28b9b34ce048e
Switch to `11ty.js` for key so as not to conflict with existing `js` passthrough copies
[ { "change_type": "MODIFY", "old_path": "config.js", "new_path": "config.js", "diff": "@@ -16,7 +16,8 @@ module.exports = function(config) {\n\"pug\",\n\"njk\",\n\"html\",\n- \"jstl\"\n+ \"jstl\",\n+ \"11ty.js\"\n],\n// if your site lives in a subdirectory, change this\npathPrefix: \"/\",\n@@ -25,6 +26,7 @@ module.exports = function(config) {\ndataTemplateEngine: \"liquid\",\npassthroughFileCopy: true,\nhtmlOutputSuffix: \"-o\",\n+ jsTemplateFileSuffix: \".11ty\",\njsDataFileSuffix: \".11tydata\",\nkeys: {\npackage: \"pkg\",\n" }, { "change_type": "MODIFY", "old_path": "src/EleventyExtensionMap.js", "new_path": "src/EleventyExtensionMap.js", "diff": "@@ -42,33 +42,45 @@ class EleventyExtensionMap {\n}\n_getGlobs(formats, inputDir) {\n+ let dir = TemplatePath.convertToGlob(inputDir);\nreturn formats.map(\nfunction(key) {\nreturn (\n- TemplatePath.convertToGlob(inputDir) +\n- \"/*.\" +\n- (this.hasExtension(key) ? this.getExtension(key) : key)\n+ dir + \"/*.\" + (this.hasExtension(key) ? this.getExtension(key) : key)\n);\n}.bind(this)\n);\n}\nhasExtension(key) {\n- return key in this.keyMapToExtension;\n+ for (var extension in EleventyExtensionMap.keyMap) {\n+ if (EleventyExtensionMap.keyMap[extension] === key) {\n+ return true;\n+ }\n+ }\n+ return false;\n}\ngetExtension(key) {\n- return this.keyMapToExtension[key];\n+ for (var extension in EleventyExtensionMap.keyMap) {\n+ if (EleventyExtensionMap.keyMap[extension] === key) {\n+ return extension;\n+ }\n+ }\n}\nstatic getExtensionFromKey(key) {\n- return EleventyExtensionMap.keyMap[key];\n+ for (var extension in EleventyExtensionMap.keyMap) {\n+ if (EleventyExtensionMap.keyMap[extension] === key) {\n+ return extension;\n+ }\n+ }\n}\nstatic getExtensionFromPath(path) {\n- for (var key in EleventyExtensionMap.keyMap) {\n- if (path.endsWith(\".\" + EleventyExtensionMap.keyMap[key])) {\n- return EleventyExtensionMap.keyMap[key];\n+ for (var extension in EleventyExtensionMap.keyMap) {\n+ if (path.endsWith(\".\" + extension)) {\n+ return extension;\n}\n}\n}\n@@ -76,33 +88,31 @@ class EleventyExtensionMap {\nstatic getKey(pathOrKey) {\npathOrKey = pathOrKey.toLowerCase();\n- let hasDot = pathOrKey.indexOf(\".\") > -1;\n- for (var key in EleventyExtensionMap.keyMap) {\n- if (!hasDot && pathOrKey === key) {\n+ for (var extension in EleventyExtensionMap.keyMap) {\n+ let key = EleventyExtensionMap.keyMap[extension];\n+ if (pathOrKey === extension) {\nreturn key;\n- } else if (pathOrKey.endsWith(\".\" + EleventyExtensionMap.keyMap[key])) {\n+ } else if (pathOrKey.endsWith(\".\" + extension)) {\nreturn key;\n}\n}\n}\nstatic removeTemplateExtension(path) {\n- for (var key in EleventyExtensionMap.keyMap) {\n- if (path.endsWith(EleventyExtensionMap.keyMap[key])) {\n- return path.substr(\n- 0,\n- path.length - 1 - EleventyExtensionMap.keyMap[key].length\n- );\n+ for (var extension in EleventyExtensionMap.keyMap) {\n+ if (path === extension || path.endsWith(\".\" + extension)) {\n+ return path.substr(0, path.length - 1 - extension.length);\n}\n}\nreturn path;\n}\n- // key => file extension\n+ // file extension => key\nstatic get keyMap() {\n- return {\n+ let fileExtensionToKeyMap = {\nejs: \"ejs\",\nmd: \"md\",\n+ markdown: \"md\",\njstl: \"jstl\",\nhtml: \"html\",\nhbs: \"hbs\",\n@@ -110,13 +120,15 @@ class EleventyExtensionMap {\nhaml: \"haml\",\npug: \"pug\",\nnjk: \"njk\",\n- liquid: \"liquid\",\n- js: \"11ty.js\"\n+ liquid: \"liquid\"\n};\n- }\n- get keyMapToExtension() {\n- return EleventyExtensionMap.keyMap;\n+ let jsSuffix = TemplatePath.stripLeadingDots(\n+ config.getConfig().jsTemplateFileSuffix + \".js\"\n+ );\n+ fileExtensionToKeyMap[jsSuffix] = \"11ty.js\";\n+\n+ return fileExtensionToKeyMap;\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "src/Engines/TemplateEngine.js", "new_path": "src/Engines/TemplateEngine.js", "diff": "@@ -90,7 +90,7 @@ class TemplateEngine {\npug: \"Pug\",\nnjk: \"Nunjucks\",\nliquid: \"Liquid\",\n- js: \"JavaScript\"\n+ \"11ty.js\": \"JavaScript\"\n};\n}\n" }, { "change_type": "MODIFY", "old_path": "src/Template.js", "new_path": "src/Template.js", "diff": "@@ -3,6 +3,8 @@ const parsePath = require(\"parse-filepath\");\nconst normalize = require(\"normalize-path\");\nconst lodashIsObject = require(\"lodash/isObject\");\nconst { DateTime } = require(\"luxon\");\n+\n+const EleventyExtensionMap = require(\"./EleventyExtensionMap\");\nconst TemplateData = require(\"./TemplateData\");\nconst TemplateContent = require(\"./TemplateContent\");\nconst TemplatePath = require(\"./TemplatePath\");\n@@ -20,6 +22,9 @@ class Template extends TemplateContent {\nsuper(path, inputDir);\nthis.parsed = parsePath(path);\n+ this.baseFile = EleventyExtensionMap.removeTemplateExtension(\n+ this.parsed.base\n+ );\n// for pagination\nthis.extraOutputSubdirectory = \"\";\n@@ -43,7 +48,7 @@ class Template extends TemplateContent {\nthis.isHtmlIOException =\nthis.inputDir === this.outputDir &&\nthis.templateRender.isEngine(\"html\") &&\n- this.parsed.name === \"index\";\n+ this.baseFile === \"index\";\nthis.isVerbose = true;\nthis.isDryRun = false;\n@@ -108,7 +113,7 @@ class Template extends TemplateContent {\nreturn TemplatePermalink.generate(\nthis.getTemplateSubfolder(),\n- this.parsed.name,\n+ this.baseFile,\nthis.extraOutputSubdirectory,\nthis.isHtmlIOException ? this.config.htmlOutputSuffix : \"\"\n);\n" }, { "change_type": "MODIFY", "old_path": "src/TemplatePath.js", "new_path": "src/TemplatePath.js", "diff": "@@ -110,6 +110,10 @@ TemplatePath.addLeadingDotSlash = function(path) {\nreturn \"./\" + path;\n};\n+TemplatePath.stripLeadingDots = function(str) {\n+ return str.replace(/^\\.*/, \"\");\n+};\n+\nTemplatePath.stripLeadingDotSlash = function(dir) {\nreturn dir.replace(/^\\.\\//, \"\");\n};\n" }, { "change_type": "MODIFY", "old_path": "test/EleventyConfigTest.js", "new_path": "test/EleventyConfigTest.js", "diff": "@@ -53,3 +53,18 @@ test(\"Set Template Formats (array)\", t => {\neleventyConfig.setTemplateFormats([\"ejs\", \"njk\", \"liquid\"]);\nt.deepEqual(eleventyConfig.templateFormats, [\"ejs\", \"njk\", \"liquid\"]);\n});\n+\n+test(\"Set Template Formats (js passthrough copy)\", t => {\n+ eleventyConfig.setTemplateFormats(\"ejs, njk, liquid, js\");\n+ t.deepEqual(eleventyConfig.templateFormats, [\"ejs\", \"njk\", \"liquid\", \"js\"]);\n+});\n+\n+test(\"Set Template Formats (11ty.js)\", t => {\n+ eleventyConfig.setTemplateFormats(\"ejs, njk, liquid, 11ty.js\");\n+ t.deepEqual(eleventyConfig.templateFormats, [\n+ \"ejs\",\n+ \"njk\",\n+ \"liquid\",\n+ \"11ty.js\"\n+ ]);\n+});\n" }, { "change_type": "MODIFY", "old_path": "test/EleventyExtensionMapTest.js", "new_path": "test/EleventyExtensionMapTest.js", "diff": "@@ -96,9 +96,12 @@ test(\"removeTemplateExtension\", t => {\ntest(\"getKey\", t => {\nt.is(EleventyExtensionMap.getKey(\"component.njk\"), \"njk\");\n- t.is(EleventyExtensionMap.getKey(\"component.11ty.js\"), \"js\");\n+ t.is(EleventyExtensionMap.getKey(\"component.11ty.js\"), \"11ty.js\");\n+ t.is(EleventyExtensionMap.getKey(\"11ty.js\"), \"11ty.js\");\n+ t.is(EleventyExtensionMap.getKey(\".11ty.js\"), \"11ty.js\");\nt.is(EleventyExtensionMap.getKey(\"\"), undefined);\n+ t.is(EleventyExtensionMap.getKey(\"js\"), undefined);\nt.is(EleventyExtensionMap.getKey(\"component\"), undefined);\nt.is(EleventyExtensionMap.getKey(\"component.js\"), undefined);\n});\n" }, { "change_type": "MODIFY", "old_path": "test/EleventyFilesTest.js", "new_path": "test/EleventyFilesTest.js", "diff": "import test from \"ava\";\nimport fastglob from \"fast-glob\";\nimport EleventyFiles from \"../src/EleventyFiles\";\n+import TemplateRender from \"../src/TemplateRender\";\nimport TemplatePassthroughManager from \"../src/TemplatePassthroughManager\";\ntest(\"getFiles\", async t => {\n@@ -13,6 +14,41 @@ test(\"getFiles\", async t => {\nt.deepEqual(await evf.getFiles(), [\"./test/stubs/writeTest/test.md\"]);\n});\n+test(\"getFiles (without 11ty.js)\", async t => {\n+ let evf = new EleventyFiles(\n+ \"./test/stubs/writeTestJS\",\n+ \"./test/stubs/_writeTestJSSite\",\n+ [\"ejs\", \"md\"]\n+ );\n+\n+ t.deepEqual(await evf.getFiles(), []);\n+});\n+\n+test(\"getFiles (with 11ty.js)\", async t => {\n+ let evf = new EleventyFiles(\n+ \"./test/stubs/writeTestJS\",\n+ \"./test/stubs/_writeTestJSSite\",\n+ [\"ejs\", \"md\", \"11ty.js\"]\n+ );\n+\n+ t.deepEqual(await evf.getFiles(), [\"./test/stubs/writeTestJS/test.11ty.js\"]);\n+});\n+\n+test(\"getFiles (with js, treated as passthrough copy)\", async t => {\n+ let evf = new EleventyFiles(\n+ \"./test/stubs/writeTestJS\",\n+ \"./test/stubs/_writeTestJSSite\",\n+ [\"ejs\", \"md\", \"js\"]\n+ );\n+\n+ t.deepEqual(await evf.getFiles(), [\n+ \"./test/stubs/writeTestJS/sample.js\",\n+ \"./test/stubs/writeTestJS/test.11ty.js\"\n+ ]);\n+ t.false(TemplateRender.hasEngine(\"./test/stubs/writeTestJS/sample.js\"));\n+ t.true(TemplateRender.hasEngine(\"./test/stubs/writeTestJS/test.11ty.js\"));\n+});\n+\ntest(\"Mutually exclusive Input and Output dirs\", async t => {\nlet evf = new EleventyFiles(\n\"./test/stubs/writeTest\",\n" }, { "change_type": "MODIFY", "old_path": "test/TemplatePathTest.js", "new_path": "test/TemplatePathTest.js", "diff": "@@ -198,3 +198,12 @@ test(\"Remove extension\", t => {\n\"./test/stubs\"\n);\n});\n+\n+test(\"stripLeadingDots\", t => {\n+ t.is(TemplatePath.stripLeadingDots(\".11ty.js\"), \"11ty.js\");\n+ t.is(TemplatePath.stripLeadingDots(\".htaccess\"), \"htaccess\");\n+\n+ t.is(TemplatePath.stripLeadingDots(\"./dist\"), \"/dist\");\n+ t.is(TemplatePath.stripLeadingDots(\"../dist\"), \"/dist\");\n+ t.is(TemplatePath.stripLeadingDots(\"dist\"), \"dist\");\n+});\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateRenderJavaScriptTest.js", "new_path": "test/TemplateRenderJavaScriptTest.js", "diff": "@@ -2,10 +2,10 @@ import test from \"ava\";\nimport TemplateRender from \"../src/TemplateRender\";\ntest(\"JS\", t => {\n- t.is(new TemplateRender(\"js\").getEngineName(), \"js\");\n+ t.is(new TemplateRender(\"11ty.js\").getEngineName(), \"11ty.js\");\nt.is(\nnew TemplateRender(\"./test/stubs/filename.11ty.js\").getEngineName(),\n- \"js\"\n+ \"11ty.js\"\n);\n});\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateWriterTest.js", "new_path": "test/TemplateWriterTest.js", "diff": "@@ -435,3 +435,25 @@ test.skip(\"renderData should exist and be resolved in a collection (Issue #289)\"\nlet templates = await mapEntry.template.getRenderedTemplates(mapEntry.data);\nt.is(templates[0].templateContent.trim(), \"Test Title\");\n});\n+\n+test(\"Write Test 11ty.js\", async t => {\n+ let tw = new TemplateWriter(\n+ \"./test/stubs/writeTestJS\",\n+ \"./test/stubs/_writeTestJSSite\"\n+ );\n+ let evf = new EleventyFiles(\n+ \"./test/stubs/writeTestJS\",\n+ \"./test/stubs/_writeTestJSSite\",\n+ [\"11ty.js\"]\n+ );\n+\n+ let files = await fastglob.async(evf.getFileGlobs());\n+ t.deepEqual(evf.getRawFiles(), [\"./test/stubs/writeTestJS/**/*.11ty.js\"]);\n+ t.deepEqual(files, [\"./test/stubs/writeTestJS/test.11ty.js\"]);\n+\n+ let tmpl = tw._createTemplate(files[0]);\n+ t.is(\n+ await tmpl.getOutputPath(),\n+ \"./test/stubs/_writeTestJSSite/test/index.html\"\n+ );\n+});\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/writeTestJS/sample.js", "diff": "+module.exports = \"<p>Zach</p>\";\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/writeTestJS/test.11ty.js", "diff": "+module.exports = \"<p>Zach</p>\";\n" } ]
JavaScript
MIT License
11ty/eleventy
Switch to `11ty.js` for key so as not to conflict with existing `js` passthrough copies
699
29.11.2018 21:36:40
21,600
987159cc18ecaadc33506a28dc114c4393ee26bd
Move config refs into TemplateEngine
[ { "change_type": "MODIFY", "old_path": "src/Engines/Ejs.js", "new_path": "src/Engines/Ejs.js", "diff": "@@ -9,7 +9,6 @@ class Ejs extends TemplateEngine {\nthis.ejsOptions = {};\n- this.config = config.getConfig();\nthis.setLibrary(this.config.libraryOverrides.ejs);\nthis.setEjsOptions(this.config.ejsOptions);\n}\n" }, { "change_type": "MODIFY", "old_path": "src/Engines/Haml.js", "new_path": "src/Engines/Haml.js", "diff": "@@ -6,7 +6,6 @@ class Haml extends TemplateEngine {\nconstructor(name, inputDir) {\nsuper(name, inputDir);\n- this.config = config.getConfig();\nthis.setLibrary(this.config.libraryOverrides.haml);\n}\n" }, { "change_type": "MODIFY", "old_path": "src/Engines/Handlebars.js", "new_path": "src/Engines/Handlebars.js", "diff": "@@ -6,7 +6,6 @@ class Handlebars extends TemplateEngine {\nconstructor(name, inputDir) {\nsuper(name, inputDir);\n- this.config = config.getConfig();\nthis.setLibrary(this.config.libraryOverrides.hbs);\n}\n" }, { "change_type": "MODIFY", "old_path": "src/Engines/Liquid.js", "new_path": "src/Engines/Liquid.js", "diff": "@@ -7,7 +7,6 @@ class Liquid extends TemplateEngine {\nconstructor(name, inputDir) {\nsuper(name, inputDir);\n- this.config = config.getConfig();\nthis.liquidOptions = {};\nthis.setLibrary(this.config.libraryOverrides.liquid);\n" }, { "change_type": "MODIFY", "old_path": "src/Engines/Markdown.js", "new_path": "src/Engines/Markdown.js", "diff": "@@ -9,7 +9,6 @@ class Markdown extends TemplateEngine {\nthis.markdownOptions = {};\n- this.config = config.getConfig();\nthis.setLibrary(this.config.libraryOverrides.md);\n}\n" }, { "change_type": "MODIFY", "old_path": "src/Engines/Mustache.js", "new_path": "src/Engines/Mustache.js", "diff": "@@ -6,7 +6,6 @@ class Mustache extends TemplateEngine {\nconstructor(name, inputDir) {\nsuper(name, inputDir);\n- this.config = config.getConfig();\nthis.setLibrary(this.config.libraryOverrides.mustache);\n}\n" }, { "change_type": "MODIFY", "old_path": "src/Engines/Nunjucks.js", "new_path": "src/Engines/Nunjucks.js", "diff": "@@ -6,7 +6,6 @@ class Nunjucks extends TemplateEngine {\nconstructor(name, inputDir) {\nsuper(name, inputDir);\n- this.config = config.getConfig();\nthis.setLibrary(this.config.libraryOverrides.njk);\n}\n" }, { "change_type": "MODIFY", "old_path": "src/Engines/Pug.js", "new_path": "src/Engines/Pug.js", "diff": "@@ -6,7 +6,6 @@ class Pug extends TemplateEngine {\nconstructor(name, inputDir) {\nsuper(name, inputDir);\n- this.config = config.getConfig();\nthis.pugOptions = {};\nthis.setLibrary(this.config.libraryOverrides.pug);\n" }, { "change_type": "MODIFY", "old_path": "src/Engines/TemplateEngine.js", "new_path": "src/Engines/TemplateEngine.js", "diff": "@@ -2,6 +2,7 @@ const fastglob = require(\"fast-glob\");\nconst fs = require(\"fs-extra\");\nconst TemplatePath = require(\"../TemplatePath\");\nconst EleventyExtensionMap = require(\"../EleventyExtensionMap\");\n+const config = require(\"../Config\");\nconst debug = require(\"debug\")(\"Eleventy:TemplateEngine\");\nclass TemplateEngine {\n@@ -16,6 +17,13 @@ class TemplateEngine {\nthis.engineLib = null;\n}\n+ get config() {\n+ if (!this._config) {\n+ this._config = config.getConfig();\n+ }\n+ return this._config;\n+ }\n+\ngetName() {\nreturn this.name;\n}\n" } ]
JavaScript
MIT License
11ty/eleventy
Move config refs into TemplateEngine
699
29.11.2018 22:16:29
21,600
c6c11b5d1c98f4287d37a909b07b605a9906a39b
Try out a universal filter/shortcode/helper/function on a JavaScript template.
[ { "change_type": "MODIFY", "old_path": "src/Engines/JavaScript.js", "new_path": "src/Engines/JavaScript.js", "diff": "@@ -2,6 +2,10 @@ const TemplateEngine = require(\"./TemplateEngine\");\nconst lodashMerge = require(\"lodash.merge\");\nclass JavaScript extends TemplateEngine {\n+ get javascriptFunctions() {\n+ return Object.assign({}, this.config.javascriptFunctions);\n+ }\n+\nasync compile(str, inputPath) {\nconst cls = require(inputPath);\nif (typeof cls === \"string\") {\n@@ -9,9 +13,9 @@ class JavaScript extends TemplateEngine {\nreturn cls;\n};\n} else if (typeof cls === \"function\") {\n+ let dataOverrides = {};\nif (cls.prototype && \"render\" in cls.prototype) {\nlet inst = new cls(inputPath);\n- let dataOverrides;\nif (cls.prototype && \"data\" in cls.prototype) {\n// work with getter or function\n@@ -19,8 +23,11 @@ class JavaScript extends TemplateEngine {\ntypeof inst.data === \"function\" ? inst.data() : inst.data;\n}\n+ Object.assign(dataOverrides, this.javascriptFunctions);\n+\nreturn function(data) {\nif (dataOverrides) {\n+ console.log(lodashMerge({}, data, dataOverrides));\nreturn inst.render(lodashMerge({}, data, dataOverrides));\n}\n@@ -28,8 +35,10 @@ class JavaScript extends TemplateEngine {\n};\n}\n+ Object.assign(dataOverrides, this.javascriptFunctions);\nreturn function(data) {\n- let result = cls(data || {});\n+ console.log(lodashMerge({}, data, dataOverrides));\n+ let result = cls(lodashMerge({}, data, dataOverrides));\nif (Buffer.isBuffer(result)) {\nreturn result.toString();\n}\n" }, { "change_type": "MODIFY", "old_path": "src/Engines/TemplateEngine.js", "new_path": "src/Engines/TemplateEngine.js", "diff": "@@ -24,6 +24,10 @@ class TemplateEngine {\nreturn this._config;\n}\n+ set config(config) {\n+ this._config = config;\n+ }\n+\ngetName() {\nreturn this.name;\n}\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateRender.js", "new_path": "src/TemplateRender.js", "diff": "@@ -16,7 +16,6 @@ class TemplateRender {\n);\n}\n- this.config = config.getConfig();\nthis.path = tmplPath;\nthis.extensionMap = extensionMap;\n@@ -31,6 +30,21 @@ class TemplateRender {\nthis.useMarkdown = this.engineName === \"md\";\n}\n+ get config() {\n+ if (!this._config) {\n+ this._config = config.getConfig();\n+ }\n+ return this._config;\n+ }\n+\n+ set config(config) {\n+ this._config = config;\n+\n+ if (this.engine) {\n+ this.engine.config = config;\n+ }\n+ }\n+\ninit(engineNameOrPath) {\nthis.engineName = this.cleanupEngineName(engineNameOrPath);\nif (!this.engineName) {\n" }, { "change_type": "MODIFY", "old_path": "src/UserConfig.js", "new_path": "src/UserConfig.js", "diff": "@@ -33,6 +33,7 @@ class UserConfig {\nthis.handlebarsHelpers = {};\nthis.handlebarsShortcodes = {};\nthis.handlebarsPairedShortcodes = {};\n+ this.javascriptFunctions = {};\nthis.pugOptions = {};\nthis.ejsOptions = {};\nthis.markdownHighlighter = null;\n@@ -180,6 +181,7 @@ class UserConfig {\n// namespacing happens downstream\nthis.addLiquidFilter(name, callback);\nthis.addNunjucksFilter(name, callback);\n+ this.addJavaScriptFunction(name, callback);\n// TODO remove Handlebars helpers in Universal Filters. Use shortcodes instead (the Handlebars template syntax is the same).\nthis.addHandlebarsHelper(name, callback);\n@@ -332,6 +334,7 @@ class UserConfig {\nthis.addNunjucksShortcode(name, callback);\nthis.addLiquidShortcode(name, callback);\nthis.addHandlebarsShortcode(name, callback);\n+ this.addJavaScriptFunction(name, callback);\n}\naddNunjucksShortcode(name, callback) {\n@@ -392,6 +395,7 @@ class UserConfig {\nthis.addPairedNunjucksShortcode(name, callback);\nthis.addPairedLiquidShortcode(name, callback);\nthis.addPairedHandlebarsShortcode(name, callback);\n+ this.addJavaScriptFunction(name, callback);\n}\naddPairedNunjucksShortcode(name, callback) {\n@@ -448,6 +452,24 @@ class UserConfig {\n);\n}\n+ addJavaScriptFunction(name, callback) {\n+ name = this.getNamespacedName(name);\n+\n+ if (this.javascriptFunctions[name]) {\n+ debug(\n+ chalk.yellow(\n+ \"Warning, overwriting a JavaScript template function with `addJavaScriptFunction(%o)`\"\n+ ),\n+ name\n+ );\n+ }\n+\n+ this.javascriptFunctions[name] = bench.add(\n+ `\"${name}\" JavaScript Function`,\n+ callback\n+ );\n+ }\n+\naddExperiment(key) {\nthis.experiments.add(key);\n}\n@@ -481,6 +503,7 @@ class UserConfig {\nhandlebarsHelpers: this.handlebarsHelpers,\nhandlebarsShortcodes: this.handlebarsShortcodes,\nhandlebarsPairedShortcodes: this.handlebarsPairedShortcodes,\n+ javascriptFunctions: this.javascriptFunctions,\npugOptions: this.pugOptions,\nejsOptions: this.ejsOptions,\nmarkdownHighlighter: this.markdownHighlighter,\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateRenderJavaScriptTest.js", "new_path": "test/TemplateRenderJavaScriptTest.js", "diff": "@@ -94,3 +94,20 @@ test(\"JS Render using ViperHTML\", async t => {\n</div>`\n);\n});\n+\n+test(\"JS Render a function\", async t => {\n+ let tr = new TemplateRender(\n+ \"../../test/stubs/template-literal-filter.11ty.js\"\n+ );\n+ tr.config = {\n+ javascriptFunctions: {\n+ upper: function(val) {\n+ return new String(val).toUpperCase();\n+ }\n+ }\n+ };\n+\n+ let fn = await tr.getCompiledTemplate();\n+ t.is(await fn({ name: \"Zach\" }), \"<p>ZACH</p>\");\n+ t.is(await fn({ name: \"Bill\" }), \"<p>BILL</p>\");\n+});\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/template-literal-filter.11ty.js", "diff": "+module.exports = function({ name, upper }) {\n+ return `<p>${upper(name)}</p>`;\n+};\n" } ]
JavaScript
MIT License
11ty/eleventy
Try out a universal filter/shortcode/helper/function on a JavaScript template.
699
30.11.2018 08:00:50
21,600
91f385d78d0d46964a8939a415d341867cbb2a52
Rogue console logs
[ { "change_type": "MODIFY", "old_path": "src/Engines/JavaScript.js", "new_path": "src/Engines/JavaScript.js", "diff": "@@ -27,7 +27,6 @@ class JavaScript extends TemplateEngine {\nreturn function(data) {\nif (dataOverrides) {\n- console.log(lodashMerge({}, data, dataOverrides));\nreturn inst.render(lodashMerge({}, data, dataOverrides));\n}\n@@ -37,7 +36,6 @@ class JavaScript extends TemplateEngine {\nObject.assign(dataOverrides, this.javascriptFunctions);\nreturn function(data) {\n- console.log(lodashMerge({}, data, dataOverrides));\nlet result = cls(lodashMerge({}, data, dataOverrides));\nif (Buffer.isBuffer(result)) {\nreturn result.toString();\n" } ]
JavaScript
MIT License
11ty/eleventy
Rogue console logs
699
01.12.2018 15:47:15
21,600
617820f5f6741e5916622ab3ca79a87b680a9976
Test javascriptFunctions available on this. in render functions for JavaScript template types.
[ { "change_type": "MODIFY", "old_path": "src/Engines/JavaScript.js", "new_path": "src/Engines/JavaScript.js", "diff": "@@ -9,40 +9,45 @@ class JavaScript extends TemplateEngine {\nasync compile(str, inputPath) {\nconst cls = require(inputPath);\nif (typeof cls === \"string\") {\n+ // string type does not work with javascriptFunctions\nreturn function() {\nreturn cls;\n};\n} else if (typeof cls === \"function\") {\n- let dataOverrides = {};\n+ // class with a `render` method\nif (cls.prototype && \"render\" in cls.prototype) {\nlet inst = new cls(inputPath);\n+ let dataOverrides = {};\n+ // get extra data from `data` method,\n+ // either as a function or getter or object literal\nif (cls.prototype && \"data\" in cls.prototype) {\n- // work with getter or function\ndataOverrides =\ntypeof inst.data === \"function\" ? inst.data() : inst.data;\n}\n- Object.assign(dataOverrides, this.javascriptFunctions);\n-\nreturn function(data) {\nif (dataOverrides) {\n- return inst.render(lodashMerge({}, data, dataOverrides));\n+ // TODO fork on deepDataMerge\n+ return inst.render.call(\n+ this.javascriptFunctions,\n+ lodashMerge({}, data, dataOverrides)\n+ );\n}\n- return inst.render(data);\n- };\n+ return inst.render.call(this.javascriptFunctions, data);\n+ }.bind(this);\n}\n- Object.assign(dataOverrides, this.javascriptFunctions);\n+ // raw function\nreturn function(data) {\n- let result = cls(lodashMerge({}, data, dataOverrides));\n+ let result = cls.call(this.javascriptFunctions, data);\nif (Buffer.isBuffer(result)) {\nreturn result.toString();\n}\nreturn result;\n- };\n+ }.bind(this);\n}\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateRenderJavaScriptTest.js", "new_path": "test/TemplateRenderJavaScriptTest.js", "diff": "@@ -95,7 +95,7 @@ test(\"JS Render using ViperHTML\", async t => {\n);\n});\n-test(\"JS Render a function\", async t => {\n+test(\"JS Render with a function\", async t => {\nlet tr = new TemplateRender(\n\"../../test/stubs/template-literal-filter.11ty.js\"\n);\n@@ -111,3 +111,74 @@ test(\"JS Render a function\", async t => {\nt.is(await fn({ name: \"Zach\" }), \"<p>ZACH</p>\");\nt.is(await fn({ name: \"Bill\" }), \"<p>BILL</p>\");\n});\n+\n+test(\"JS Class Render with a function\", async t => {\n+ let tr = new TemplateRender(\n+ \"../../test/stubs/class-template-literal-filter.11ty.js\"\n+ );\n+ tr.config = {\n+ javascriptFunctions: {\n+ upper: function(val) {\n+ return new String(val).toUpperCase();\n+ }\n+ }\n+ };\n+\n+ let fn = await tr.getCompiledTemplate();\n+ t.is(await fn({ name: \"Zach\" }), \"<p>ZACH</p>\");\n+ t.is(await fn({ name: \"Bill\" }), \"<p>BILL</p>\");\n+});\n+\n+test(\"JS Class Data Object + Render with a function\", async t => {\n+ let tr = new TemplateRender(\n+ \"../../test/stubs/class-template-literal-data-filter.11ty.js\"\n+ );\n+ tr.config = {\n+ javascriptFunctions: {\n+ upper: function(val) {\n+ return new String(val).toUpperCase();\n+ }\n+ }\n+ };\n+\n+ let fn = await tr.getCompiledTemplate();\n+ // Overrides all names to Ted\n+ t.is(await fn({ name: \"Zach\" }), \"<p>TED</p>\");\n+ t.is(await fn({ name: \"Bill\" }), \"<p>TED</p>\");\n+});\n+\n+test(\"JS Class Data Function + Render with a function\", async t => {\n+ let tr = new TemplateRender(\n+ \"../../test/stubs/class-template-literal-data-fn-filter.11ty.js\"\n+ );\n+ tr.config = {\n+ javascriptFunctions: {\n+ upper: function(val) {\n+ return new String(val).toUpperCase();\n+ }\n+ }\n+ };\n+\n+ let fn = await tr.getCompiledTemplate();\n+ // Overrides all names to Ted\n+ t.is(await fn({ name: \"Zach\" }), \"<p>TED</p>\");\n+ t.is(await fn({ name: \"Bill\" }), \"<p>TED</p>\");\n+});\n+\n+test(\"JS Class Async Render with a function\", async t => {\n+ let tr = new TemplateRender(\n+ \"../../test/stubs/class-template-literal-async-filter.11ty.js\"\n+ );\n+ tr.config = {\n+ javascriptFunctions: {\n+ upper: function(val) {\n+ return new String(val).toUpperCase();\n+ }\n+ }\n+ };\n+\n+ let fn = await tr.getCompiledTemplate();\n+ // Overrides all names to Ted\n+ t.is(await fn({ name: \"Zach\" }), \"<p>ZACH</p>\");\n+ t.is(await fn({ name: \"Bill\" }), \"<p>BILL</p>\");\n+});\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/class-template-literal-async-filter.11ty.js", "diff": "+class Test {\n+ async render({ name }) {\n+ return Promise.resolve(`<p>${this.upper(name)}</p>`);\n+ }\n+}\n+\n+module.exports = Test;\n" }, { "change_type": "MODIFY", "old_path": "test/stubs/class-template-literal-async.11ty.js", "new_path": "test/stubs/class-template-literal-async.11ty.js", "diff": "class Test {\n- async render(data) {\n- return `<p>${data.name}</p>`;\n+ async render({ name }) {\n+ return Promise.resolve(`<p>${name}</p>`);\n}\n}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/class-template-literal-data-filter.11ty.js", "diff": "+class Test {\n+ get data() {\n+ return {\n+ name: \"Ted\"\n+ };\n+ }\n+\n+ render({ name }) {\n+ return `<p>${this.upper(name)}</p>`;\n+ }\n+}\n+\n+module.exports = Test;\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/class-template-literal-data-fn-filter.11ty.js", "diff": "+class Test {\n+ data() {\n+ return {\n+ name: \"Ted\"\n+ };\n+ }\n+\n+ render({ name }) {\n+ return `<p>${this.upper(name)}</p>`;\n+ }\n+}\n+\n+module.exports = Test;\n" }, { "change_type": "MODIFY", "old_path": "test/stubs/class-template-literal-data-fn.11ty.js", "new_path": "test/stubs/class-template-literal-data-fn.11ty.js", "diff": "@@ -5,8 +5,8 @@ class Test {\n};\n}\n- render(data) {\n- return `<p>${data.name}</p>`;\n+ render({ name }) {\n+ return `<p>${name}</p>`;\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "test/stubs/class-template-literal-data.11ty.js", "new_path": "test/stubs/class-template-literal-data.11ty.js", "diff": "@@ -5,8 +5,8 @@ class Test {\n};\n}\n- render(data) {\n- return `<p>${data.name}</p>`;\n+ render({ name }) {\n+ return `<p>${name}</p>`;\n}\n}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/class-template-literal-filter.11ty.js", "diff": "+class Test {\n+ render({ name }) {\n+ return `<p>${this.upper(name)}</p>`;\n+ }\n+}\n+\n+module.exports = Test;\n" }, { "change_type": "MODIFY", "old_path": "test/stubs/class-template-literal.11ty.js", "new_path": "test/stubs/class-template-literal.11ty.js", "diff": "class Test {\n- render(data) {\n- return `<p>${data.name}</p>`;\n+ render({ name }) {\n+ return `<p>${name}</p>`;\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "test/stubs/template-literal-filter.11ty.js", "new_path": "test/stubs/template-literal-filter.11ty.js", "diff": "-module.exports = function({ name, upper }) {\n- return `<p>${upper(name)}</p>`;\n+module.exports = function({ name }) {\n+ return `<p>${this.upper(name)}</p>`;\n};\n" } ]
JavaScript
MIT License
11ty/eleventy
Test javascriptFunctions available on this. in render functions for JavaScript template types.
699
01.12.2018 19:54:33
21,600
f82656eb796071cd530ea3ba91bbe828a7dda993
Simpler file renames
[ { "change_type": "MODIFY", "old_path": "test/TemplateRenderJavaScriptTest.js", "new_path": "test/TemplateRenderJavaScriptTest.js", "diff": "@@ -18,7 +18,7 @@ test(\"JS Render a string (no data)\", async t => {\ntest(\"JS Render a function\", async t => {\nlet fn = await new TemplateRender(\n- \"../../test/stubs/template-literal.11ty.js\"\n+ \"../../test/stubs/function.11ty.js\"\n).getCompiledTemplate();\nt.is(await fn({ name: \"Zach\" }), \"<p>Zach</p>\");\nt.is(await fn({ name: \"Bill\" }), \"<p>Bill</p>\");\n@@ -26,7 +26,7 @@ test(\"JS Render a function\", async t => {\ntest(\"JS Render with a Class\", async t => {\nlet fn = await new TemplateRender(\n- \"../../test/stubs/class-template-literal.11ty.js\"\n+ \"../../test/stubs/class.11ty.js\"\n).getCompiledTemplate();\nt.is(await fn({ name: \"Zach\" }), \"<p>Zach</p>\");\nt.is(await fn({ name: \"Bill\" }), \"<p>Bill</p>\");\n@@ -34,7 +34,7 @@ test(\"JS Render with a Class\", async t => {\ntest(\"JS Render with a Class, async render\", async t => {\nlet fn = await new TemplateRender(\n- \"../../test/stubs/class-template-literal-async.11ty.js\"\n+ \"../../test/stubs/class-async.11ty.js\"\n).getCompiledTemplate();\nt.is(await fn({ name: \"Zach\" }), \"<p>Zach</p>\");\nt.is(await fn({ name: \"Bill\" }), \"<p>Bill</p>\");\n@@ -42,7 +42,7 @@ test(\"JS Render with a Class, async render\", async t => {\ntest(\"JS Render with a Class and Data getter\", async t => {\nlet fn = await new TemplateRender(\n- \"../../test/stubs/class-template-literal-data.11ty.js\"\n+ \"../../test/stubs/class-data.11ty.js\"\n).getCompiledTemplate();\nt.is(await fn(), \"<p>Ted</p>\");\nt.is(await fn({ name: \"Bill\" }), \"<p>Ted</p>\");\n@@ -50,7 +50,7 @@ test(\"JS Render with a Class and Data getter\", async t => {\ntest(\"JS Render with a Class and Data function\", async t => {\nlet fn = await new TemplateRender(\n- \"../../test/stubs/class-template-literal-data-fn.11ty.js\"\n+ \"../../test/stubs/class-data-fn.11ty.js\"\n).getCompiledTemplate();\nt.is(await fn(), \"<p>Ted</p>\");\nt.is(await fn({ name: \"Bill\" }), \"<p>Ted</p>\");\n@@ -96,9 +96,7 @@ test(\"JS Render using ViperHTML\", async t => {\n});\ntest(\"JS Render with a function\", async t => {\n- let tr = new TemplateRender(\n- \"../../test/stubs/template-literal-filter.11ty.js\"\n- );\n+ let tr = new TemplateRender(\"../../test/stubs/function-filter.11ty.js\");\ntr.config = {\njavascriptFunctions: {\nupper: function(val) {\n@@ -113,9 +111,7 @@ test(\"JS Render with a function\", async t => {\n});\ntest(\"JS Class Render with a function\", async t => {\n- let tr = new TemplateRender(\n- \"../../test/stubs/class-template-literal-filter.11ty.js\"\n- );\n+ let tr = new TemplateRender(\"../../test/stubs/class-filter.11ty.js\");\ntr.config = {\njavascriptFunctions: {\nupper: function(val) {\n@@ -130,9 +126,7 @@ test(\"JS Class Render with a function\", async t => {\n});\ntest(\"JS Class Data Object + Render with a function\", async t => {\n- let tr = new TemplateRender(\n- \"../../test/stubs/class-template-literal-data-filter.11ty.js\"\n- );\n+ let tr = new TemplateRender(\"../../test/stubs/class-data-filter.11ty.js\");\ntr.config = {\njavascriptFunctions: {\nupper: function(val) {\n@@ -148,9 +142,7 @@ test(\"JS Class Data Object + Render with a function\", async t => {\n});\ntest(\"JS Class Data Function + Render with a function\", async t => {\n- let tr = new TemplateRender(\n- \"../../test/stubs/class-template-literal-data-fn-filter.11ty.js\"\n- );\n+ let tr = new TemplateRender(\"../../test/stubs/class-data-fn-filter.11ty.js\");\ntr.config = {\njavascriptFunctions: {\nupper: function(val) {\n@@ -166,9 +158,7 @@ test(\"JS Class Data Function + Render with a function\", async t => {\n});\ntest(\"JS Class Async Render with a function\", async t => {\n- let tr = new TemplateRender(\n- \"../../test/stubs/class-template-literal-async-filter.11ty.js\"\n- );\n+ let tr = new TemplateRender(\"../../test/stubs/class-async-filter.11ty.js\");\ntr.config = {\njavascriptFunctions: {\nupper: function(val) {\n" }, { "change_type": "RENAME", "old_path": "test/stubs/class-template-literal-async-filter.11ty.js", "new_path": "test/stubs/class-async-filter.11ty.js", "diff": "" }, { "change_type": "RENAME", "old_path": "test/stubs/class-template-literal-async.11ty.js", "new_path": "test/stubs/class-async.11ty.js", "diff": "" }, { "change_type": "RENAME", "old_path": "test/stubs/class-template-literal-data-filter.11ty.js", "new_path": "test/stubs/class-data-filter.11ty.js", "diff": "" }, { "change_type": "RENAME", "old_path": "test/stubs/class-template-literal-data-fn-filter.11ty.js", "new_path": "test/stubs/class-data-fn-filter.11ty.js", "diff": "" }, { "change_type": "RENAME", "old_path": "test/stubs/class-template-literal-data-fn.11ty.js", "new_path": "test/stubs/class-data-fn.11ty.js", "diff": "" }, { "change_type": "RENAME", "old_path": "test/stubs/class-template-literal-data.11ty.js", "new_path": "test/stubs/class-data.11ty.js", "diff": "" }, { "change_type": "RENAME", "old_path": "test/stubs/class-template-literal-filter.11ty.js", "new_path": "test/stubs/class-filter.11ty.js", "diff": "" }, { "change_type": "RENAME", "old_path": "test/stubs/class-template-literal.11ty.js", "new_path": "test/stubs/class.11ty.js", "diff": "" }, { "change_type": "RENAME", "old_path": "test/stubs/template-literal-filter.11ty.js", "new_path": "test/stubs/function-filter.11ty.js", "diff": "" }, { "change_type": "RENAME", "old_path": "test/stubs/template-literal.11ty.js", "new_path": "test/stubs/function.11ty.js", "diff": "" } ]
JavaScript
MIT License
11ty/eleventy
Simpler file renames
699
01.12.2018 20:55:15
21,600
fe131dd63c95be9bc16b77ecbacfc5b490dcd743
Keep other methods accessible from class render methods and functions
[ { "change_type": "MODIFY", "old_path": "src/Engines/JavaScript.js", "new_path": "src/Engines/JavaScript.js", "diff": "@@ -2,10 +2,6 @@ const TemplateEngine = require(\"./TemplateEngine\");\nconst lodashMerge = require(\"lodash.merge\");\nclass JavaScript extends TemplateEngine {\n- get javascriptFunctions() {\n- return Object.assign({}, this.config.javascriptFunctions);\n- }\n-\nasync compile(str, inputPath) {\nconst cls = require(inputPath);\nif (typeof cls === \"string\") {\n@@ -18,7 +14,6 @@ class JavaScript extends TemplateEngine {\nif (cls.prototype && \"render\" in cls.prototype) {\nlet inst = new cls(inputPath);\nlet dataOverrides = {};\n-\n// get extra data from `data` method,\n// either as a function or getter or object literal\nif (cls.prototype && \"data\" in cls.prototype) {\n@@ -26,22 +21,20 @@ class JavaScript extends TemplateEngine {\ntypeof inst.data === \"function\" ? inst.data() : inst.data;\n}\n+ Object.assign(inst, this.config.javascriptFunctions);\nreturn function(data) {\nif (dataOverrides) {\n// TODO fork on deepDataMerge\n- return inst.render.call(\n- this.javascriptFunctions,\n- lodashMerge({}, data, dataOverrides)\n- );\n+ return inst.render.call(inst, lodashMerge({}, data, dataOverrides));\n}\n- return inst.render.call(this.javascriptFunctions, data);\n- }.bind(this);\n+ return inst.render.call(inst, data);\n+ };\n}\n// raw function\nreturn function(data) {\n- let result = cls.call(this.javascriptFunctions, data);\n+ let result = cls.call(this.config.javascriptFunctions, data);\nif (Buffer.isBuffer(result)) {\nreturn result.toString();\n}\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateRenderJavaScriptTest.js", "new_path": "test/TemplateRenderJavaScriptTest.js", "diff": "@@ -28,8 +28,8 @@ test(\"JS Render with a Class\", async t => {\nlet fn = await new TemplateRender(\n\"../../test/stubs/class.11ty.js\"\n).getCompiledTemplate();\n- t.is(await fn({ name: \"Zach\" }), \"<p>Zach</p>\");\n- t.is(await fn({ name: \"Bill\" }), \"<p>Bill</p>\");\n+ t.is(await fn({ name: \"Zach\" }), \"<p>ZachBill</p>\");\n+ t.is(await fn({ name: \"Bill\" }), \"<p>BillBill</p>\");\n});\ntest(\"JS Render with a Class, async render\", async t => {\n@@ -106,8 +106,8 @@ test(\"JS Render with a function\", async t => {\n};\nlet fn = await tr.getCompiledTemplate();\n- t.is(await fn({ name: \"Zach\" }), \"<p>ZACH</p>\");\n- t.is(await fn({ name: \"Bill\" }), \"<p>BILL</p>\");\n+ t.is(await fn({ name: \"Zach\" }), \"<p>ZACHT9000</p>\");\n+ t.is(await fn({ name: \"Bill\" }), \"<p>BILLT9000</p>\");\n});\ntest(\"JS Class Render with a function\", async t => {\n@@ -121,8 +121,8 @@ test(\"JS Class Render with a function\", async t => {\n};\nlet fn = await tr.getCompiledTemplate();\n- t.is(await fn({ name: \"Zach\" }), \"<p>ZACH</p>\");\n- t.is(await fn({ name: \"Bill\" }), \"<p>BILL</p>\");\n+ t.is(await fn({ name: \"Zach\" }), \"<p>ZACHBill</p>\");\n+ t.is(await fn({ name: \"Bill\" }), \"<p>BILLBill</p>\");\n});\ntest(\"JS Class Data Object + Render with a function\", async t => {\n@@ -169,6 +169,6 @@ test(\"JS Class Async Render with a function\", async t => {\nlet fn = await tr.getCompiledTemplate();\n// Overrides all names to Ted\n- t.is(await fn({ name: \"Zach\" }), \"<p>ZACH</p>\");\n- t.is(await fn({ name: \"Bill\" }), \"<p>BILL</p>\");\n+ t.is(await fn({ name: \"Zach\" }), \"<p>ZACHBill</p>\");\n+ t.is(await fn({ name: \"Bill\" }), \"<p>BILLBill</p>\");\n});\n" }, { "change_type": "MODIFY", "old_path": "test/stubs/class-async-filter.11ty.js", "new_path": "test/stubs/class-async-filter.11ty.js", "diff": "class Test {\n+ returnsBill() {\n+ return \"Bill\";\n+ }\n+\nasync render({ name }) {\n- return Promise.resolve(`<p>${this.upper(name)}</p>`);\n+ return Promise.resolve(`<p>${this.upper(name)}${this.returnsBill()}</p>`);\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "test/stubs/class-filter.11ty.js", "new_path": "test/stubs/class-filter.11ty.js", "diff": "class Test {\n+ returnsBill() {\n+ return \"Bill\";\n+ }\n+\nrender({ name }) {\n- return `<p>${this.upper(name)}</p>`;\n+ return `<p>${this.upper(name)}${this.returnsBill()}</p>`;\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "test/stubs/class.11ty.js", "new_path": "test/stubs/class.11ty.js", "diff": "class Test {\n+ returnsBill() {\n+ return \"Bill\";\n+ }\n+\nrender({ name }) {\n- return `<p>${name}</p>`;\n+ return `<p>${name}${this.returnsBill()}</p>`;\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "test/stubs/function-filter.11ty.js", "new_path": "test/stubs/function-filter.11ty.js", "diff": "-module.exports = function({ name }) {\n- return `<p>${this.upper(name)}</p>`;\n+function myFunction({ name }) {\n+ return `<p>${this.upper(name)}${myFunction.staticMethod()}</p>`;\n+}\n+\n+myFunction.staticMethod = function() {\n+ return \"T9000\";\n};\n+\n+module.exports = myFunction;\n" } ]
JavaScript
MIT License
11ty/eleventy
Keep other methods accessible from class render methods and functions
699
01.12.2018 21:46:46
21,600
04678663bbb6094f69dbe6092e74c247a37cba59
Async function test
[ { "change_type": "MODIFY", "old_path": "test/TemplateRenderJavaScriptTest.js", "new_path": "test/TemplateRenderJavaScriptTest.js", "diff": "@@ -24,6 +24,14 @@ test(\"JS Render a function\", async t => {\nt.is(await fn({ name: \"Bill\" }), \"<p>Bill</p>\");\n});\n+test(\"JS Render an async function\", async t => {\n+ let fn = await new TemplateRender(\n+ \"../../test/stubs/function-async.11ty.js\"\n+ ).getCompiledTemplate();\n+ t.is(await fn({ name: \"Zach\" }), \"<p>Zach</p>\");\n+ t.is(await fn({ name: \"Bill\" }), \"<p>Bill</p>\");\n+});\n+\ntest(\"JS Render with a Class\", async t => {\nlet fn = await new TemplateRender(\n\"../../test/stubs/class.11ty.js\"\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/function-async.11ty.js", "diff": "+module.exports = async function(data) {\n+ return new Promise((resolve, reject) => {\n+ setTimeout(function() {\n+ resolve(`<p>${data.name}</p>`);\n+ }, 100);\n+ });\n+};\n" } ]
JavaScript
MIT License
11ty/eleventy
Async function test
699
01.12.2018 21:54:40
21,600
955487e270ffc8bb4ba7d70642148cc8fa0ba12a
Async data function
[ { "change_type": "MODIFY", "old_path": "src/Engines/JavaScript.js", "new_path": "src/Engines/JavaScript.js", "diff": "@@ -18,7 +18,7 @@ class JavaScript extends TemplateEngine {\n// either as a function or getter or object literal\nif (cls.prototype && \"data\" in cls.prototype) {\ndataOverrides =\n- typeof inst.data === \"function\" ? inst.data() : inst.data;\n+ typeof inst.data === \"function\" ? await inst.data() : inst.data;\n}\nObject.assign(inst, this.config.javascriptFunctions);\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateRenderJavaScriptTest.js", "new_path": "test/TemplateRenderJavaScriptTest.js", "diff": "@@ -64,6 +64,14 @@ test(\"JS Render with a Class and Data function\", async t => {\nt.is(await fn({ name: \"Bill\" }), \"<p>Ted</p>\");\n});\n+test(\"JS Render with a Class and Async Data function\", async t => {\n+ let fn = await new TemplateRender(\n+ \"../../test/stubs/class-async-data-fn.11ty.js\"\n+ ).getCompiledTemplate();\n+ t.is(await fn(), \"<p>Ted</p>\");\n+ t.is(await fn({ name: \"Bill\" }), \"<p>Ted</p>\");\n+});\n+\ntest(\"JS Render using Vue\", async t => {\nlet fn = await new TemplateRender(\n\"../../test/stubs/vue.11ty.js\"\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/class-async-data-fn.11ty.js", "diff": "+class Test {\n+ async data() {\n+ return new Promise((resolve, reject) => {\n+ setTimeout(function() {\n+ resolve({\n+ name: \"Ted\"\n+ });\n+ }, 50);\n+ });\n+ }\n+\n+ render({ name }) {\n+ return `<p>${name}</p>`;\n+ }\n+}\n+\n+module.exports = Test;\n" } ]
JavaScript
MIT License
11ty/eleventy
Async data function
699
01.12.2018 22:20:36
21,600
9072cbc73939b569202c066b7a0069c2d1614a8b
Works with buffers
[ { "change_type": "MODIFY", "old_path": "src/Engines/JavaScript.js", "new_path": "src/Engines/JavaScript.js", "diff": "const TemplateEngine = require(\"./TemplateEngine\");\nconst lodashMerge = require(\"lodash.merge\");\n+function cleanup(result) {\n+ if (Buffer.isBuffer(result)) {\n+ return result.toString();\n+ }\n+\n+ return result;\n+}\n+\nclass JavaScript extends TemplateEngine {\nasync compile(str, inputPath) {\nconst cls = require(inputPath);\n- if (typeof cls === \"string\") {\n- // string type does not work with javascriptFunctions\n- return function() {\n- return cls;\n- };\n- } else if (typeof cls === \"function\") {\n+ if (typeof cls === \"function\") {\n// class with a `render` method\nif (cls.prototype && \"render\" in cls.prototype) {\nlet inst = new cls(inputPath);\n@@ -25,22 +28,23 @@ class JavaScript extends TemplateEngine {\nreturn function(data) {\nif (dataOverrides) {\n// TODO fork on deepDataMerge\n- return inst.render.call(inst, lodashMerge({}, data, dataOverrides));\n+ return cleanup(\n+ inst.render.call(inst, lodashMerge({}, data, dataOverrides))\n+ );\n}\n-\n- return inst.render.call(inst, data);\n+ return cleanup(inst.render.call(inst, data));\n};\n}\n// raw function\nreturn function(data) {\n- let result = cls.call(this.config.javascriptFunctions, data);\n- if (Buffer.isBuffer(result)) {\n- return result.toString();\n- }\n-\n- return result;\n+ return cleanup(cls.call(this.config.javascriptFunctions, data));\n}.bind(this);\n+ } else {\n+ // string type does not work with javascriptFunctions\n+ return function() {\n+ return cleanup(cls);\n+ };\n}\n}\n}\n" } ]
JavaScript
MIT License
11ty/eleventy
Works with buffers
699
02.12.2018 14:07:35
21,600
91f5b584ed7400abff1b38618150d9f3e551ed08
Fix `requires` and clear require cache when watching.
[ { "change_type": "MODIFY", "old_path": "src/Engines/JavaScript.js", "new_path": "src/Engines/JavaScript.js", "diff": "const TemplateEngine = require(\"./TemplateEngine\");\n+const TemplatePath = require(\"../TemplatePath\");\nconst lodashMerge = require(\"lodash.merge\");\n-function cleanup(result) {\n+class JavaScript extends TemplateEngine {\n+ cleanup(result) {\nif (Buffer.isBuffer(result)) {\nreturn result.toString();\n}\n@@ -9,13 +11,18 @@ function cleanup(result) {\nreturn result;\n}\n-class JavaScript extends TemplateEngine {\n+ removeJSExtension(path) {\n+ return path.endsWith(\".js\") ? path.substring(0, path.length - 3) : path;\n+ }\n+\nasync compile(str, inputPath) {\n- const cls = require(inputPath);\n+ let requirePath = TemplatePath.localPath(inputPath);\n+ delete require.cache[requirePath];\n+ const cls = require(this.removeJSExtension(requirePath));\nif (typeof cls === \"function\") {\n// class with a `render` method\nif (cls.prototype && \"render\" in cls.prototype) {\n- let inst = new cls(inputPath);\n+ let inst = new cls();\nlet dataOverrides = {};\n// get extra data from `data` method,\n// either as a function or getter or object literal\n@@ -28,23 +35,23 @@ class JavaScript extends TemplateEngine {\nreturn function(data) {\nif (dataOverrides) {\n// TODO fork on deepDataMerge\n- return cleanup(\n+ return this.cleanup(\ninst.render.call(inst, lodashMerge({}, data, dataOverrides))\n);\n}\n- return cleanup(inst.render.call(inst, data));\n- };\n+ return this.cleanup(inst.render.call(inst, data));\n+ }.bind(this);\n}\n// raw function\nreturn function(data) {\n- return cleanup(cls.call(this.config.javascriptFunctions, data));\n+ return this.cleanup(cls.call(this.config.javascriptFunctions, data));\n}.bind(this);\n} else {\n// string type does not work with javascriptFunctions\nreturn function() {\n- return cleanup(cls);\n- };\n+ return this.cleanup(cls);\n+ }.bind(this);\n}\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateRenderJavaScriptTest.js", "new_path": "test/TemplateRenderJavaScriptTest.js", "diff": "@@ -43,8 +43,8 @@ test(\"JS Render with a Class\", async t => {\nlet fn = await new TemplateRender(\n\"../../test/stubs/class.11ty.js\"\n).getCompiledTemplate();\n- t.is(await fn({ name: \"Zach\" }), \"<p>ZachBill</p>\");\n- t.is(await fn({ name: \"Bill\" }), \"<p>BillBill</p>\");\n+ t.is(await fn({ name: \"Zach\" }), \"<p>ZachBillTed</p>\");\n+ t.is(await fn({ name: \"Bill\" }), \"<p>BillBillTed</p>\");\n});\ntest(\"JS Render with a Class, async render\", async t => {\n@@ -133,6 +133,21 @@ test(\"JS Render with a function\", async t => {\nt.is(await fn({ name: \"Bill\" }), \"<p>BILLT9000</p>\");\n});\n+test(\"JS Render with a function prototype\", async t => {\n+ let tr = new TemplateRender(\"../../test/stubs/function-prototype.11ty.js\");\n+ tr.config = {\n+ javascriptFunctions: {\n+ upper: function(val) {\n+ return new String(val).toUpperCase();\n+ }\n+ }\n+ };\n+\n+ let fn = await tr.getCompiledTemplate();\n+ t.is(await fn({ name: \"Zach\" }), \"<p>ZACHBillT9001</p>\");\n+ t.is(await fn({ name: \"Bill\" }), \"<p>BILLBillT9001</p>\");\n+});\n+\ntest(\"JS Class Render with a function\", async t => {\nlet tr = new TemplateRender(\"../../test/stubs/class-filter.11ty.js\");\ntr.config = {\n@@ -144,8 +159,8 @@ test(\"JS Class Render with a function\", async t => {\n};\nlet fn = await tr.getCompiledTemplate();\n- t.is(await fn({ name: \"Zach\" }), \"<p>ZACHBill</p>\");\n- t.is(await fn({ name: \"Bill\" }), \"<p>BILLBill</p>\");\n+ t.is(await fn({ name: \"Zach\" }), \"<p>ZACHBillTed</p>\");\n+ t.is(await fn({ name: \"Bill\" }), \"<p>BILLBillTed</p>\");\n});\ntest(\"JS Class Data Object + Render with a function\", async t => {\n@@ -192,6 +207,6 @@ test(\"JS Class Async Render with a function\", async t => {\nlet fn = await tr.getCompiledTemplate();\n// Overrides all names to Ted\n- t.is(await fn({ name: \"Zach\" }), \"<p>ZACHBill</p>\");\n- t.is(await fn({ name: \"Bill\" }), \"<p>BILLBill</p>\");\n+ t.is(await fn({ name: \"Zach\" }), \"<p>ZACHBillTed</p>\");\n+ t.is(await fn({ name: \"Bill\" }), \"<p>BILLBillTed</p>\");\n});\n" }, { "change_type": "MODIFY", "old_path": "test/stubs/class-async-filter.11ty.js", "new_path": "test/stubs/class-async-filter.11ty.js", "diff": "class Test {\n+ static returnsTed() {\n+ return \"Ted\";\n+ }\n+\nreturnsBill() {\nreturn \"Bill\";\n}\nasync render({ name }) {\n- return Promise.resolve(`<p>${this.upper(name)}${this.returnsBill()}</p>`);\n+ return Promise.resolve(\n+ `<p>${this.upper(name)}${this.returnsBill()}${Test.returnsTed()}</p>`\n+ );\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "test/stubs/class-filter.11ty.js", "new_path": "test/stubs/class-filter.11ty.js", "diff": "class Test {\n+ static returnsTed() {\n+ return \"Ted\";\n+ }\n+\nreturnsBill() {\nreturn \"Bill\";\n}\nrender({ name }) {\n- return `<p>${this.upper(name)}${this.returnsBill()}</p>`;\n+ return `<p>${this.upper(\n+ name\n+ )}${this.returnsBill()}${Test.returnsTed()}</p>`;\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "test/stubs/class.11ty.js", "new_path": "test/stubs/class.11ty.js", "diff": "@@ -3,8 +3,12 @@ class Test {\nreturn \"Bill\";\n}\n+ static returnsTed() {\n+ return \"Ted\";\n+ }\n+\nrender({ name }) {\n- return `<p>${name}${this.returnsBill()}</p>`;\n+ return `<p>${name}${this.returnsBill()}${Test.returnsTed()}</p>`;\n}\n}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/function-prototype.11ty.js", "diff": "+function myFunction() {}\n+\n+myFunction.prototype.render = function({ name }) {\n+ return `<p>${this.upper(\n+ name\n+ )}${this.returnsBill()}${myFunction.staticMethod()}</p>`;\n+};\n+\n+myFunction.prototype.returnsBill = function() {\n+ return \"Bill\";\n+};\n+\n+myFunction.staticMethod = function() {\n+ return \"T9001\";\n+};\n+\n+module.exports = myFunction;\n" } ]
JavaScript
MIT License
11ty/eleventy
Fix `requires` and clear require cache when watching.
699
02.12.2018 23:28:43
21,600
24cadabe19db60e9b1ecee896f5d656fb3285fcf
More efficient and more tests.
[ { "change_type": "MODIFY", "old_path": "src/Engines/JavaScript.js", "new_path": "src/Engines/JavaScript.js", "diff": "@@ -11,34 +11,38 @@ class JavaScript extends TemplateEngine {\nreturn result;\n}\n- removeJSExtension(path) {\n- return path.endsWith(\".js\") ? path.substring(0, path.length - 3) : path;\n- }\n-\n- async compile(str, inputPath) {\n+ getRequire(inputPath) {\nlet requirePath = TemplatePath.localPath(inputPath);\ndelete require.cache[requirePath];\n- const cls = require(this.removeJSExtension(requirePath));\n+ return require(requirePath);\n+ }\n+\n+ needsToReadFileContents() {\n+ return false;\n+ }\n+\n+ async getExtraDataFromFile(inputPath) {\n+ const cls = this.getRequire(inputPath);\nif (typeof cls === \"function\") {\n- // class with a `render` method\n- if (cls.prototype && \"render\" in cls.prototype) {\n+ if (cls.prototype && \"data\" in cls.prototype) {\nlet inst = new cls();\n- let dataOverrides = {};\n// get extra data from `data` method,\n// either as a function or getter or object literal\n- if (cls.prototype && \"data\" in cls.prototype) {\n- dataOverrides =\n- typeof inst.data === \"function\" ? await inst.data() : inst.data;\n+ return typeof inst.data === \"function\" ? await inst.data() : inst.data;\n+ }\n}\n+ return {};\n+ }\n+\n+ async compile(str, inputPath) {\n+ const cls = this.getRequire(inputPath);\n+ if (typeof cls === \"function\") {\n+ // class with a `render` method\n+ if (cls.prototype && \"render\" in cls.prototype) {\n+ let inst = new cls();\nObject.assign(inst, this.config.javascriptFunctions);\nreturn function(data) {\n- if (dataOverrides) {\n- // TODO fork on deepDataMerge\n- return this.cleanup(\n- inst.render.call(inst, lodashMerge({}, data, dataOverrides))\n- );\n- }\nreturn this.cleanup(inst.render.call(inst, data));\n}.bind(this);\n}\n" }, { "change_type": "MODIFY", "old_path": "src/Engines/TemplateEngine.js", "new_path": "src/Engines/TemplateEngine.js", "diff": "@@ -97,6 +97,15 @@ class TemplateEngine {\nreturn fn(data);\n}\n+ // JavaScript files defer to the module loader rather than read the files to strings\n+ needsToReadFileContents() {\n+ return true;\n+ }\n+\n+ getExtraDataFromFile(inputPath) {\n+ return {};\n+ }\n+\nstatic get templateKeyMapToClassName() {\nreturn {\nejs: \"Ejs\",\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateContent.js", "new_path": "src/TemplateContent.js", "diff": "@@ -2,6 +2,7 @@ const fs = require(\"fs-extra\");\nconst normalize = require(\"normalize-path\");\nconst matter = require(\"gray-matter\");\n+const TemplateData = require(\"./TemplateData\");\nconst TemplateRender = require(\"./TemplateRender\");\nconst EleventyBaseError = require(\"./EleventyBaseError\");\nconst config = require(\"./Config\");\n@@ -39,6 +40,10 @@ class TemplateContent {\nreturn this._config;\n}\n+ get engine() {\n+ return this.templateRender.engine;\n+ }\n+\nget templateRender() {\nif (!this._templateRender) {\nthis._templateRender = new TemplateRender(\n@@ -61,13 +66,25 @@ class TemplateContent {\nasync read() {\nthis.inputContent = await this.getInputContent();\n+\n+ if (this.inputContent) {\nthis.frontMatter = matter(this.inputContent);\n+ } else {\n+ this.frontMatter = {\n+ data: {},\n+ content: \"\"\n+ };\n+ }\n}\nasync getInputContent() {\n+ if (this.engine.needsToReadFileContents()) {\nreturn fs.readFile(this.inputPath, \"utf-8\");\n}\n+ return \"\";\n+ }\n+\nasync getFrontMatter() {\nif (!this.frontMatter) {\nawait this.read();\n@@ -88,6 +105,7 @@ class TemplateContent {\nif (\"tags\" in data && typeof data.tags === \"string\") {\ndata.tags = [data.tags];\n}\n+\nreturn data;\n}\n@@ -96,7 +114,9 @@ class TemplateContent {\nawait this.read();\n}\n- return this.cleanupFrontMatterData(this.frontMatter.data || {});\n+ let extraData = await this.engine.getExtraDataFromFile(this.inputPath);\n+ let data = TemplateData.mergeDeep({}, this.frontMatter.data, extraData);\n+ return this.cleanupFrontMatterData(data);\n}\nasync getEngineOverride() {\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateRenderJavaScriptTest.js", "new_path": "test/TemplateRenderJavaScriptTest.js", "diff": "@@ -55,30 +55,6 @@ test(\"JS Render with a Class, async render\", async t => {\nt.is(await fn({ name: \"Bill\" }), \"<p>Bill</p>\");\n});\n-test(\"JS Render with a Class and Data getter\", async t => {\n- let fn = await new TemplateRender(\n- \"./test/stubs/class-data.11ty.js\"\n- ).getCompiledTemplate();\n- t.is(await fn(), \"<p>Ted</p>\");\n- t.is(await fn({ name: \"Bill\" }), \"<p>Ted</p>\");\n-});\n-\n-test(\"JS Render with a Class and Data function\", async t => {\n- let fn = await new TemplateRender(\n- \"./test/stubs/class-data-fn.11ty.js\"\n- ).getCompiledTemplate();\n- t.is(await fn(), \"<p>Ted</p>\");\n- t.is(await fn({ name: \"Bill\" }), \"<p>Ted</p>\");\n-});\n-\n-test(\"JS Render with a Class and Async Data function\", async t => {\n- let fn = await new TemplateRender(\n- \"./test/stubs/class-async-data-fn.11ty.js\"\n- ).getCompiledTemplate();\n- t.is(await fn(), \"<p>Ted</p>\");\n- t.is(await fn({ name: \"Bill\" }), \"<p>Ted</p>\");\n-});\n-\ntest(\"JS Render using Vue\", async t => {\nlet fn = await new TemplateRender(\n\"./test/stubs/vue.11ty.js\"\n@@ -163,38 +139,6 @@ test(\"JS Class Render with a function\", async t => {\nt.is(await fn({ name: \"Bill\" }), \"<p>BILLBillTed</p>\");\n});\n-test(\"JS Class Data Object + Render with a function\", async t => {\n- let tr = new TemplateRender(\"./test/stubs/class-data-filter.11ty.js\");\n- tr.config = {\n- javascriptFunctions: {\n- upper: function(val) {\n- return new String(val).toUpperCase();\n- }\n- }\n- };\n-\n- let fn = await tr.getCompiledTemplate();\n- // Overrides all names to Ted\n- t.is(await fn({ name: \"Zach\" }), \"<p>TED</p>\");\n- t.is(await fn({ name: \"Bill\" }), \"<p>TED</p>\");\n-});\n-\n-test(\"JS Class Data Function + Render with a function\", async t => {\n- let tr = new TemplateRender(\"./test/stubs/class-data-fn-filter.11ty.js\");\n- tr.config = {\n- javascriptFunctions: {\n- upper: function(val) {\n- return new String(val).toUpperCase();\n- }\n- }\n- };\n-\n- let fn = await tr.getCompiledTemplate();\n- // Overrides all names to Ted\n- t.is(await fn({ name: \"Zach\" }), \"<p>TED</p>\");\n- t.is(await fn({ name: \"Bill\" }), \"<p>TED</p>\");\n-});\n-\ntest(\"JS Class Async Render with a function\", async t => {\nlet tr = new TemplateRender(\"./test/stubs/class-async-filter.11ty.js\");\ntr.config = {\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateTest.js", "new_path": "test/TemplateTest.js", "diff": "@@ -1262,3 +1262,100 @@ test(\"Data Cascade Tag Merge (Shallow merge)\", async t => {\nlet data = await tmpl.getData();\nt.deepEqual(data.tags.sort(), [\"tagA\", \"tagB\"]);\n});\n+\n+test(\"JavaScript template type (function)\", async t => {\n+ let tmpl = new Template(\n+ \"./test/stubs/function.11ty.js\",\n+ \"./test/stubs/\",\n+ \"./dist\"\n+ );\n+\n+ t.is(await tmpl.getOutputPath(), \"./dist/function/index.html\");\n+ let data = await tmpl.getData();\n+ data.name = \"Zach\";\n+\n+ let pages = await tmpl.getRenderedTemplates(data);\n+ t.is(pages[0].templateContent.trim(), \"<p>Zach</p>\");\n+});\n+\n+test(\"JavaScript template type (class with data getter)\", async t => {\n+ let tmpl = new Template(\n+ \"./test/stubs/class-data.11ty.js\",\n+ \"./test/stubs/\",\n+ \"./dist\"\n+ );\n+\n+ t.is(await tmpl.getOutputPath(), \"./dist/class-data/index.html\");\n+ let data = await tmpl.getData();\n+\n+ let pages = await tmpl.getRenderedTemplates(data);\n+ t.is(pages[0].templateContent.trim(), \"<p>Ted</p>\");\n+});\n+\n+test(\"JavaScript template type (class with data method)\", async t => {\n+ let tmpl = new Template(\n+ \"./test/stubs/class-data-fn.11ty.js\",\n+ \"./test/stubs/\",\n+ \"./dist\"\n+ );\n+\n+ t.is(await tmpl.getOutputPath(), \"./dist/class-data-fn/index.html\");\n+ let data = await tmpl.getData();\n+\n+ let pages = await tmpl.getRenderedTemplates(data);\n+ t.is(pages[0].templateContent.trim(), \"<p>Ted</p>\");\n+});\n+\n+test(\"JavaScript template type (class with async data method)\", async t => {\n+ let tmpl = new Template(\n+ \"./test/stubs/class-async-data-fn.11ty.js\",\n+ \"./test/stubs/\",\n+ \"./dist\"\n+ );\n+\n+ t.is(await tmpl.getOutputPath(), \"./dist/class-async-data-fn/index.html\");\n+ let data = await tmpl.getData();\n+\n+ let pages = await tmpl.getRenderedTemplates(data);\n+ t.is(pages[0].templateContent.trim(), \"<p>Ted</p>\");\n+});\n+\n+test(\"JavaScript template type (class with data getter and a javascriptFunction)\", async t => {\n+ let tmpl = new Template(\n+ \"./test/stubs/class-data-filter.11ty.js\",\n+ \"./test/stubs/\",\n+ \"./dist\"\n+ );\n+ tmpl.templateRender.config = {\n+ javascriptFunctions: {\n+ upper: function(val) {\n+ return new String(val).toUpperCase();\n+ }\n+ }\n+ };\n+\n+ t.is(await tmpl.getOutputPath(), \"./dist/class-data-filter/index.html\");\n+ let data = await tmpl.getData();\n+ let pages = await tmpl.getRenderedTemplates(data);\n+ t.is(pages[0].templateContent.trim(), \"<p>TED</p>\");\n+});\n+\n+test(\"JavaScript template type (class with data method and a javascriptFunction)\", async t => {\n+ let tmpl = new Template(\n+ \"./test/stubs/class-data-fn-filter.11ty.js\",\n+ \"./test/stubs/\",\n+ \"./dist\"\n+ );\n+ tmpl.templateRender.config = {\n+ javascriptFunctions: {\n+ upper: function(val) {\n+ return new String(val).toUpperCase();\n+ }\n+ }\n+ };\n+\n+ t.is(await tmpl.getOutputPath(), \"./dist/class-data-fn-filter/index.html\");\n+ let data = await tmpl.getData();\n+ let pages = await tmpl.getRenderedTemplates(data);\n+ t.is(pages[0].templateContent.trim(), \"<p>TED</p>\");\n+});\n" } ]
JavaScript
MIT License
11ty/eleventy
More efficient and more tests.
699
04.12.2018 17:33:26
21,600
a6d17b820eb636810bba66460d07183d2dc5b59f
Move npm badge
[ { "change_type": "MODIFY", "old_path": "README.md", "new_path": "README.md", "diff": "@@ -13,7 +13,7 @@ Works with HTML, Markdown, Liquid, Nunjucks, Handlebars, Mustache, EJS, Haml, Pu\n- [@11ty on npm](https://www.npmjs.com/org/11ty)\n- [@11ty on GitHub](https://github.com/11ty)\n-[![Build Status](https://img.shields.io/travis/11ty/eleventy/master.svg?style=for-the-badge)](https://travis-ci.org/11ty/eleventy) [![GitHub issues](https://img.shields.io/github/issues/11ty/eleventy.svg?style=for-the-badge)](https://github.com/11ty/eleventy/issues) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=for-the-badge)](https://github.com/prettier/prettier) [![npm Version](https://img.shields.io/npm/v/@11ty/eleventy.svg?style=for-the-badge)](https://www.npmjs.com/package/@11ty/eleventy) [![npm Downloads](https://img.shields.io/npm/dt/@11ty/eleventy.svg?style=for-the-badge)](https://www.npmjs.com/package/@11ty/eleventy)\n+[![npm Version](https://img.shields.io/npm/v/@11ty/eleventy.svg?style=for-the-badge)](https://www.npmjs.com/package/@11ty/eleventy) [![Build Status](https://img.shields.io/travis/11ty/eleventy/master.svg?style=for-the-badge)](https://travis-ci.org/11ty/eleventy) [![GitHub issues](https://img.shields.io/github/issues/11ty/eleventy.svg?style=for-the-badge)](https://github.com/11ty/eleventy/issues) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=for-the-badge)](https://github.com/prettier/prettier) [![npm Downloads](https://img.shields.io/npm/dt/@11ty/eleventy.svg?style=for-the-badge)](https://www.npmjs.com/package/@11ty/eleventy)\n## Tests\n" } ]
JavaScript
MIT License
11ty/eleventy
Move npm badge
699
05.12.2018 08:54:02
21,600
39c1df54d938ce700b5fb1692bd2820a289527d5
Adds permalink test (currently failing)
[ { "change_type": "ADD", "old_path": null, "new_path": "test/TemplateTest-JavaScript.js", "diff": "+import test from \"ava\";\n+import Template from \"../src/Template\";\n+\n+test(\"JavaScript template type (function)\", async t => {\n+ let tmpl = new Template(\n+ \"./test/stubs/function.11ty.js\",\n+ \"./test/stubs/\",\n+ \"./dist\"\n+ );\n+\n+ t.is(await tmpl.getOutputPath(), \"./dist/function/index.html\");\n+ let data = await tmpl.getData();\n+ data.name = \"Zach\";\n+\n+ let pages = await tmpl.getRenderedTemplates(data);\n+ t.is(pages[0].templateContent.trim(), \"<p>Zach</p>\");\n+});\n+\n+test(\"JavaScript template type (class with data getter)\", async t => {\n+ let tmpl = new Template(\n+ \"./test/stubs/class-data.11ty.js\",\n+ \"./test/stubs/\",\n+ \"./dist\"\n+ );\n+\n+ t.is(await tmpl.getOutputPath(), \"./dist/class-data/index.html\");\n+ let data = await tmpl.getData();\n+\n+ let pages = await tmpl.getRenderedTemplates(data);\n+ t.is(pages[0].templateContent.trim(), \"<p>Ted</p>\");\n+});\n+\n+test(\"JavaScript template type (class with data method)\", async t => {\n+ let tmpl = new Template(\n+ \"./test/stubs/class-data-fn.11ty.js\",\n+ \"./test/stubs/\",\n+ \"./dist\"\n+ );\n+\n+ t.is(await tmpl.getOutputPath(), \"./dist/class-data-fn/index.html\");\n+ let data = await tmpl.getData();\n+\n+ let pages = await tmpl.getRenderedTemplates(data);\n+ t.is(pages[0].templateContent.trim(), \"<p>Ted</p>\");\n+});\n+\n+test(\"JavaScript template type (class with async data method)\", async t => {\n+ let tmpl = new Template(\n+ \"./test/stubs/class-async-data-fn.11ty.js\",\n+ \"./test/stubs/\",\n+ \"./dist\"\n+ );\n+\n+ t.is(await tmpl.getOutputPath(), \"./dist/class-async-data-fn/index.html\");\n+ let data = await tmpl.getData();\n+\n+ let pages = await tmpl.getRenderedTemplates(data);\n+ t.is(pages[0].templateContent.trim(), \"<p>Ted</p>\");\n+});\n+\n+test(\"JavaScript template type (class with data getter and a javascriptFunction)\", async t => {\n+ let tmpl = new Template(\n+ \"./test/stubs/class-data-filter.11ty.js\",\n+ \"./test/stubs/\",\n+ \"./dist\"\n+ );\n+ tmpl.templateRender.config = {\n+ javascriptFunctions: {\n+ upper: function(val) {\n+ return new String(val).toUpperCase();\n+ }\n+ }\n+ };\n+\n+ t.is(await tmpl.getOutputPath(), \"./dist/class-data-filter/index.html\");\n+ let data = await tmpl.getData();\n+ let pages = await tmpl.getRenderedTemplates(data);\n+ t.is(pages[0].templateContent.trim(), \"<p>TED</p>\");\n+});\n+\n+test(\"JavaScript template type (class with data method and a javascriptFunction)\", async t => {\n+ let tmpl = new Template(\n+ \"./test/stubs/class-data-fn-filter.11ty.js\",\n+ \"./test/stubs/\",\n+ \"./dist\"\n+ );\n+ tmpl.templateRender.config = {\n+ javascriptFunctions: {\n+ upper: function(val) {\n+ return new String(val).toUpperCase();\n+ }\n+ }\n+ };\n+\n+ t.is(await tmpl.getOutputPath(), \"./dist/class-data-fn-filter/index.html\");\n+ let data = await tmpl.getData();\n+ let pages = await tmpl.getRenderedTemplates(data);\n+ t.is(pages[0].templateContent.trim(), \"<p>TED</p>\");\n+});\n+\n+test(\"JavaScript template type (class with data permalink)\", async t => {\n+ let tmpl = new Template(\n+ \"./test/stubs/class-data-permalink.11ty.js\",\n+ \"./test/stubs/\",\n+ \"./dist\"\n+ );\n+\n+ t.is(await tmpl.getOutputPath(), \"./dist/my-permalink/index.html\");\n+});\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateTest.js", "new_path": "test/TemplateTest.js", "diff": "@@ -1262,100 +1262,3 @@ test(\"Data Cascade Tag Merge (Shallow merge)\", async t => {\nlet data = await tmpl.getData();\nt.deepEqual(data.tags.sort(), [\"tagA\", \"tagB\"]);\n});\n-\n-test(\"JavaScript template type (function)\", async t => {\n- let tmpl = new Template(\n- \"./test/stubs/function.11ty.js\",\n- \"./test/stubs/\",\n- \"./dist\"\n- );\n-\n- t.is(await tmpl.getOutputPath(), \"./dist/function/index.html\");\n- let data = await tmpl.getData();\n- data.name = \"Zach\";\n-\n- let pages = await tmpl.getRenderedTemplates(data);\n- t.is(pages[0].templateContent.trim(), \"<p>Zach</p>\");\n-});\n-\n-test(\"JavaScript template type (class with data getter)\", async t => {\n- let tmpl = new Template(\n- \"./test/stubs/class-data.11ty.js\",\n- \"./test/stubs/\",\n- \"./dist\"\n- );\n-\n- t.is(await tmpl.getOutputPath(), \"./dist/class-data/index.html\");\n- let data = await tmpl.getData();\n-\n- let pages = await tmpl.getRenderedTemplates(data);\n- t.is(pages[0].templateContent.trim(), \"<p>Ted</p>\");\n-});\n-\n-test(\"JavaScript template type (class with data method)\", async t => {\n- let tmpl = new Template(\n- \"./test/stubs/class-data-fn.11ty.js\",\n- \"./test/stubs/\",\n- \"./dist\"\n- );\n-\n- t.is(await tmpl.getOutputPath(), \"./dist/class-data-fn/index.html\");\n- let data = await tmpl.getData();\n-\n- let pages = await tmpl.getRenderedTemplates(data);\n- t.is(pages[0].templateContent.trim(), \"<p>Ted</p>\");\n-});\n-\n-test(\"JavaScript template type (class with async data method)\", async t => {\n- let tmpl = new Template(\n- \"./test/stubs/class-async-data-fn.11ty.js\",\n- \"./test/stubs/\",\n- \"./dist\"\n- );\n-\n- t.is(await tmpl.getOutputPath(), \"./dist/class-async-data-fn/index.html\");\n- let data = await tmpl.getData();\n-\n- let pages = await tmpl.getRenderedTemplates(data);\n- t.is(pages[0].templateContent.trim(), \"<p>Ted</p>\");\n-});\n-\n-test(\"JavaScript template type (class with data getter and a javascriptFunction)\", async t => {\n- let tmpl = new Template(\n- \"./test/stubs/class-data-filter.11ty.js\",\n- \"./test/stubs/\",\n- \"./dist\"\n- );\n- tmpl.templateRender.config = {\n- javascriptFunctions: {\n- upper: function(val) {\n- return new String(val).toUpperCase();\n- }\n- }\n- };\n-\n- t.is(await tmpl.getOutputPath(), \"./dist/class-data-filter/index.html\");\n- let data = await tmpl.getData();\n- let pages = await tmpl.getRenderedTemplates(data);\n- t.is(pages[0].templateContent.trim(), \"<p>TED</p>\");\n-});\n-\n-test(\"JavaScript template type (class with data method and a javascriptFunction)\", async t => {\n- let tmpl = new Template(\n- \"./test/stubs/class-data-fn-filter.11ty.js\",\n- \"./test/stubs/\",\n- \"./dist\"\n- );\n- tmpl.templateRender.config = {\n- javascriptFunctions: {\n- upper: function(val) {\n- return new String(val).toUpperCase();\n- }\n- }\n- };\n-\n- t.is(await tmpl.getOutputPath(), \"./dist/class-data-fn-filter/index.html\");\n- let data = await tmpl.getData();\n- let pages = await tmpl.getRenderedTemplates(data);\n- t.is(pages[0].templateContent.trim(), \"<p>TED</p>\");\n-});\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/class-data-permalink.11ty.js", "diff": "+class Test {\n+ get data() {\n+ return {\n+ permalink: \"/my-permalink/\"\n+ };\n+ }\n+ // TODO permalink: function() {}\n+\n+ render({ name }) {\n+ return `<p>${name}</p>`;\n+ }\n+}\n+\n+module.exports = Test;\n" } ]
JavaScript
MIT License
11ty/eleventy
Adds permalink test (currently failing)
699
06.12.2018 09:03:13
21,600
8d754d1da2a246397c304fc5633990296b9f89c6
Adds support for 11ty.js permalinks
[ { "change_type": "MODIFY", "old_path": "src/Engines/JavaScript.js", "new_path": "src/Engines/JavaScript.js", "diff": "@@ -3,7 +3,7 @@ const TemplatePath = require(\"../TemplatePath\");\nconst lodashMerge = require(\"lodash.merge\");\nclass JavaScript extends TemplateEngine {\n- cleanup(result) {\n+ normalize(result) {\nif (Buffer.isBuffer(result)) {\nreturn result.toString();\n}\n@@ -11,7 +11,7 @@ class JavaScript extends TemplateEngine {\nreturn result;\n}\n- getRequire(inputPath) {\n+ _getRequire(inputPath) {\nlet requirePath = TemplatePath.localPath(inputPath);\ndelete require.cache[requirePath];\nreturn require(requirePath);\n@@ -22,7 +22,7 @@ class JavaScript extends TemplateEngine {\n}\nasync getExtraDataFromFile(inputPath) {\n- const cls = this.getRequire(inputPath);\n+ const cls = this._getRequire(inputPath);\nif (typeof cls === \"function\") {\nif (cls.prototype && \"data\" in cls.prototype) {\nlet inst = new cls();\n@@ -36,25 +36,38 @@ class JavaScript extends TemplateEngine {\n}\nasync compile(str, inputPath) {\n- const cls = this.getRequire(inputPath);\n+ // for permalinks\n+ if (str) {\n+ // works with String, Buffer, Function!\n+ return function(data) {\n+ let target = str;\n+ if (typeof str === \"function\") {\n+ target = str.call(this.config.javascriptFunctions, data);\n+ }\n+ return this.normalize(target);\n+ }.bind(this);\n+ }\n+\n+ // for all other requires, str will be falsy\n+ const cls = this._getRequire(inputPath);\nif (typeof cls === \"function\") {\n// class with a `render` method\nif (cls.prototype && \"render\" in cls.prototype) {\nlet inst = new cls();\nObject.assign(inst, this.config.javascriptFunctions);\nreturn function(data) {\n- return this.cleanup(inst.render.call(inst, data));\n+ return this.normalize(inst.render.call(inst, data));\n}.bind(this);\n}\n// raw function\nreturn function(data) {\n- return this.cleanup(cls.call(this.config.javascriptFunctions, data));\n+ return this.normalize(cls.call(this.config.javascriptFunctions, data));\n}.bind(this);\n} else {\n// string type does not work with javascriptFunctions\nreturn function() {\n- return this.cleanup(cls);\n+ return this.normalize(cls);\n}.bind(this);\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateTest-JavaScript.js", "new_path": "test/TemplateTest-JavaScript.js", "diff": "@@ -44,6 +44,20 @@ test(\"JavaScript template type (class with data method)\", async t => {\nt.is(pages[0].templateContent.trim(), \"<p>Ted</p>\");\n});\n+test(\"JavaScript template type (class with shorthand data method)\", async t => {\n+ let tmpl = new Template(\n+ \"./test/stubs/class-data-fn-shorthand.11ty.js\",\n+ \"./test/stubs/\",\n+ \"./dist\"\n+ );\n+\n+ t.is(await tmpl.getOutputPath(), \"./dist/class-data-fn-shorthand/index.html\");\n+ let data = await tmpl.getData();\n+\n+ let pages = await tmpl.getRenderedTemplates(data);\n+ t.is(pages[0].templateContent.trim(), \"<p>Ted</p>\");\n+});\n+\ntest(\"JavaScript template type (class with async data method)\", async t => {\nlet tmpl = new Template(\n\"./test/stubs/class-async-data-fn.11ty.js\",\n@@ -107,3 +121,26 @@ test(\"JavaScript template type (class with data permalink)\", async t => {\nt.is(await tmpl.getOutputPath(), \"./dist/my-permalink/index.html\");\n});\n+\n+test(\"JavaScript template type (class with data permalink function)\", async t => {\n+ let tmpl = new Template(\n+ \"./test/stubs/class-data-permalink-fn.11ty.js\",\n+ \"./test/stubs/\",\n+ \"./dist\"\n+ );\n+\n+ t.is(await tmpl.getOutputPath(), \"./dist/my-permalink/value1/index.html\");\n+});\n+\n+test(\"JavaScript template type (class with data permalink function using a filter)\", async t => {\n+ let tmpl = new Template(\n+ \"./test/stubs/class-data-permalink-fn-filter.11ty.js\",\n+ \"./test/stubs/\",\n+ \"./dist\"\n+ );\n+\n+ t.is(\n+ await tmpl.getOutputPath(),\n+ \"./dist/my-permalink/my-super-cool-title/index.html\"\n+ );\n+});\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/class-data-permalink-fn-filter.11ty.js", "diff": "+class Test {\n+ get data() {\n+ return {\n+ title: \"My Super Cool Title\",\n+ permalink: function({ title }) {\n+ return `/my-permalink/${this.slug(title)}/`;\n+ }\n+ };\n+ }\n+\n+ render({ name }) {\n+ return `<p>${name}</p>`;\n+ }\n+}\n+\n+module.exports = Test;\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/class-data-permalink-fn.11ty.js", "diff": "+class Test {\n+ get data() {\n+ return {\n+ key: \"value1\",\n+ permalink: data => `/my-permalink/${data.key}/`\n+ };\n+ }\n+\n+ render({ name }) {\n+ return `<p>${name}</p>`;\n+ }\n+}\n+\n+module.exports = Test;\n" }, { "change_type": "MODIFY", "old_path": "test/stubs/class-data-permalink.11ty.js", "new_path": "test/stubs/class-data-permalink.11ty.js", "diff": "@@ -4,7 +4,6 @@ class Test {\npermalink: \"/my-permalink/\"\n};\n}\n- // TODO permalink: function() {}\nrender({ name }) {\nreturn `<p>${name}</p>`;\n" } ]
JavaScript
MIT License
11ty/eleventy
Adds support for 11ty.js permalinks
699
07.12.2018 08:41:38
21,600
17f4f5bdc12bd3c679ea60d25bb07d9ee4274e00
Adds tests for renderData with JavaScript template types.
[ { "change_type": "MODIFY", "old_path": "src/Template.js", "new_path": "src/Template.js", "diff": "@@ -157,7 +157,13 @@ class Template extends TemplateContent {\n}\nasync mapDataAsRenderedTemplates(data, templateData) {\n- if (Array.isArray(data)) {\n+ // function supported in JavaScript type\n+ if (typeof data === \"string\" || typeof data === \"function\") {\n+ debug(\"rendering data.renderData for %o\", this.inputPath);\n+ // bypassMarkdown\n+ let str = await super.render(data, templateData, true);\n+ return str;\n+ } else if (Array.isArray(data)) {\nlet arr = [];\nfor (let j = 0, k = data.length; j < k; j++) {\narr.push(await this.mapDataAsRenderedTemplates(data[j], templateData));\n@@ -172,11 +178,6 @@ class Template extends TemplateContent {\n);\n}\nreturn obj;\n- } else if (typeof data === \"string\") {\n- debug(\"rendering data.renderData for %o\", this.inputPath);\n- // bypassMarkdown\n- let str = await super.render(data, templateData, true);\n- return str;\n}\nreturn data;\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateTest-JavaScript.js", "new_path": "test/TemplateTest-JavaScript.js", "diff": "@@ -144,3 +144,18 @@ test(\"JavaScript template type (class with data permalink function using a filte\n\"./dist/my-permalink/my-super-cool-title/index.html\"\n);\n});\n+\n+test(\"JavaScript template type (class with renderData)\", async t => {\n+ let tmpl = new Template(\n+ \"./test/stubs/class-data-renderdata.11ty.js\",\n+ \"./test/stubs/\",\n+ \"./dist\"\n+ );\n+\n+ let data = await tmpl.getRenderedData();\n+ let pages = await tmpl.getRenderedTemplates(data);\n+ t.is(\n+ pages[0].templateContent.trim(),\n+ \"<p>StringTesthowdy Zach, meet Thanos</p>\"\n+ );\n+});\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/class-data-renderdata.11ty.js", "diff": "+class Test {\n+ data() {\n+ return {\n+ name: \"Zach\",\n+ otherFn: function() {\n+ return \"Thanos\";\n+ },\n+ renderData: {\n+ str: `StringTest`,\n+ test: function({ name }) {\n+ return `howdy ${name}`;\n+ }\n+ }\n+ };\n+ }\n+\n+ render(data) {\n+ return `<p>${data.renderData.str}${\n+ data.renderData.test\n+ }, meet ${data.otherFn()}</p>`;\n+ }\n+}\n+\n+module.exports = Test;\n" } ]
JavaScript
MIT License
11ty/eleventy
Adds tests for renderData with JavaScript template types.
699
17.12.2018 20:35:21
21,600
8f28976abdaddd8ca218dfe56c022c014a35f046
Upgrades to ava 1.0
[ { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "\"files\": [\n\"test/*.js\"\n],\n- \"source\": [\n+ \"sources\": [\n\"**/.eleventyignore\",\n\"src/**/*.js\",\n\"test/stubs/**\"\n},\n\"devDependencies\": {\n\"@11ty/eleventy-plugin-syntaxhighlight\": \"^2.0.0\",\n- \"ava\": \"^0.25.0\",\n+ \"ava\": \"^1.0.1\",\n\"husky\": \"^1.0.1\",\n\"lint-staged\": \"^7.3.0\",\n\"markdown-it-emoji\": \"^1.4.0\",\n\"luxon\": \"^1.4.1\",\n\"markdown-it\": \"^8.4.2\",\n\"minimist\": \"^1.2.0\",\n+ \"moo\": \"^0.5.0\",\n\"multimatch\": \"^2.1.0\",\n\"mustache\": \"^2.3.0\",\n\"normalize-path\": \"^3.0.0\",\n" }, { "change_type": "MODIFY", "old_path": "test/EleventyExtensionMapTest.js", "new_path": "test/EleventyExtensionMapTest.js", "diff": "@@ -16,7 +16,7 @@ test(\"Multiple formats\", t => {\nt.deepEqual(map.getGlobs(\"src\"), [\"./src/**/*.njk\", \"./src/**/*.pug\"]);\n});\n-test(\"Invalid keys are filtered\", t => {\n+test(\"Invalid keys are filtered (no passthrough copy)\", t => {\nlet map = new EleventyExtensionMap([\"lksdjfjlsk\"]);\nmap.setConfig({\npassthroughFileCopy: false\n@@ -24,7 +24,7 @@ test(\"Invalid keys are filtered\", t => {\nt.deepEqual(map.getGlobs(), []);\n});\n-test(\"Invalid keys are filtered\", t => {\n+test(\"Invalid keys are filtered (using passthrough copy)\", t => {\nlet map = new EleventyExtensionMap([\"lksdjfjlsk\"]);\nmap.setConfig({\npassthroughFileCopy: true\n" }, { "change_type": "MODIFY", "old_path": "test/EleventyFilesTest.js", "new_path": "test/EleventyFilesTest.js", "diff": "@@ -291,7 +291,7 @@ test(\"Glob Watcher Files with File Extension Passthroughs\", async t => {\n]);\n});\n-test(\"Glob Watcher Files with Config Passthroughs\", async t => {\n+test(\"Glob Watcher Files with Config Passthroughs (one template format)\", async t => {\nlet evf = new EleventyFiles(\"test/stubs\", \"test/stubs/_site\", [\"njk\"]);\nevf.init();\n@@ -314,7 +314,7 @@ test(\"Glob Watcher Files with Config Passthroughs\", async t => {\n]);\n});\n-test(\"Glob Watcher Files with Config Passthroughs\", async t => {\n+test(\"Glob Watcher Files with Config Passthroughs (no template formats)\", async t => {\nlet evf = new EleventyFiles(\"test/stubs\", \"test/stubs/_site\", []);\nevf.init();\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateDataTest.js", "new_path": "test/TemplateDataTest.js", "diff": "@@ -38,9 +38,10 @@ test(\"getData()\", async t => {\n});\ntest(\"Data dir does not exist\", async t => {\n+ await t.throwsAsync(async () => {\nlet dataObj = new TemplateData(\"./test/thisdirectorydoesnotexist\");\n-\n- await t.throws(dataObj.getData());\n+ await dataObj.getData();\n+ });\n});\ntest(\"Add local data\", async t => {\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateGlobTest.js", "new_path": "test/TemplateGlobTest.js", "diff": "@@ -49,7 +49,7 @@ test(\"NormalizePath with globstar and star and file extension\", t => {\n);\n});\n-test(\"NormalizePath with globstar and star and file extension\", t => {\n+test(\"NormalizePath with globstar and star and file extension (errors)\", t => {\nt.throws(() => {\nTemplateGlob.normalizePath(\"!views/**/*.json\");\n});\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateMapTest.js", "new_path": "test/TemplateMapTest.js", "diff": "@@ -266,7 +266,7 @@ This page is bars\n);\n});\n-test(\"TemplateMap adds collections data and has page data values\", async t => {\n+test(\"TemplateMap adds collections data and has page data values using .cache()\", async t => {\nlet tm = new TemplateMap();\nawait tm.add(tmpl1);\nawait tm.add(tmpl2);\n@@ -286,7 +286,7 @@ test(\"TemplateMap adds collections data and has page data values\", async t => {\nt.truthy(map[0].data.page.date);\n});\n-test(\"TemplateMap adds collections data and has page data values\", async t => {\n+test(\"TemplateMap adds collections data and has page data values using .getCollectionsData()\", async t => {\nlet tm = new TemplateMap();\nawait tm.add(tmpl1);\nawait tm.add(tmpl2);\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateRenderHandlebarsTest.js", "new_path": "test/TemplateRenderHandlebarsTest.js", "diff": "@@ -79,7 +79,7 @@ test(\"Handlebars Render Helper\", async t => {\nt.is(await fn({ name: \"Zach\" }), \"<p>This is a Zach Zach.</p>\");\n});\n-test(\"Handlebars Render Helper\", async t => {\n+test(\"Handlebars Render Helper (uses argument)\", async t => {\nlet tr = new TemplateRender(\"hbs\");\ntr.engine.addHelpers({\nhelpername2: function(name) {\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateRenderMustacheTest.js", "new_path": "test/TemplateRenderMustacheTest.js", "diff": "@@ -13,7 +13,7 @@ test(\"Mustache Render\", async t => {\nt.is(await fn({ name: \"Zach\" }), \"<p>Zach</p>\");\n});\n-test(\"Mustache Render Partial\", async t => {\n+test(\"Mustache Render Partial (raw text content)\", async t => {\nlet fn = await new TemplateRender(\n\"mustache\",\n\"./test/stubs/\"\n@@ -21,7 +21,7 @@ test(\"Mustache Render Partial\", async t => {\nt.is(await fn(), \"<p>This is an include.</p>\");\n});\n-test(\"Mustache Render Partial\", async t => {\n+test(\"Mustache Render Partial (uses a variable in content)\", async t => {\nlet fn = await new TemplateRender(\n\"mustache\",\n\"./test/stubs/\"\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateRenderTest.js", "new_path": "test/TemplateRenderTest.js", "diff": "@@ -2,7 +2,7 @@ import test from \"ava\";\nimport TemplateRender from \"../src/TemplateRender\";\nimport path from \"path\";\n-test(t => {\n+test(\"Basic\", t => {\n// Path is unnecessary but supported\nt.is(TemplateRender.cleanupEngineName(\"default.ejs\"), \"ejs\");\nt.true(TemplateRender.hasEngine(\"default.ejs\"));\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateTest.js", "new_path": "test/TemplateTest.js", "diff": "@@ -82,7 +82,7 @@ test(\"HTML files output to the same as the input directory have a file suffix ad\nt.is(await tmpl.getOutputPath(), \"./test/stubs/index-o.html\");\n});\n-test(\"HTML files output to the same as the input directory have a file suffix added (only if index, this _is_ index).\", async t => {\n+test(\"HTML files output to the same as the input directory have a file suffix added (only if index, this _is_ index, subfolder).\", async t => {\nlet tmpl = new Template(\n\"./test/stubs/subfolder/index.html\",\n\"./test/stubs\",\n@@ -899,7 +899,9 @@ test(\"Override base templating engine should error with bad string\", async t =>\n\"./dist\"\n);\n- await t.throws(tmpl.render());\n+ await t.throwsAsync(async () => {\n+ await tmpl.render();\n+ });\n});\ntest(\"Override base templating engine (bypasses markdown)\", async t => {\n" } ]
JavaScript
MIT License
11ty/eleventy
Upgrades to ava 1.0
699
17.12.2018 20:58:26
21,600
838e6a7e4d26e0f95672a7e20adf9ca4de08ab3c
Generic ignore: prefix in lexer
[ { "change_type": "MODIFY", "old_path": "src/Engines/Liquid.js", "new_path": "src/Engines/Liquid.js", "diff": "@@ -17,7 +17,7 @@ class Liquid extends TemplateEngine {\ndoubleQuoteString: /\"(?:\\\\[\"\\\\]|[^\\n\"\\\\])*\"/,\nsingleQuoteString: /'(?:\\\\['\\\\]|[^\\n'\\\\])*'/,\nkeyword: /[a-zA-Z0-9]+/,\n- whitespace: /[, \\t]+/ // includes comma separator\n+ \"ignore:whitespace\": /[, \\t]+/ // includes comma separator\n});\n}\n@@ -114,7 +114,7 @@ class Liquid extends TemplateEngine {\nlineBreaks: 0,\nline: 1,\ncol: 1 }*/\n- if (arg.type !== \"whitespace\") {\n+ if (arg.type.indexOf(\"ignore:\") === -1) {\nargArray.push(LiquidLib.evalExp(arg.value, scope)); // or evalValue\n}\narg = lexer.next();\n" } ]
JavaScript
MIT License
11ty/eleventy
Generic ignore: prefix in lexer
699
19.12.2018 07:58:34
21,600
b73af8c91c0994ca33107578787ed21be2756ec0
Removes glob-watcher middle-man and use upstream dependency instead (chokidar)
[ { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "\"dependencies\": {\n\"browser-sync\": \"^2.24.7\",\n\"chalk\": \"^2.4.1\",\n+ \"chokidar\": \"^2.0.4\",\n\"debug\": \"^4.0.1\",\n\"dependency-tree\": \"^6.3.0\",\n\"ejs\": \"^2.6.1\",\n\"fast-glob\": \"^2.2.2\",\n\"fs-extra\": \"^7.0.0\",\n- \"glob-watcher\": \"^5.0.1\",\n\"gray-matter\": \"^4.0.1\",\n\"hamljs\": \"^0.6.2\",\n\"handlebars\": \"^4.0.12\",\n" } ]
JavaScript
MIT License
11ty/eleventy
Removes glob-watcher middle-man and use upstream dependency instead (chokidar)
699
21.12.2018 07:46:49
21,600
20bd9cddbd6b7884680b61cb5f607a5c19c368de
Adds a test returning markdown inside of the JavaScript template.
[ { "change_type": "MODIFY", "old_path": "test/TemplateRenderJavaScriptTest.js", "new_path": "test/TemplateRenderJavaScriptTest.js", "diff": "@@ -31,6 +31,14 @@ test(\"JS Render a function\", async t => {\nt.is(await fn({ name: \"Bill\" }), \"<p>Bill</p>\");\n});\n+test(\"JS Render a function (Markdown)\", async t => {\n+ let tr = new TemplateRender(\"./test/stubs/function-markdown.11ty.js\");\n+ tr.setEngineOverride(\"11ty.js,md\");\n+ let fn = await tr.getCompiledTemplate();\n+ t.is((await fn({ name: \"Zach\" })).trim(), \"<h1>Zach</h1>\");\n+ t.is((await fn({ name: \"Bill\" })).trim(), \"<h1>Bill</h1>\");\n+});\n+\ntest(\"JS Render an async function\", async t => {\nlet fn = await new TemplateRender(\n\"./test/stubs/function-async.11ty.js\"\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/function-markdown.11ty.js", "diff": "+module.exports = function(data) {\n+ return `# ${data.name}`;\n+};\n" } ]
JavaScript
MIT License
11ty/eleventy
Adds a test returning markdown inside of the JavaScript template.
699
21.12.2018 22:13:37
21,600
244368bbeba5c9dd6b1d0f51ef6d52a345896b2a
Only remove JS templates from require cache once
[ { "change_type": "MODIFY", "old_path": "src/EleventyWatchTargets.js", "new_path": "src/EleventyWatchTargets.js", "diff": "@@ -79,7 +79,7 @@ class EleventyWatchTargets {\ngetJavaScriptDependenciesFromList(files = []) {\nlet depSet = new Set();\nfiles\n- .filter(file => file.endsWith(\".js\"))\n+ .filter(file => file.endsWith(\".js\")) // TODO does this need to work with aliasing? what other JS extensions will have deps?\n.forEach(file => {\ndependencyTree\n.toList({\n" }, { "change_type": "MODIFY", "old_path": "src/Engines/JavaScript.js", "new_path": "src/Engines/JavaScript.js", "diff": "@@ -14,7 +14,6 @@ class JavaScript extends TemplateEngine {\n_getRequire(inputPath) {\nlet requirePath = TemplatePath.localPath(inputPath);\n- delete require.cache[requirePath];\nreturn require(requirePath);\n}\n@@ -22,10 +21,19 @@ class JavaScript extends TemplateEngine {\nreturn false;\n}\n+ // only remove from cache once on startup (if it already exists)\n+ initRequireCache(inputPath) {\n+ let requirePath = TemplatePath.localPath(inputPath);\n+ if (requirePath in require.cache) {\n+ delete require.cache[requirePath];\n+ }\n+ }\n+\nasync getExtraDataFromFile(inputPath) {\nconst cls = this._getRequire(inputPath);\nif (typeof cls === \"function\") {\nif (cls.prototype && \"data\" in cls.prototype) {\n+ // TODO this is instantiating multiple separate instances every time it is called (see also one in compile)\nlet inst = new cls();\n// get extra data from `data` method,\n// either as a function or getter or object literal\n" }, { "change_type": "MODIFY", "old_path": "src/Engines/TemplateEngine.js", "new_path": "src/Engines/TemplateEngine.js", "diff": "@@ -107,6 +107,10 @@ class TemplateEngine {\nreturn {};\n}\n+ initRequireCache(inputPath) {\n+ // do nothing\n+ }\n+\nstatic get templateKeyMapToClassName() {\nreturn {\nejs: \"Ejs\",\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateRender.js", "new_path": "src/TemplateRender.js", "diff": "@@ -53,6 +53,7 @@ class TemplateRender {\n);\n}\nthis.engine = TemplateEngine.getEngine(this.engineName, this.inputDir);\n+ this.engine.initRequireCache(this.path);\n}\ncleanupEngineName(tmplPath) {\n" } ]
JavaScript
MIT License
11ty/eleventy
Only remove JS templates from require cache once
699
21.12.2018 22:13:54
21,600
8c9ddf2ea1c84c36b93112904836d8952dbdf6f4
Markdown in 11ty.js template test.
[ { "change_type": "MODIFY", "old_path": "test/TemplateTest.js", "new_path": "test/TemplateTest.js", "diff": "@@ -842,6 +842,16 @@ test(\"Override base templating engine from .liquid to ejs\", async t => {\nt.is((await tmpl.render()).trim(), \"My Title\");\n});\n+test(\"Override base templating engine from markdown to 11ty.js, then markdown\", async t => {\n+ let tmpl = new Template(\n+ \"./test/stubs/test-override-js-markdown.11ty.js\",\n+ \"./test/stubs/\",\n+ \"./dist\"\n+ );\n+\n+ t.is((await tmpl.render()).trim(), \"<h1>This is markdown</h1>\");\n+});\n+\ntest(\"Override base templating engine from .liquid to md\", async t => {\nlet tmpl = new Template(\n\"./test/stubs/overrides/test-md.liquid\",\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/test-override-js-markdown.11ty.js", "diff": "+class Test {\n+ data() {\n+ return {\n+ name: \"markdown\",\n+ templateEngineOverride: \"11ty.js,md\"\n+ };\n+ }\n+\n+ render(data) {\n+ return `# This is ${data.name}`;\n+ }\n+}\n+\n+module.exports = Test;\n" } ]
JavaScript
MIT License
11ty/eleventy
Markdown in 11ty.js template test.
699
26.12.2018 22:35:57
21,600
d050e9acb50e4885d7d5cd4c4290900d6238bdfe
Adds benchmark link
[ { "change_type": "MODIFY", "old_path": "README.md", "new_path": "README.md", "diff": "@@ -22,6 +22,7 @@ npm run test\n```\n- [Code Coverage Statistics](https://github.com/11ty/eleventy/blob/master/docs/coverage.md)\n+- [Benchmark for Performance Regressions](https://github.com/11ty/eleventy-benchmark)\n## Major Roadmapped Features\n" } ]
JavaScript
MIT License
11ty/eleventy
Adds benchmark link
699
28.12.2018 08:58:31
21,600
512842d025af195fdd4631675dad465919220a34
Permalink async function
[ { "change_type": "MODIFY", "old_path": "test/TemplateTest-JavaScript.js", "new_path": "test/TemplateTest-JavaScript.js", "diff": "@@ -152,6 +152,16 @@ test(\"JavaScript template type (class with data permalink function using a buffe\nt.is(await tmpl.getOutputPath(), \"./dist/my-permalink/value1/index.html\");\n});\n+test(\"JavaScript template type (class with data permalink async function)\", async t => {\n+ let tmpl = new Template(\n+ \"./test/stubs/class-data-permalink-async-fn.11ty.js\",\n+ \"./test/stubs/\",\n+ \"./dist\"\n+ );\n+\n+ t.is(await tmpl.getOutputPath(), \"./dist/my-permalink/value1/index.html\");\n+});\n+\ntest(\"JavaScript template type (class with data permalink function using a filter)\", async t => {\nlet tmpl = new Template(\n\"./test/stubs/class-data-permalink-fn-filter.11ty.js\",\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/class-data-permalink-async-fn.11ty.js", "diff": "+class Test {\n+ get data() {\n+ return {\n+ key: \"value1\",\n+ permalink: async function(data) {\n+ return new Promise((resolve, reject) => {\n+ setTimeout(function() {\n+ resolve(`/my-permalink/${data.key}/`);\n+ }, 100);\n+ });\n+ }\n+ };\n+ }\n+\n+ render({ name }) {\n+ return `<p>${name}</p>`;\n+ }\n+}\n+\n+module.exports = Test;\n" } ]
JavaScript
MIT License
11ty/eleventy
Permalink async function
699
06.01.2019 21:14:29
21,600
0d4e9d9b03a7837f65b058befc87eb5d4dc6a221
Another test for JS templates
[ { "change_type": "MODIFY", "old_path": "test/TemplateRenderJavaScriptTest.js", "new_path": "test/TemplateRenderJavaScriptTest.js", "diff": "@@ -38,6 +38,14 @@ test(\"JS Render a function\", async t => {\nt.is(await fn({ name: \"Bill\" }), \"<p>Bill</p>\");\n});\n+test(\"JS Render a function (arrow syntax)\", async t => {\n+ let fn = await new TemplateRender(\n+ \"./test/stubs/function-arrow.11ty.js\"\n+ ).getCompiledTemplate();\n+ t.is(await fn({ name: \"Zach\" }), \"<p>Zach</p>\");\n+ t.is(await fn({ name: \"Bill\" }), \"<p>Bill</p>\");\n+});\n+\ntest(\"JS Render a function, returns a Buffer\", async t => {\nlet fn = await new TemplateRender(\n\"./test/stubs/function-buffer.11ty.js\"\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/function-arrow.11ty.js", "diff": "+module.exports = ({ name }) => `<p>${name}</p>`;\n" } ]
JavaScript
MIT License
11ty/eleventy
Another test for JS templates
669
08.01.2019 17:40:05
-3,600
05cbdc93a04e783b871239f02aa9fb67f88edec2
Fix: Tests invoking illegal constructor TemplateData()
[ { "change_type": "MODIFY", "old_path": "test/TemplateTest.js", "new_path": "test/TemplateTest.js", "diff": "@@ -414,7 +414,7 @@ test(\"Layout from template-data-file that has a permalink (fileslug) Issue #121\"\n});\ntest(\"Local template data file import (without a global data json)\", async t => {\n- let dataObj = new TemplateData();\n+ let dataObj = new TemplateData(\"./test/stubs/\");\nawait dataObj.cacheData();\nlet tmpl = new Template(\n@@ -435,7 +435,7 @@ test(\"Local template data file import (without a global data json)\", async t =>\n});\ntest(\"Local template data file import (two subdirectories deep)\", async t => {\n- let dataObj = new TemplateData();\n+ let dataObj = new TemplateData(\"./test/stubs/\");\nawait dataObj.cacheData();\nlet tmpl = new Template(\n@@ -459,7 +459,7 @@ test(\"Local template data file import (two subdirectories deep)\", async t => {\n});\ntest(\"Posts inherits local JSON, layouts\", async t => {\n- let dataObj = new TemplateData();\n+ let dataObj = new TemplateData(\"./test/stubs/\");\nawait dataObj.cacheData();\nlet tmpl = new Template(\n@@ -494,7 +494,7 @@ test(\"Posts inherits local JSON, layouts\", async t => {\n});\ntest(\"Template and folder name are the same, make sure data imports work ok\", async t => {\n- let dataObj = new TemplateData();\n+ let dataObj = new TemplateData(\"./test/stubs/\");\nawait dataObj.cacheData();\nlet tmpl = new Template(\n@@ -1194,7 +1194,7 @@ test(\"Data Cascade (Deep merge)\", async t => {\nlet newConfig = Object.assign({}, config);\nnewConfig.dataDeepMerge = true;\n- let dataObj = new TemplateData();\n+ let dataObj = new TemplateData(\"./test/\");\ndataObj._setConfig(newConfig);\nawait dataObj.cacheData();\n@@ -1226,7 +1226,7 @@ test(\"Data Cascade (Deep merge)\", async t => {\n});\ntest(\"Data Cascade (Shallow merge)\", async t => {\n- let dataObj = new TemplateData();\n+ let dataObj = new TemplateData(\"./test/\");\nawait dataObj.cacheData();\nlet tmpl = new Template(\n@@ -1255,7 +1255,7 @@ test(\"Data Cascade Tag Merge (Deep merge)\", async t => {\nlet newConfig = Object.assign({}, config);\nnewConfig.dataDeepMerge = true;\n- let dataObj = new TemplateData();\n+ let dataObj = new TemplateData(\"./test/stubs/\");\ndataObj._setConfig(newConfig);\nawait dataObj.cacheData();\n@@ -1272,7 +1272,7 @@ test(\"Data Cascade Tag Merge (Deep merge)\", async t => {\n});\ntest(\"Data Cascade Tag Merge (Shallow merge)\", async t => {\n- let dataObj = new TemplateData();\n+ let dataObj = new TemplateData(\"./test/stubs/\");\nawait dataObj.cacheData();\nlet tmpl = new Template(\n" } ]
JavaScript
MIT License
11ty/eleventy
Fix: Tests invoking illegal constructor TemplateData()
669
09.01.2019 10:25:05
-3,600
4609e373aada81e1bef5c0928cf74ddc9cf47a7b
Join paths together correctly with TemplatePath utility
[ { "change_type": "MODIFY", "old_path": "src/EleventyFiles.js", "new_path": "src/EleventyFiles.js", "diff": "@@ -18,7 +18,10 @@ class EleventyFiles {\nthis.inputDir = TemplatePath.getDir(this.input);\nthis.outputDir = outputDir;\n- this.includesDir = this.inputDir + \"/\" + this.config.dir.includes;\n+ this.includesDir = TemplatePath.normalize(\n+ this.inputDir,\n+ this.config.dir.includes\n+ );\nthis.passthroughAll = !!passthroughAll;\nthis.formats = formats;\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateConfig.js", "new_path": "src/TemplateConfig.js", "diff": "@@ -68,7 +68,9 @@ class TemplateConfig {\nlet overrides = [\"templateFormats\"];\nlet localConfig = {};\nlet path = TemplatePath.normalize(\n- TemplatePath.getWorkingDir() + \"/\" + localProjectConfigPath\n+ TemplatePath.getWorkingDir(),\n+ \"/\",\n+ localProjectConfigPath\n);\ndebug(`Merging config with ${path}`);\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateData.js", "new_path": "src/TemplateData.js", "diff": "@@ -34,10 +34,9 @@ class TemplateData {\nsetInputDir(inputDir) {\nthis.inputDirNeedsCheck = true;\nthis.inputDir = inputDir;\n- this.dataDir =\n- inputDir +\n- \"/\" +\n- (this.config.dir.data !== \".\" ? this.config.dir.data : \"\");\n+ this.dataDir = this.config.dir.data\n+ ? TemplatePath.normalize(inputDir, this.config.dir.data)\n+ : inputDir;\n}\nsetDataTemplateEngine(engineName) {\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateLayout.js", "new_path": "src/TemplateLayout.js", "diff": "const TemplateLayoutPathResolver = require(\"./TemplateLayoutPathResolver\");\nconst TemplateContent = require(\"./TemplateContent\");\nconst TemplateData = require(\"./TemplateData\");\n+const TemplatePath = require(\"./TemplatePath\");\nconst templateCache = require(\"./TemplateCache\");\nconst config = require(\"./Config\");\n@@ -11,7 +12,7 @@ class TemplateLayout extends TemplateContent {\nconstructor(key, inputDir) {\n// TODO getConfig() is duplicated in TemplateContent (super)\nlet cfg = config.getConfig();\n- let layoutsDir = inputDir + \"/\" + cfg.dir.includes;\n+ let layoutsDir = TemplatePath.normalize(inputDir, cfg.dir.includes);\nlet resolvedPath = new TemplateLayoutPathResolver(\nkey,\nlayoutsDir\n@@ -25,7 +26,7 @@ class TemplateLayout extends TemplateContent {\n}\nstatic resolveFullKey(key, inputDir) {\n- return inputDir + key;\n+ return TemplatePath.normalize(inputDir, key);\n}\nstatic getTemplate(key, inputDir, config) {\n" }, { "change_type": "MODIFY", "old_path": "src/TemplatePermalink.js", "new_path": "src/TemplatePermalink.js", "diff": "@@ -13,9 +13,7 @@ TemplatePermalink.prototype._cleanLink = function(link) {\nTemplatePermalink.prototype.resolve = function() {\nlet parsed = parsePath(this.link);\n- return TemplatePath.normalize(\n- parsed.dir + \"/\" + this.extraSubdir + parsed.base // name with extension\n- );\n+ return TemplatePath.normalize(parsed.dir, \"/\", this.extraSubdir, parsed.base);\n};\nTemplatePermalink.prototype.toString = function() {\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateRender.js", "new_path": "src/TemplateRender.js", "diff": "@@ -156,9 +156,10 @@ class TemplateRender {\n}\n_normalizeInputDir(dir) {\n- return dir\n- ? TemplatePath.normalize(dir, this.config.dir.includes)\n- : TemplatePath.normalize(this.config.dir.input, this.config.dir.includes);\n+ return TemplatePath.normalize(\n+ dir ? dir : this.config.dir.input,\n+ this.config.dir.includes\n+ );\n}\ngetInputDir() {\n" }, { "change_type": "MODIFY", "old_path": "test/EleventyFilesTest.js", "new_path": "test/EleventyFilesTest.js", "diff": "@@ -277,7 +277,7 @@ test(\"Get ignores (both .eleventyignore and .gitignore, using setUseGitIgnore(fa\ntest(\"getDataDir\", t => {\nlet evf = new EleventyFiles(\".\", \"_site\", []);\nevf.init();\n- t.is(evf.getDataDir(), \"./_data\");\n+ t.is(evf.getDataDir(), \"_data\");\n});\ntest(\"getDataDir subdir\", t => {\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateLayoutTest.js", "new_path": "test/TemplateLayoutTest.js", "diff": "@@ -4,7 +4,7 @@ import TemplateLayout from \"../src/TemplateLayout\";\ntest(\"Creation\", t => {\nt.is(\nnew TemplateLayout(\"base\", \"./test/stubs\").getInputPath(),\n- \"./test/stubs/_includes/base.njk\"\n+ \"test/stubs/_includes/base.njk\"\n);\nt.throws(() => {\n@@ -14,10 +14,7 @@ test(\"Creation\", t => {\ntest(\"Get Front Matter Data\", async t => {\nlet tl = new TemplateLayout(\"layouts/layout-inherit-a.njk\", \"./test/stubs\");\n- t.is(\n- tl.getInputPath(),\n- \"./test/stubs/_includes/layouts/layout-inherit-a.njk\"\n- );\n+ t.is(tl.getInputPath(), \"test/stubs/_includes/layouts/layout-inherit-a.njk\");\nt.deepEqual(await tl.getData(), {\ninherits: \"a\",\n" } ]
JavaScript
MIT License
11ty/eleventy
Join paths together correctly with TemplatePath utility
669
09.01.2019 11:17:33
-3,600
cc9830f89aa31357926e633c8b4fc5b3e3d83dc8
Separate normalize and join methods
[ { "change_type": "MODIFY", "old_path": "docs-src/.eleventy.docs.js", "new_path": "docs-src/.eleventy.docs.js", "diff": "@@ -11,7 +11,7 @@ module.exports = {\nremoveDir: function(str) {\nreturn TemplatePath.stripPathFromDir(\nstr,\n- TemplatePath.normalize(__dirname, \"..\")\n+ TemplatePath.join(__dirname, \"..\")\n);\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "src/EleventyFiles.js", "new_path": "src/EleventyFiles.js", "diff": "@@ -18,7 +18,7 @@ class EleventyFiles {\nthis.inputDir = TemplatePath.getDir(this.input);\nthis.outputDir = outputDir;\n- this.includesDir = TemplatePath.normalize(\n+ this.includesDir = TemplatePath.join(\nthis.inputDir,\nthis.config.dir.includes\n);\n@@ -190,11 +190,11 @@ class EleventyFiles {\nfiles = files.concat(\nEleventyFiles.getFileIgnores(\n[\n- TemplatePath.normalize(\n+ TemplatePath.join(\nthis.localPathRoot || TemplatePath.localPath(),\n\".gitignore\"\n),\n- TemplatePath.normalize(this.inputDir, \".gitignore\")\n+ TemplatePath.join(this.inputDir, \".gitignore\")\n],\n\"node_modules/**\"\n)\n@@ -203,11 +203,11 @@ class EleventyFiles {\nfiles = files.concat(\nEleventyFiles.getFileIgnores([\n- TemplatePath.normalize(\n+ TemplatePath.join(\nthis.localPathRoot || TemplatePath.localPath(),\n\".eleventyignore\"\n),\n- TemplatePath.normalize(this.inputDir, \".eleventyignore\")\n+ TemplatePath.join(this.inputDir, \".eleventyignore\")\n])\n);\n" }, { "change_type": "MODIFY", "old_path": "src/EleventyServe.js", "new_path": "src/EleventyServe.js", "diff": "@@ -22,11 +22,11 @@ class EleventyServe {\n}\ngetRedirectDir(dirName) {\n- return TemplatePath.normalize(this.outputDir, dirName);\n+ return TemplatePath.join(this.outputDir, dirName);\n}\ngetRedirectFilename(dirName) {\n- return TemplatePath.normalize(this.getRedirectDir(dirName), \"index.html\");\n+ return TemplatePath.join(this.getRedirectDir(dirName), \"index.html\");\n}\ncleanupRedirect(dirName) {\n@@ -106,7 +106,7 @@ class EleventyServe {\n// if has a savedPathPrefix, use the /savedPathPrefix/index.html template to redirect to /pathPrefix/\nif (this.savedPathPrefix) {\n- serverConfig.routes[this.savedPathPrefix] = TemplatePath.normalize(\n+ serverConfig.routes[this.savedPathPrefix] = TemplatePath.join(\nthis.outputDir,\nthis.savedPathPrefix\n);\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateConfig.js", "new_path": "src/TemplateConfig.js", "diff": "@@ -67,7 +67,7 @@ class TemplateConfig {\nmergeConfig(localProjectConfigPath) {\nlet overrides = [\"templateFormats\"];\nlet localConfig = {};\n- let path = TemplatePath.normalize(\n+ let path = TemplatePath.join(\nTemplatePath.getWorkingDir(),\n\"/\",\nlocalProjectConfigPath\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateData.js", "new_path": "src/TemplateData.js", "diff": "@@ -35,7 +35,7 @@ class TemplateData {\nthis.inputDirNeedsCheck = true;\nthis.inputDir = inputDir;\nthis.dataDir = this.config.dir.data\n- ? TemplatePath.normalize(inputDir, this.config.dir.data)\n+ ? TemplatePath.join(inputDir, this.config.dir.data)\n: inputDir;\n}\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateGlob.js", "new_path": "src/TemplateGlob.js", "diff": "@@ -9,7 +9,7 @@ class TemplateGlob {\n)}`\n);\n}\n- return TemplatePath.addLeadingDotSlash(TemplatePath.normalize(...paths));\n+ return TemplatePath.addLeadingDotSlash(TemplatePath.join(...paths));\n}\nstatic normalize(path) {\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateLayout.js", "new_path": "src/TemplateLayout.js", "diff": "@@ -12,7 +12,7 @@ class TemplateLayout extends TemplateContent {\nconstructor(key, inputDir) {\n// TODO getConfig() is duplicated in TemplateContent (super)\nlet cfg = config.getConfig();\n- let layoutsDir = TemplatePath.normalize(inputDir, cfg.dir.includes);\n+ let layoutsDir = TemplatePath.join(inputDir, cfg.dir.includes);\nlet resolvedPath = new TemplateLayoutPathResolver(\nkey,\nlayoutsDir\n@@ -26,7 +26,7 @@ class TemplateLayout extends TemplateContent {\n}\nstatic resolveFullKey(key, inputDir) {\n- return TemplatePath.normalize(inputDir, key);\n+ return TemplatePath.join(inputDir, key);\n}\nstatic getTemplate(key, inputDir, config) {\n" }, { "change_type": "MODIFY", "old_path": "src/TemplatePassthrough.js", "new_path": "src/TemplatePassthrough.js", "diff": "@@ -11,7 +11,7 @@ class TemplatePassthrough {\n}\ngetOutputPath() {\n- return TemplatePath.normalize(\n+ return TemplatePath.join(\nthis.outputDir,\nTemplatePath.stripPathFromDir(this.path, this.inputDir)\n);\n" }, { "change_type": "MODIFY", "old_path": "src/TemplatePermalink.js", "new_path": "src/TemplatePermalink.js", "diff": "@@ -13,7 +13,7 @@ TemplatePermalink.prototype._cleanLink = function(link) {\nTemplatePermalink.prototype.resolve = function() {\nlet parsed = parsePath(this.link);\n- return TemplatePath.normalize(parsed.dir, \"/\", this.extraSubdir, parsed.base);\n+ return TemplatePath.join(parsed.dir, \"/\", this.extraSubdir, parsed.base);\n};\nTemplatePermalink.prototype.toString = function() {\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateRender.js", "new_path": "src/TemplateRender.js", "diff": "@@ -156,7 +156,7 @@ class TemplateRender {\n}\n_normalizeInputDir(dir) {\n- return TemplatePath.normalize(\n+ return TemplatePath.join(\ndir ? dir : this.config.dir.input,\nthis.config.dir.includes\n);\n" }, { "change_type": "MODIFY", "old_path": "test/TemplatePathTest.js", "new_path": "test/TemplatePathTest.js", "diff": "@@ -8,7 +8,7 @@ test(\"Working dir\", t => {\nt.is(TemplatePath.getModuleDir(), path.resolve(__dirname, \"..\"));\n});\n-test(\"Normalizer\", async t => {\n+test(\"normalize\", async t => {\nt.is(TemplatePath.normalize(\"\"), \".\");\nt.is(TemplatePath.normalize(\".\"), \".\");\nt.is(TemplatePath.normalize(\"/\"), \"/\");\n@@ -23,10 +23,6 @@ test(\"Normalizer\", async t => {\nt.is(TemplatePath.normalize(\"../\"), \"..\");\nt.is(TemplatePath.normalize(\"../testing\"), \"../testing\");\n- t.is(TemplatePath.normalize(\"testing\", \"hello\"), \"testing/hello\");\n- t.is(TemplatePath.normalize(\"testing\", \"hello/\"), \"testing/hello\");\n- t.is(TemplatePath.normalize(\"./testing\", \"hello\"), \"testing/hello\");\n- t.is(TemplatePath.normalize(\"./testing\", \"hello/\"), \"testing/hello\");\nt.is(TemplatePath.normalize(\"./testing/hello\"), \"testing/hello\");\nt.is(TemplatePath.normalize(\"./testing/hello/\"), \"testing/hello\");\n@@ -34,6 +30,22 @@ test(\"Normalizer\", async t => {\nt.is(TemplatePath.normalize(\".htaccess\"), \".htaccess\");\n});\n+test(\"join\", async t => {\n+ t.is(TemplatePath.join(\"src\", \"_includes\"), \"src/_includes\");\n+ t.is(TemplatePath.join(\"src\", \"_includes/\"), \"src/_includes\");\n+ t.is(TemplatePath.join(\"src\", \"/_includes\"), \"src/_includes\");\n+ t.is(TemplatePath.join(\"src\", \"./_includes\"), \"src/_includes\");\n+ t.is(TemplatePath.join(\"src\", \"//_includes\"), \"src/_includes\");\n+\n+ t.is(TemplatePath.join(\"./src\", \"_includes\"), \"src/_includes\");\n+ t.is(TemplatePath.join(\"./src\", \"_includes/\"), \"src/_includes\");\n+ t.is(TemplatePath.join(\"./src\", \"/_includes\"), \"src/_includes\");\n+ t.is(TemplatePath.join(\"./src\", \"./_includes\"), \"src/_includes\");\n+ t.is(TemplatePath.join(\"./src\", \"//_includes\"), \"src/_includes\");\n+\n+ t.is(TemplatePath.join(\"src\", \"test\", \"..\", \"_includes\"), \"src/_includes\");\n+});\n+\ntest(\"stripLeadingDotSlash\", t => {\nt.is(TemplatePath.stripLeadingDotSlash(\"./test/stubs\"), \"test/stubs\");\nt.is(TemplatePath.stripLeadingDotSlash(\"./dist\"), \"dist\");\n" } ]
JavaScript
MIT License
11ty/eleventy
Separate normalize and join methods
669
10.01.2019 15:12:17
-3,600
91eb48b88ff58afb3270c76f778c97c4324d1d84
Remove superfluous slash in call to TemplatePath.join
[ { "change_type": "MODIFY", "old_path": "src/TemplateConfig.js", "new_path": "src/TemplateConfig.js", "diff": "@@ -69,7 +69,6 @@ class TemplateConfig {\nlet localConfig = {};\nlet path = TemplatePath.join(\nTemplatePath.getWorkingDir(),\n- \"/\",\nlocalProjectConfigPath\n);\ndebug(`Merging config with ${path}`);\n" }, { "change_type": "MODIFY", "old_path": "src/TemplatePermalink.js", "new_path": "src/TemplatePermalink.js", "diff": "@@ -13,7 +13,7 @@ TemplatePermalink.prototype._cleanLink = function(link) {\nTemplatePermalink.prototype.resolve = function() {\nlet parsed = parsePath(this.link);\n- return TemplatePath.join(parsed.dir, \"/\", this.extraSubdir, parsed.base);\n+ return TemplatePath.join(parsed.dir, this.extraSubdir, parsed.base);\n};\nTemplatePermalink.prototype.toString = function() {\n" } ]
JavaScript
MIT License
11ty/eleventy
Remove superfluous slash in call to TemplatePath.join
699
10.01.2019 08:36:16
21,600
3115dd40512707cb96e6fd11097196a2a46ad167
Skipped failing Test for
[ { "change_type": "MODIFY", "old_path": "test/TemplateMapTest.js", "new_path": "test/TemplateMapTest.js", "diff": "@@ -445,6 +445,7 @@ test(\"Should be able to paginate a user config collection (paged template is als\nlet tm = new TemplateMap();\nawait tm.add(tmpl1);\nawait tm.add(tmpl2);\n+ await tm.add(tmpl4);\nlet pagedTmpl = new Template(\n\"./test/stubs/templateMapCollection/paged-cfg-tagged.md\",\n@@ -461,8 +462,10 @@ test(\"Should be able to paginate a user config collection (paged template is als\n});\nlet collections = await tm.getCollectionsData();\n+ t.is(collections.dog.length, 2);\n+\nt.truthy(collections.haha);\n- t.truthy(collections.haha.length);\n+ t.is(collections.haha.length, 1);\nt.is(collections.haha[0].url, \"/templateMapCollection/paged-cfg-tagged/\");\n});\n@@ -566,3 +569,32 @@ test(\"Should be able to paginate a tag generated collection when aliased (and it\n<p>After</p>`\n);\n});\n+\n+test.skip(\"Issue #253: Paginated template with a tag should put multiple pages into a collection\", async t => {\n+ let tm = new TemplateMap();\n+ await tm.add(tmpl1);\n+ await tm.add(tmpl2);\n+ await tm.add(tmpl4);\n+\n+ let pagedTmpl = new Template(\n+ \"./test/stubs/tagged-pagination-multiples/test.njk\",\n+ \"./test/stubs/\",\n+ \"./test/stubs/_site\"\n+ );\n+ await tm.add(pagedTmpl);\n+\n+ tm.setUserConfigCollections({\n+ userCollection: function(collection) {\n+ let all = collection.getFilteredByTag(\"dog\");\n+ return all;\n+ }\n+ });\n+\n+ let collections = await tm.getCollectionsData();\n+ t.is(collections.dog.length, 2);\n+\n+ t.truthy(collections.haha);\n+ t.is(collections.haha.length, 2);\n+ t.is(collections.haha[0].url, \"/tagged-pagination-multiples/test/\");\n+ t.is(collections.haha[1].url, \"/tagged-pagination-multiples/test/1/\");\n+});\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/tagged-pagination-multiples/test.njk", "diff": "+---\n+title: Paged Test\n+tags:\n+ - haha\n+pagination:\n+ data: collections.userCollection\n+ size: 1\n+ alias: item\n+---\n+\n+{{ title }}\n\\ No newline at end of file\n" } ]
JavaScript
MIT License
11ty/eleventy
Skipped failing Test for #253
699
10.01.2019 09:23:30
21,600
f2218f8e83d3ab137f6bfad6f682ebae0e789a98
Removes config options for template aliases
[ { "change_type": "MODIFY", "old_path": "src/EleventyExtensionMap.js", "new_path": "src/EleventyExtensionMap.js", "diff": "@@ -2,22 +2,25 @@ const TemplatePath = require(\"./TemplatePath\");\nconst config = require(\"./Config\");\nclass EleventyExtensionMap {\n- constructor(formats = []) {\n- this.config = config.getConfig();\n-\n- this.unfilteredFormats = formats.map(function(key) {\n+ constructor(formatKeys = []) {\n+ this.unfilteredFormatKeys = formatKeys.map(function(key) {\nreturn key.trim().toLowerCase();\n});\n- this.formats = this.unfilteredFormats.filter(key => this.hasExtension(key));\n+ this.formatKeys = this.unfilteredFormatKeys.filter(key =>\n+ this.hasExtension(key)\n+ );\n- this.prunedFormats = this.unfilteredFormats.filter(\n+ this.prunedFormatKeys = this.unfilteredFormatKeys.filter(\nkey => !this.hasExtension(key)\n);\n}\n- setConfig(configOverride) {\n- this.config = configOverride || {};\n+ get config() {\n+ return this.configOverride || config.getConfig();\n+ }\n+ set config(cfg) {\n+ this.configOverride = cfg;\n}\n/* Used for layout path resolution */\n@@ -27,9 +30,9 @@ class EleventyExtensionMap {\n}\nlet files = [];\n- this.formats.forEach(\n+ this.formatKeys.forEach(\nfunction(key) {\n- this.getExtensions(key).forEach(function(extension) {\n+ this.getExtensionsFromKey(key).forEach(function(extension) {\nfiles.push((dir ? dir + \"/\" : \"\") + path + \".\" + extension);\n});\n}.bind(this)\n@@ -39,24 +42,24 @@ class EleventyExtensionMap {\n}\ngetPrunedGlobs(inputDir) {\n- return this._getGlobs(this.prunedFormats, inputDir);\n+ return this._getGlobs(this.prunedFormatKeys, inputDir);\n}\ngetGlobs(inputDir) {\nif (this.config.passthroughFileCopy) {\n- return this._getGlobs(this.unfilteredFormats, inputDir);\n+ return this._getGlobs(this.unfilteredFormatKeys, inputDir);\n}\n- return this._getGlobs(this.formats, inputDir);\n+ return this._getGlobs(this.formatKeys, inputDir);\n}\n- _getGlobs(formats, inputDir) {\n+ _getGlobs(formatKeys, inputDir) {\nlet dir = TemplatePath.convertToGlob(inputDir);\nlet globs = [];\n- formats.forEach(\n+ formatKeys.forEach(\nfunction(key) {\nif (this.hasExtension(key)) {\n- this.getExtensions(key).forEach(function(extension) {\n+ this.getExtensionsFromKey(key).forEach(function(extension) {\nglobs.push(dir + \"/*.\" + extension);\n});\n} else {\n@@ -76,10 +79,6 @@ class EleventyExtensionMap {\nreturn false;\n}\n- getExtensions(key) {\n- return this.getExtensionsFromKey(key);\n- }\n-\ngetExtensionsFromKey(key) {\nlet extensions = [];\nfor (var extension in this.keyMap) {\n@@ -129,13 +128,12 @@ class EleventyExtensionMap {\nget keyMap() {\nreturn EleventyExtensionMap._getKeyMap(\n- this.config.templateExtensionAliases\n+ this.config.templateExtensionAliases || {}\n);\n}\n-\nstatic get keyMap() {\nreturn EleventyExtensionMap._getKeyMap(\n- config.getConfig().templateExtensionAliases\n+ config.getConfig().templateExtensionAliases || {}\n);\n}\n" }, { "change_type": "MODIFY", "old_path": "src/UserConfig.js", "new_path": "src/UserConfig.js", "diff": "@@ -51,7 +51,7 @@ class UserConfig {\nthis.dataDeepMerge = false;\nthis.experiments = new Set();\n// this.userExtensionMap = {};\n- this.templateExtensionAliases = {};\n+ // this.templateExtensionAliases = {};\nthis.watchJavaScriptDependencies = true;\nthis.browserSyncConfig = {};\n}\n@@ -483,9 +483,9 @@ class UserConfig {\nthis.dataDeepMerge = !!deepMerge;\n}\n- addTemplateExtensionAlias(targetKey, extension) {\n- this.templateExtensionAliases[extension] = targetKey;\n- }\n+ // addTemplateExtensionAlias(targetKey, extension) {\n+ // this.templateExtensionAliases[extension] = targetKey;\n+ // }\nsetWatchJavaScriptDependencies(watchEnabled) {\nthis.watchJavaScriptDependencies = !!watchEnabled;\n@@ -524,7 +524,7 @@ class UserConfig {\nuseGitIgnore: this.useGitIgnore,\ndataDeepMerge: this.dataDeepMerge,\nexperiments: this.experiments,\n- templateExtensionAliases: this.templateExtensionAliases,\n+ // templateExtensionAliases: this.templateExtensionAliases,\nwatchJavaScriptDependencies: this.watchJavaScriptDependencies,\nbrowserSyncConfig: this.browserSyncConfig\n};\n" }, { "change_type": "MODIFY", "old_path": "test/EleventyExtensionMapTest.js", "new_path": "test/EleventyExtensionMapTest.js", "diff": "@@ -18,17 +18,17 @@ test(\"Multiple formats\", t => {\ntest(\"Invalid keys are filtered (no passthrough copy)\", t => {\nlet map = new EleventyExtensionMap([\"lksdjfjlsk\"]);\n- map.setConfig({\n+ map.config = {\npassthroughFileCopy: false\n- });\n+ };\nt.deepEqual(map.getGlobs(), []);\n});\ntest(\"Invalid keys are filtered (using passthrough copy)\", t => {\nlet map = new EleventyExtensionMap([\"lksdjfjlsk\"]);\n- map.setConfig({\n+ map.config = {\npassthroughFileCopy: true\n- });\n+ };\nt.deepEqual(map.getGlobs(), [\"./**/*.lksdjfjlsk\"]);\n});\n@@ -110,12 +110,12 @@ test(\"getKey\", t => {\ntest(\"Extension aliasing (one format key)\", t => {\nlet map = new EleventyExtensionMap([\"md\"]);\n- map.setConfig({\n+ map.config = {\ntemplateExtensionAliases: {\nmarkdown: \"md\",\nnunjucks: \"njk\" // N/A to current format list\n}\n- });\n+ };\nt.deepEqual(map.getExtensionsFromKey(\"md\"), [\"md\", \"markdown\"]);\nt.deepEqual(map.getExtensionsFromKey(\"njk\"), [\"njk\", \"nunjucks\"]);\n@@ -125,12 +125,12 @@ test(\"Extension aliasing (one format key)\", t => {\ntest(\"Extension aliasing (two format keys)\", t => {\nlet map = new EleventyExtensionMap([\"md\", \"njk\"]);\n- map.setConfig({\n+ map.config = {\ntemplateExtensionAliases: {\nmarkdown: \"md\",\nnunjucks: \"njk\"\n}\n- });\n+ };\nt.deepEqual(map.getExtensionsFromKey(\"md\"), [\"md\", \"markdown\"]);\nt.deepEqual(map.getExtensionsFromKey(\"njk\"), [\"njk\", \"nunjucks\"]);\n" }, { "change_type": "MODIFY", "old_path": "test/EleventyFilesTest.js", "new_path": "test/EleventyFilesTest.js", "diff": "@@ -371,11 +371,11 @@ test(\"Glob Watcher Files with passthroughAll\", async t => {\ntest(\"File extension aliasing\", async t => {\nlet map = new EleventyExtensionMap([\"md\"]);\n- map.setConfig({\n+ map.config = {\ntemplateExtensionAliases: {\nmarkdown: \"md\"\n}\n- });\n+ };\nlet evf = new EleventyFiles(\n\"./test/stubs/writeTestMarkdown\",\n" } ]
JavaScript
MIT License
11ty/eleventy
Removes config options for template aliases #207.
699
10.01.2019 09:27:21
21,600
6eba496694a3c36d48f3e478e95f7a51395b162a
Oops broken tests
[ { "change_type": "MODIFY", "old_path": "test/TemplateWriterTest.js", "new_path": "test/TemplateWriterTest.js", "diff": "@@ -464,11 +464,11 @@ test(\"Write Test 11ty.js\", async t => {\ntest(\"Markdown with alias\", async t => {\nlet map = new EleventyExtensionMap([\"md\"]);\n- map.setConfig({\n+ map.config = {\ntemplateExtensionAliases: {\nmarkdown: \"md\"\n}\n- });\n+ };\nlet evf = new EleventyFiles(\n\"./test/stubs/writeTestMarkdown\",\n@@ -511,11 +511,11 @@ test(\"Markdown with alias\", async t => {\ntest(\"JavaScript with alias\", async t => {\nlet map = new EleventyExtensionMap([\"11ty.js\"]);\n- map.setConfig({\n+ map.config = {\ntemplateExtensionAliases: {\njs: \"11ty.js\"\n}\n- });\n+ };\nlet evf = new EleventyFiles(\n\"./test/stubs/writeTestJS\",\n" } ]
JavaScript
MIT License
11ty/eleventy
Oops broken tests #207
699
10.01.2019 10:37:54
21,600
b7af5bbffa00b5acba052cfbad8ff4a04d4d57ff
Upgrade dependencies, unskip one liquid test
[ { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "]\n},\n\"devDependencies\": {\n- \"@11ty/eleventy-plugin-syntaxhighlight\": \"^2.0.0\",\n+ \"@11ty/eleventy-plugin-syntaxhighlight\": \"^2.0.1\",\n\"ava\": \"^1.0.1\",\n- \"husky\": \"^1.0.1\",\n+ \"husky\": \"^1.3.1\",\n\"lint-staged\": \"^8.1.0\",\n\"markdown-it-emoji\": \"^1.4.0\",\n- \"nyc\": \"^13.0.1\",\n+ \"nyc\": \"^13.1.0\",\n\"prettier\": \"^1.15.3\",\n- \"viperhtml\": \"^2.12.0\",\n- \"vue\": \"^2.5.16\",\n- \"vue-server-renderer\": \"^2.5.16\"\n+ \"viperhtml\": \"^2.17.0\",\n+ \"vue\": \"^2.5.21\",\n+ \"vue-server-renderer\": \"^2.5.21\"\n},\n\"dependencies\": {\n- \"browser-sync\": \"^2.24.7\",\n- \"chalk\": \"^2.4.1\",\n+ \"browser-sync\": \"^2.26.3\",\n+ \"chalk\": \"^2.4.2\",\n\"chokidar\": \"^2.0.4\",\n- \"debug\": \"^4.0.1\",\n+ \"debug\": \"^4.1.1\",\n\"dependency-tree\": \"^6.3.0\",\n\"ejs\": \"^2.6.1\",\n- \"fast-glob\": \"^2.2.2\",\n- \"fs-extra\": \"^7.0.0\",\n+ \"fast-glob\": \"^2.2.6\",\n+ \"fs-extra\": \"^7.0.1\",\n\"gray-matter\": \"^4.0.1\",\n\"hamljs\": \"^0.6.2\",\n\"handlebars\": \"^4.0.12\",\n\"javascript-stringify\": \"^1.6.0\",\n- \"liquidjs\": \"^6.0.1\",\n+ \"liquidjs\": \"^6.2.0\",\n\"lodash\": \"^4.17.11\",\n- \"luxon\": \"^1.4.1\",\n+ \"luxon\": \"^1.9.0\",\n\"markdown-it\": \"^8.4.2\",\n\"minimist\": \"^1.2.0\",\n\"moo\": \"^0.5.0\",\n\"multimatch\": \"^2.1.0\",\n\"mustache\": \"^2.3.0\",\n\"normalize-path\": \"^3.0.0\",\n- \"nunjucks\": \"^3.1.4\",\n+ \"nunjucks\": \"^3.1.6\",\n\"parse-filepath\": \"^1.0.2\",\n\"please-upgrade-node\": \"^3.1.1\",\n\"pretty\": \"^2.0.0\",\n\"pug\": \"^2.0.3\",\n\"recursive-copy\": \"^2.0.9\",\n- \"semver\": \"^5.5.1\",\n- \"slugify\": \"^1.3.1\",\n+ \"semver\": \"^5.6.0\",\n+ \"slugify\": \"^1.3.4\",\n\"time-require\": \"^0.1.2\",\n\"valid-url\": \"^1.0.9\"\n},\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateTest.js", "new_path": "test/TemplateTest.js", "diff": "@@ -1211,7 +1211,7 @@ test(\"Front Matter Tags (Multiple)\", async t => {\nt.deepEqual(frontmatter.tags, [\"multi-tag\", \"multi-tag-2\"]);\n});\n-test.skip(\"Front matter date with quotes (liquid), issue #258\", async t => {\n+test(\"Front matter date with quotes (liquid), issue #258\", async t => {\nlet tmpl = new Template(\n\"./test/stubs/frontmatter-date/test.liquid\",\n\"./test/stubs/\",\n@@ -1219,10 +1219,10 @@ test.skip(\"Front matter date with quotes (liquid), issue #258\", async t => {\n);\nlet data = await tmpl.getData();\n- t.is(data.mydate.toISOString(), \"2009-04-15T00:34:34.000Z\");\n+ t.is(data.mydate.toISOString(), \"2009-04-15T11:34:34.000Z\");\nlet pages = await tmpl.getRenderedTemplates(data);\n- t.is(pages[0].templateContent.trim(), `2009-04-15T00:34:34.000Z`);\n+ t.is(pages[0].templateContent.trim(), \"2009-04-15\");\n});\ntest(\"Front matter date with quotes (njk), issue #258\", async t => {\n" }, { "change_type": "MODIFY", "old_path": "test/stubs/frontmatter-date/test.liquid", "new_path": "test/stubs/frontmatter-date/test.liquid", "diff": "---\n-mydate: 2009-04-15T01:34:34+01:00\n+mydate: 2009-04-15T12:34:34+01:00\n---\n-{{ mydate | date: \"%Y-%m-%d %H:%M:%S\" }}\n\\ No newline at end of file\n+{{ mydate | date: \"%Y-%m-%d\" }}\n\\ No newline at end of file\n" } ]
JavaScript
MIT License
11ty/eleventy
Upgrade dependencies, unskip one liquid test
699
10.01.2019 11:03:15
21,600
34b028f72a03805b1fa652ad97028f866cfbfc3c
Eligible major version updates (purposefully not upgrading mustache and dependency-tree)
[ { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "\"markdown-it\": \"^8.4.2\",\n\"minimist\": \"^1.2.0\",\n\"moo\": \"^0.5.0\",\n- \"multimatch\": \"^2.1.0\",\n+ \"multimatch\": \"^3.0.0\",\n\"mustache\": \"^2.3.0\",\n\"normalize-path\": \"^3.0.0\",\n\"nunjucks\": \"^3.1.6\",\n" } ]
JavaScript
MIT License
11ty/eleventy
Eligible major version updates (purposefully not upgrading mustache and dependency-tree)
699
10.01.2019 21:06:46
21,600
fd729bb5127bc7f8bdf09a1599eb2772b6d94cdf
0.7.0 coverage
[ { "change_type": "MODIFY", "old_path": "docs-src/_data/coverage.json", "new_path": "docs-src/_data/coverage.json", "diff": "-{\"total\": {\"lines\":{\"total\":2258,\"covered\":1980,\"skipped\":0,\"pct\":87.69},\"statements\":{\"total\":2263,\"covered\":1985,\"skipped\":0,\"pct\":87.72},\"functions\":{\"total\":532,\"covered\":457,\"skipped\":0,\"pct\":85.9},\"branches\":{\"total\":808,\"covered\":620,\"skipped\":0,\"pct\":76.73}}\n+{\"total\": {\"lines\":{\"total\":2503,\"covered\":2205,\"skipped\":0,\"pct\":88.09},\"statements\":{\"total\":2507,\"covered\":2209,\"skipped\":0,\"pct\":88.11},\"functions\":{\"total\":613,\"covered\":533,\"skipped\":0,\"pct\":86.95},\"branches\":{\"total\":913,\"covered\":727,\"skipped\":0,\"pct\":79.63}}\n,\"/Users/zachleat/Code/eleventy/config.js\": {\"lines\":{\"total\":6,\"covered\":6,\"skipped\":0,\"pct\":100},\"functions\":{\"total\":1,\"covered\":1,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":6,\"covered\":6,\"skipped\":0,\"pct\":100},\"branches\":{\"total\":0,\"covered\":0,\"skipped\":0,\"pct\":100}}\n,\"/Users/zachleat/Code/eleventy/src/Benchmark.js\": {\"lines\":{\"total\":12,\"covered\":11,\"skipped\":0,\"pct\":91.67},\"functions\":{\"total\":6,\"covered\":5,\"skipped\":0,\"pct\":83.33},\"statements\":{\"total\":12,\"covered\":11,\"skipped\":0,\"pct\":91.67},\"branches\":{\"total\":6,\"covered\":4,\"skipped\":0,\"pct\":66.67}}\n,\"/Users/zachleat/Code/eleventy/src/BenchmarkGroup.js\": {\"lines\":{\"total\":29,\"covered\":22,\"skipped\":0,\"pct\":75.86},\"functions\":{\"total\":6,\"covered\":5,\"skipped\":0,\"pct\":83.33},\"statements\":{\"total\":29,\"covered\":22,\"skipped\":0,\"pct\":75.86},\"branches\":{\"total\":6,\"covered\":3,\"skipped\":0,\"pct\":50}}\n,\"/Users/zachleat/Code/eleventy/src/BenchmarkManager.js\": {\"lines\":{\"total\":17,\"covered\":13,\"skipped\":0,\"pct\":76.47},\"functions\":{\"total\":7,\"covered\":5,\"skipped\":0,\"pct\":71.43},\"statements\":{\"total\":17,\"covered\":13,\"skipped\":0,\"pct\":76.47},\"branches\":{\"total\":4,\"covered\":2,\"skipped\":0,\"pct\":50}}\n,\"/Users/zachleat/Code/eleventy/src/Config.js\": {\"lines\":{\"total\":5,\"covered\":5,\"skipped\":0,\"pct\":100},\"functions\":{\"total\":0,\"covered\":0,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":5,\"covered\":5,\"skipped\":0,\"pct\":100},\"branches\":{\"total\":0,\"covered\":0,\"skipped\":0,\"pct\":100}}\n-,\"/Users/zachleat/Code/eleventy/src/Eleventy.js\": {\"lines\":{\"total\":152,\"covered\":89,\"skipped\":0,\"pct\":58.55},\"functions\":{\"total\":23,\"covered\":10,\"skipped\":0,\"pct\":43.48},\"statements\":{\"total\":152,\"covered\":89,\"skipped\":0,\"pct\":58.55},\"branches\":{\"total\":44,\"covered\":15,\"skipped\":0,\"pct\":34.09}}\n+,\"/Users/zachleat/Code/eleventy/src/Eleventy.js\": {\"lines\":{\"total\":193,\"covered\":114,\"skipped\":0,\"pct\":59.07},\"functions\":{\"total\":31,\"covered\":16,\"skipped\":0,\"pct\":51.61},\"statements\":{\"total\":193,\"covered\":114,\"skipped\":0,\"pct\":59.07},\"branches\":{\"total\":48,\"covered\":22,\"skipped\":0,\"pct\":45.83}}\n,\"/Users/zachleat/Code/eleventy/src/EleventyBaseError.js\": {\"lines\":{\"total\":5,\"covered\":5,\"skipped\":0,\"pct\":100},\"functions\":{\"total\":1,\"covered\":1,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":5,\"covered\":5,\"skipped\":0,\"pct\":100},\"branches\":{\"total\":0,\"covered\":0,\"skipped\":0,\"pct\":100}}\n,\"/Users/zachleat/Code/eleventy/src/EleventyCommandCheck.js\": {\"lines\":{\"total\":28,\"covered\":28,\"skipped\":0,\"pct\":100},\"functions\":{\"total\":5,\"covered\":5,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":28,\"covered\":28,\"skipped\":0,\"pct\":100},\"branches\":{\"total\":8,\"covered\":7,\"skipped\":0,\"pct\":87.5}}\n,\"/Users/zachleat/Code/eleventy/src/EleventyConfig.js\": {\"lines\":{\"total\":2,\"covered\":2,\"skipped\":0,\"pct\":100},\"functions\":{\"total\":0,\"covered\":0,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":2,\"covered\":2,\"skipped\":0,\"pct\":100},\"branches\":{\"total\":0,\"covered\":0,\"skipped\":0,\"pct\":100}}\n-,\"/Users/zachleat/Code/eleventy/src/EleventyErrorHandler.js\": {\"lines\":{\"total\":22,\"covered\":19,\"skipped\":0,\"pct\":86.36},\"functions\":{\"total\":6,\"covered\":5,\"skipped\":0,\"pct\":83.33},\"statements\":{\"total\":22,\"covered\":19,\"skipped\":0,\"pct\":86.36},\"branches\":{\"total\":17,\"covered\":9,\"skipped\":0,\"pct\":52.94}}\n-,\"/Users/zachleat/Code/eleventy/src/EleventyExtensionMap.js\": {\"lines\":{\"total\":28,\"covered\":28,\"skipped\":0,\"pct\":100},\"functions\":{\"total\":16,\"covered\":16,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":29,\"covered\":29,\"skipped\":0,\"pct\":100},\"branches\":{\"total\":12,\"covered\":11,\"skipped\":0,\"pct\":91.67}}\n-,\"/Users/zachleat/Code/eleventy/src/EleventyFiles.js\": {\"lines\":{\"total\":93,\"covered\":88,\"skipped\":0,\"pct\":94.62},\"functions\":{\"total\":28,\"covered\":24,\"skipped\":0,\"pct\":85.71},\"statements\":{\"total\":93,\"covered\":88,\"skipped\":0,\"pct\":94.62},\"branches\":{\"total\":24,\"covered\":22,\"skipped\":0,\"pct\":91.67}}\n-,\"/Users/zachleat/Code/eleventy/src/EleventyServe.js\": {\"lines\":{\"total\":56,\"covered\":11,\"skipped\":0,\"pct\":19.64},\"functions\":{\"total\":13,\"covered\":6,\"skipped\":0,\"pct\":46.15},\"statements\":{\"total\":56,\"covered\":11,\"skipped\":0,\"pct\":19.64},\"branches\":{\"total\":33,\"covered\":1,\"skipped\":0,\"pct\":3.03}}\n-,\"/Users/zachleat/Code/eleventy/src/Template.js\": {\"lines\":{\"total\":245,\"covered\":227,\"skipped\":0,\"pct\":92.65},\"functions\":{\"total\":42,\"covered\":40,\"skipped\":0,\"pct\":95.24},\"statements\":{\"total\":245,\"covered\":227,\"skipped\":0,\"pct\":92.65},\"branches\":{\"total\":91,\"covered\":75,\"skipped\":0,\"pct\":82.42}}\n+,\"/Users/zachleat/Code/eleventy/src/EleventyErrorHandler.js\": {\"lines\":{\"total\":27,\"covered\":23,\"skipped\":0,\"pct\":85.19},\"functions\":{\"total\":6,\"covered\":5,\"skipped\":0,\"pct\":83.33},\"statements\":{\"total\":27,\"covered\":23,\"skipped\":0,\"pct\":85.19},\"branches\":{\"total\":25,\"covered\":16,\"skipped\":0,\"pct\":64}}\n+,\"/Users/zachleat/Code/eleventy/src/EleventyExtensionMap.js\": {\"lines\":{\"total\":60,\"covered\":60,\"skipped\":0,\"pct\":100},\"functions\":{\"total\":25,\"covered\":25,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":60,\"covered\":60,\"skipped\":0,\"pct\":100},\"branches\":{\"total\":27,\"covered\":27,\"skipped\":0,\"pct\":100}}\n+,\"/Users/zachleat/Code/eleventy/src/EleventyFiles.js\": {\"lines\":{\"total\":114,\"covered\":109,\"skipped\":0,\"pct\":95.61},\"functions\":{\"total\":35,\"covered\":31,\"skipped\":0,\"pct\":88.57},\"statements\":{\"total\":114,\"covered\":109,\"skipped\":0,\"pct\":95.61},\"branches\":{\"total\":34,\"covered\":31,\"skipped\":0,\"pct\":91.18}}\n+,\"/Users/zachleat/Code/eleventy/src/EleventyServe.js\": {\"lines\":{\"total\":61,\"covered\":22,\"skipped\":0,\"pct\":36.07},\"functions\":{\"total\":16,\"covered\":9,\"skipped\":0,\"pct\":56.25},\"statements\":{\"total\":61,\"covered\":22,\"skipped\":0,\"pct\":36.07},\"branches\":{\"total\":41,\"covered\":10,\"skipped\":0,\"pct\":24.39}}\n+,\"/Users/zachleat/Code/eleventy/src/EleventyWatchTargets.js\": {\"lines\":{\"total\":45,\"covered\":42,\"skipped\":0,\"pct\":93.33},\"functions\":{\"total\":19,\"covered\":17,\"skipped\":0,\"pct\":89.47},\"statements\":{\"total\":45,\"covered\":42,\"skipped\":0,\"pct\":93.33},\"branches\":{\"total\":15,\"covered\":14,\"skipped\":0,\"pct\":93.33}}\n+,\"/Users/zachleat/Code/eleventy/src/Template.js\": {\"lines\":{\"total\":247,\"covered\":231,\"skipped\":0,\"pct\":93.52},\"functions\":{\"total\":43,\"covered\":41,\"skipped\":0,\"pct\":95.35},\"statements\":{\"total\":247,\"covered\":231,\"skipped\":0,\"pct\":93.52},\"branches\":{\"total\":95,\"covered\":80,\"skipped\":0,\"pct\":84.21}}\n,\"/Users/zachleat/Code/eleventy/src/TemplateCache.js\": {\"lines\":{\"total\":9,\"covered\":9,\"skipped\":0,\"pct\":100},\"functions\":{\"total\":6,\"covered\":6,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":9,\"covered\":9,\"skipped\":0,\"pct\":100},\"branches\":{\"total\":2,\"covered\":2,\"skipped\":0,\"pct\":100}}\n,\"/Users/zachleat/Code/eleventy/src/TemplateCollection.js\": {\"lines\":{\"total\":30,\"covered\":27,\"skipped\":0,\"pct\":90},\"functions\":{\"total\":13,\"covered\":12,\"skipped\":0,\"pct\":92.31},\"statements\":{\"total\":32,\"covered\":29,\"skipped\":0,\"pct\":90.63},\"branches\":{\"total\":12,\"covered\":9,\"skipped\":0,\"pct\":75}}\n-,\"/Users/zachleat/Code/eleventy/src/TemplateConfig.js\": {\"lines\":{\"total\":54,\"covered\":48,\"skipped\":0,\"pct\":88.89},\"functions\":{\"total\":9,\"covered\":5,\"skipped\":0,\"pct\":55.56},\"statements\":{\"total\":54,\"covered\":48,\"skipped\":0,\"pct\":88.89},\"branches\":{\"total\":20,\"covered\":18,\"skipped\":0,\"pct\":90}}\n-,\"/Users/zachleat/Code/eleventy/src/TemplateContent.js\": {\"lines\":{\"total\":56,\"covered\":52,\"skipped\":0,\"pct\":92.86},\"functions\":{\"total\":14,\"covered\":14,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":56,\"covered\":52,\"skipped\":0,\"pct\":92.86},\"branches\":{\"total\":16,\"covered\":13,\"skipped\":0,\"pct\":81.25}}\n-,\"/Users/zachleat/Code/eleventy/src/TemplateData.js\": {\"lines\":{\"total\":143,\"covered\":135,\"skipped\":0,\"pct\":94.41},\"functions\":{\"total\":24,\"covered\":24,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":143,\"covered\":135,\"skipped\":0,\"pct\":94.41},\"branches\":{\"total\":42,\"covered\":34,\"skipped\":0,\"pct\":80.95}}\n+,\"/Users/zachleat/Code/eleventy/src/TemplateConfig.js\": {\"lines\":{\"total\":55,\"covered\":50,\"skipped\":0,\"pct\":90.91},\"functions\":{\"total\":9,\"covered\":6,\"skipped\":0,\"pct\":66.67},\"statements\":{\"total\":55,\"covered\":50,\"skipped\":0,\"pct\":90.91},\"branches\":{\"total\":20,\"covered\":18,\"skipped\":0,\"pct\":90}}\n+,\"/Users/zachleat/Code/eleventy/src/TemplateContent.js\": {\"lines\":{\"total\":69,\"covered\":65,\"skipped\":0,\"pct\":94.2},\"functions\":{\"total\":18,\"covered\":18,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":69,\"covered\":65,\"skipped\":0,\"pct\":94.2},\"branches\":{\"total\":22,\"covered\":20,\"skipped\":0,\"pct\":90.91}}\n+,\"/Users/zachleat/Code/eleventy/src/TemplateData.js\": {\"lines\":{\"total\":148,\"covered\":140,\"skipped\":0,\"pct\":94.59},\"functions\":{\"total\":26,\"covered\":26,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":148,\"covered\":140,\"skipped\":0,\"pct\":94.59},\"branches\":{\"total\":42,\"covered\":33,\"skipped\":0,\"pct\":78.57}}\n,\"/Users/zachleat/Code/eleventy/src/TemplateFileSlug.js\": {\"lines\":{\"total\":19,\"covered\":19,\"skipped\":0,\"pct\":100},\"functions\":{\"total\":2,\"covered\":2,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":19,\"covered\":19,\"skipped\":0,\"pct\":100},\"branches\":{\"total\":8,\"covered\":8,\"skipped\":0,\"pct\":100}}\n,\"/Users/zachleat/Code/eleventy/src/TemplateGlob.js\": {\"lines\":{\"total\":15,\"covered\":14,\"skipped\":0,\"pct\":93.33},\"functions\":{\"total\":4,\"covered\":4,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":15,\"covered\":14,\"skipped\":0,\"pct\":93.33},\"branches\":{\"total\":8,\"covered\":7,\"skipped\":0,\"pct\":87.5}}\n-,\"/Users/zachleat/Code/eleventy/src/TemplateLayout.js\": {\"lines\":{\"total\":68,\"covered\":68,\"skipped\":0,\"pct\":100},\"functions\":{\"total\":9,\"covered\":9,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":68,\"covered\":68,\"skipped\":0,\"pct\":100},\"branches\":{\"total\":14,\"covered\":14,\"skipped\":0,\"pct\":100}}\n+,\"/Users/zachleat/Code/eleventy/src/TemplateLayout.js\": {\"lines\":{\"total\":69,\"covered\":69,\"skipped\":0,\"pct\":100},\"functions\":{\"total\":9,\"covered\":9,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":69,\"covered\":69,\"skipped\":0,\"pct\":100},\"branches\":{\"total\":14,\"covered\":14,\"skipped\":0,\"pct\":100}}\n,\"/Users/zachleat/Code/eleventy/src/TemplateLayoutPathResolver.js\": {\"lines\":{\"total\":33,\"covered\":32,\"skipped\":0,\"pct\":96.97},\"functions\":{\"total\":6,\"covered\":6,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":33,\"covered\":32,\"skipped\":0,\"pct\":96.97},\"branches\":{\"total\":14,\"covered\":13,\"skipped\":0,\"pct\":92.86}}\n,\"/Users/zachleat/Code/eleventy/src/TemplateMap.js\": {\"lines\":{\"total\":113,\"covered\":111,\"skipped\":0,\"pct\":98.23},\"functions\":{\"total\":19,\"covered\":19,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":113,\"covered\":111,\"skipped\":0,\"pct\":98.23},\"branches\":{\"total\":44,\"covered\":39,\"skipped\":0,\"pct\":88.64}}\n,\"/Users/zachleat/Code/eleventy/src/TemplatePassthrough.js\": {\"lines\":{\"total\":13,\"covered\":10,\"skipped\":0,\"pct\":76.92},\"functions\":{\"total\":4,\"covered\":3,\"skipped\":0,\"pct\":75},\"statements\":{\"total\":13,\"covered\":10,\"skipped\":0,\"pct\":76.92},\"branches\":{\"total\":2,\"covered\":0,\"skipped\":0,\"pct\":0}}\n,\"/Users/zachleat/Code/eleventy/src/TemplatePassthroughManager.js\": {\"lines\":{\"total\":54,\"covered\":44,\"skipped\":0,\"pct\":81.48},\"functions\":{\"total\":16,\"covered\":13,\"skipped\":0,\"pct\":81.25},\"statements\":{\"total\":54,\"covered\":44,\"skipped\":0,\"pct\":81.48},\"branches\":{\"total\":12,\"covered\":9,\"skipped\":0,\"pct\":75}}\n-,\"/Users/zachleat/Code/eleventy/src/TemplatePath.js\": {\"lines\":{\"total\":93,\"covered\":91,\"skipped\":0,\"pct\":97.85},\"functions\":{\"total\":21,\"covered\":20,\"skipped\":0,\"pct\":95.24},\"statements\":{\"total\":93,\"covered\":91,\"skipped\":0,\"pct\":97.85},\"branches\":{\"total\":62,\"covered\":60,\"skipped\":0,\"pct\":96.77}}\n+,\"/Users/zachleat/Code/eleventy/src/TemplatePath.js\": {\"lines\":{\"total\":99,\"covered\":97,\"skipped\":0,\"pct\":97.98},\"functions\":{\"total\":24,\"covered\":23,\"skipped\":0,\"pct\":95.83},\"statements\":{\"total\":99,\"covered\":97,\"skipped\":0,\"pct\":97.98},\"branches\":{\"total\":62,\"covered\":60,\"skipped\":0,\"pct\":96.77}}\n,\"/Users/zachleat/Code/eleventy/src/TemplatePermalink.js\": {\"lines\":{\"total\":30,\"covered\":30,\"skipped\":0,\"pct\":100},\"functions\":{\"total\":7,\"covered\":7,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":30,\"covered\":30,\"skipped\":0,\"pct\":100},\"branches\":{\"total\":20,\"covered\":20,\"skipped\":0,\"pct\":100}}\n,\"/Users/zachleat/Code/eleventy/src/TemplatePermalinkNoWrite.js\": {\"lines\":{\"total\":3,\"covered\":3,\"skipped\":0,\"pct\":100},\"functions\":{\"total\":2,\"covered\":2,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":3,\"covered\":3,\"skipped\":0,\"pct\":100},\"branches\":{\"total\":0,\"covered\":0,\"skipped\":0,\"pct\":100}}\n-,\"/Users/zachleat/Code/eleventy/src/TemplateRender.js\": {\"lines\":{\"total\":82,\"covered\":80,\"skipped\":0,\"pct\":97.56},\"functions\":{\"total\":18,\"covered\":18,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":82,\"covered\":80,\"skipped\":0,\"pct\":97.56},\"branches\":{\"total\":40,\"covered\":36,\"skipped\":0,\"pct\":90}}\n-,\"/Users/zachleat/Code/eleventy/src/TemplateWriter.js\": {\"lines\":{\"total\":86,\"covered\":74,\"skipped\":0,\"pct\":86.05},\"functions\":{\"total\":20,\"covered\":15,\"skipped\":0,\"pct\":75},\"statements\":{\"total\":86,\"covered\":74,\"skipped\":0,\"pct\":86.05},\"branches\":{\"total\":8,\"covered\":3,\"skipped\":0,\"pct\":37.5}}\n-,\"/Users/zachleat/Code/eleventy/src/UserConfig.js\": {\"lines\":{\"total\":145,\"covered\":96,\"skipped\":0,\"pct\":66.21},\"functions\":{\"total\":41,\"covered\":22,\"skipped\":0,\"pct\":53.66},\"statements\":{\"total\":146,\"covered\":97,\"skipped\":0,\"pct\":66.44},\"branches\":{\"total\":60,\"covered\":32,\"skipped\":0,\"pct\":53.33}}\n-,\"/Users/zachleat/Code/eleventy/src/Engines/Ejs.js\": {\"lines\":{\"total\":21,\"covered\":20,\"skipped\":0,\"pct\":95.24},\"functions\":{\"total\":7,\"covered\":6,\"skipped\":0,\"pct\":85.71},\"statements\":{\"total\":21,\"covered\":20,\"skipped\":0,\"pct\":95.24},\"branches\":{\"total\":6,\"covered\":4,\"skipped\":0,\"pct\":66.67}}\n-,\"/Users/zachleat/Code/eleventy/src/Engines/Haml.js\": {\"lines\":{\"total\":10,\"covered\":10,\"skipped\":0,\"pct\":100},\"functions\":{\"total\":3,\"covered\":3,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":10,\"covered\":10,\"skipped\":0,\"pct\":100},\"branches\":{\"total\":2,\"covered\":2,\"skipped\":0,\"pct\":100}}\n-,\"/Users/zachleat/Code/eleventy/src/Engines/Handlebars.js\": {\"lines\":{\"total\":31,\"covered\":31,\"skipped\":0,\"pct\":100},\"functions\":{\"total\":9,\"covered\":9,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":31,\"covered\":31,\"skipped\":0,\"pct\":100},\"branches\":{\"total\":6,\"covered\":5,\"skipped\":0,\"pct\":83.33}}\n+,\"/Users/zachleat/Code/eleventy/src/TemplateRender.js\": {\"lines\":{\"total\":77,\"covered\":75,\"skipped\":0,\"pct\":97.4},\"functions\":{\"total\":22,\"covered\":22,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":77,\"covered\":75,\"skipped\":0,\"pct\":97.4},\"branches\":{\"total\":42,\"covered\":38,\"skipped\":0,\"pct\":90.48}}\n+,\"/Users/zachleat/Code/eleventy/src/TemplateWriter.js\": {\"lines\":{\"total\":87,\"covered\":75,\"skipped\":0,\"pct\":86.21},\"functions\":{\"total\":20,\"covered\":15,\"skipped\":0,\"pct\":75},\"statements\":{\"total\":87,\"covered\":75,\"skipped\":0,\"pct\":86.21},\"branches\":{\"total\":8,\"covered\":3,\"skipped\":0,\"pct\":37.5}}\n+,\"/Users/zachleat/Code/eleventy/src/UserConfig.js\": {\"lines\":{\"total\":163,\"covered\":105,\"skipped\":0,\"pct\":64.42},\"functions\":{\"total\":44,\"covered\":23,\"skipped\":0,\"pct\":52.27},\"statements\":{\"total\":164,\"covered\":106,\"skipped\":0,\"pct\":64.63},\"branches\":{\"total\":63,\"covered\":34,\"skipped\":0,\"pct\":53.97}}\n+,\"/Users/zachleat/Code/eleventy/src/Engines/Ejs.js\": {\"lines\":{\"total\":20,\"covered\":19,\"skipped\":0,\"pct\":95},\"functions\":{\"total\":7,\"covered\":6,\"skipped\":0,\"pct\":85.71},\"statements\":{\"total\":20,\"covered\":19,\"skipped\":0,\"pct\":95},\"branches\":{\"total\":6,\"covered\":4,\"skipped\":0,\"pct\":66.67}}\n+,\"/Users/zachleat/Code/eleventy/src/Engines/Haml.js\": {\"lines\":{\"total\":9,\"covered\":9,\"skipped\":0,\"pct\":100},\"functions\":{\"total\":3,\"covered\":3,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":9,\"covered\":9,\"skipped\":0,\"pct\":100},\"branches\":{\"total\":2,\"covered\":2,\"skipped\":0,\"pct\":100}}\n+,\"/Users/zachleat/Code/eleventy/src/Engines/Handlebars.js\": {\"lines\":{\"total\":30,\"covered\":30,\"skipped\":0,\"pct\":100},\"functions\":{\"total\":9,\"covered\":9,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":30,\"covered\":30,\"skipped\":0,\"pct\":100},\"branches\":{\"total\":6,\"covered\":5,\"skipped\":0,\"pct\":83.33}}\n,\"/Users/zachleat/Code/eleventy/src/Engines/Html.js\": {\"lines\":{\"total\":9,\"covered\":9,\"skipped\":0,\"pct\":100},\"functions\":{\"total\":3,\"covered\":3,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":9,\"covered\":9,\"skipped\":0,\"pct\":100},\"branches\":{\"total\":2,\"covered\":2,\"skipped\":0,\"pct\":100}}\n+,\"/Users/zachleat/Code/eleventy/src/Engines/JavaScript.js\": {\"lines\":{\"total\":37,\"covered\":37,\"skipped\":0,\"pct\":100},\"functions\":{\"total\":10,\"covered\":10,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":37,\"covered\":37,\"skipped\":0,\"pct\":100},\"branches\":{\"total\":22,\"covered\":22,\"skipped\":0,\"pct\":100}}\n,\"/Users/zachleat/Code/eleventy/src/Engines/JavaScriptTemplateLiteral.js\": {\"lines\":{\"total\":18,\"covered\":17,\"skipped\":0,\"pct\":94.44},\"functions\":{\"total\":3,\"covered\":3,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":18,\"covered\":17,\"skipped\":0,\"pct\":94.44},\"branches\":{\"total\":6,\"covered\":6,\"skipped\":0,\"pct\":100}}\n-,\"/Users/zachleat/Code/eleventy/src/Engines/Liquid.js\": {\"lines\":{\"total\":65,\"covered\":62,\"skipped\":0,\"pct\":95.38},\"functions\":{\"total\":25,\"covered\":24,\"skipped\":0,\"pct\":96},\"statements\":{\"total\":65,\"covered\":62,\"skipped\":0,\"pct\":95.38},\"branches\":{\"total\":8,\"covered\":6,\"skipped\":0,\"pct\":75}}\n-,\"/Users/zachleat/Code/eleventy/src/Engines/Markdown.js\": {\"lines\":{\"total\":29,\"covered\":26,\"skipped\":0,\"pct\":89.66},\"functions\":{\"total\":8,\"covered\":7,\"skipped\":0,\"pct\":87.5},\"statements\":{\"total\":29,\"covered\":26,\"skipped\":0,\"pct\":89.66},\"branches\":{\"total\":12,\"covered\":9,\"skipped\":0,\"pct\":75}}\n-,\"/Users/zachleat/Code/eleventy/src/Engines/Mustache.js\": {\"lines\":{\"total\":12,\"covered\":12,\"skipped\":0,\"pct\":100},\"functions\":{\"total\":4,\"covered\":4,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":12,\"covered\":12,\"skipped\":0,\"pct\":100},\"branches\":{\"total\":2,\"covered\":2,\"skipped\":0,\"pct\":100}}\n-,\"/Users/zachleat/Code/eleventy/src/Engines/Nunjucks.js\": {\"lines\":{\"total\":62,\"covered\":58,\"skipped\":0,\"pct\":93.55},\"functions\":{\"total\":21,\"covered\":21,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":62,\"covered\":58,\"skipped\":0,\"pct\":93.55},\"branches\":{\"total\":6,\"covered\":5,\"skipped\":0,\"pct\":83.33}}\n-,\"/Users/zachleat/Code/eleventy/src/Engines/Pug.js\": {\"lines\":{\"total\":16,\"covered\":16,\"skipped\":0,\"pct\":100},\"functions\":{\"total\":5,\"covered\":5,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":16,\"covered\":16,\"skipped\":0,\"pct\":100},\"branches\":{\"total\":4,\"covered\":3,\"skipped\":0,\"pct\":75}}\n-,\"/Users/zachleat/Code/eleventy/src/Engines/TemplateEngine.js\": {\"lines\":{\"total\":35,\"covered\":35,\"skipped\":0,\"pct\":100},\"functions\":{\"total\":11,\"covered\":11,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":35,\"covered\":35,\"skipped\":0,\"pct\":100},\"branches\":{\"total\":6,\"covered\":6,\"skipped\":0,\"pct\":100}}\n+,\"/Users/zachleat/Code/eleventy/src/Engines/Liquid.js\": {\"lines\":{\"total\":69,\"covered\":66,\"skipped\":0,\"pct\":95.65},\"functions\":{\"total\":26,\"covered\":25,\"skipped\":0,\"pct\":96.15},\"statements\":{\"total\":69,\"covered\":66,\"skipped\":0,\"pct\":95.65},\"branches\":{\"total\":10,\"covered\":8,\"skipped\":0,\"pct\":80}}\n+,\"/Users/zachleat/Code/eleventy/src/Engines/Markdown.js\": {\"lines\":{\"total\":28,\"covered\":25,\"skipped\":0,\"pct\":89.29},\"functions\":{\"total\":8,\"covered\":7,\"skipped\":0,\"pct\":87.5},\"statements\":{\"total\":28,\"covered\":25,\"skipped\":0,\"pct\":89.29},\"branches\":{\"total\":12,\"covered\":9,\"skipped\":0,\"pct\":75}}\n+,\"/Users/zachleat/Code/eleventy/src/Engines/Mustache.js\": {\"lines\":{\"total\":11,\"covered\":11,\"skipped\":0,\"pct\":100},\"functions\":{\"total\":4,\"covered\":4,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":11,\"covered\":11,\"skipped\":0,\"pct\":100},\"branches\":{\"total\":2,\"covered\":2,\"skipped\":0,\"pct\":100}}\n+,\"/Users/zachleat/Code/eleventy/src/Engines/Nunjucks.js\": {\"lines\":{\"total\":62,\"covered\":58,\"skipped\":0,\"pct\":93.55},\"functions\":{\"total\":21,\"covered\":21,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":62,\"covered\":58,\"skipped\":0,\"pct\":93.55},\"branches\":{\"total\":8,\"covered\":7,\"skipped\":0,\"pct\":87.5}}\n+,\"/Users/zachleat/Code/eleventy/src/Engines/Pug.js\": {\"lines\":{\"total\":15,\"covered\":15,\"skipped\":0,\"pct\":100},\"functions\":{\"total\":5,\"covered\":5,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":15,\"covered\":15,\"skipped\":0,\"pct\":100},\"branches\":{\"total\":4,\"covered\":3,\"skipped\":0,\"pct\":75}}\n+,\"/Users/zachleat/Code/eleventy/src/Engines/TemplateEngine.js\": {\"lines\":{\"total\":51,\"covered\":51,\"skipped\":0,\"pct\":100},\"functions\":{\"total\":18,\"covered\":18,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":51,\"covered\":51,\"skipped\":0,\"pct\":100},\"branches\":{\"total\":8,\"covered\":8,\"skipped\":0,\"pct\":100}}\n,\"/Users/zachleat/Code/eleventy/src/Filters/Slug.js\": {\"lines\":{\"total\":3,\"covered\":3,\"skipped\":0,\"pct\":100},\"functions\":{\"total\":1,\"covered\":1,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":3,\"covered\":3,\"skipped\":0,\"pct\":100},\"branches\":{\"total\":0,\"covered\":0,\"skipped\":0,\"pct\":100}}\n,\"/Users/zachleat/Code/eleventy/src/Filters/Url.js\": {\"lines\":{\"total\":18,\"covered\":18,\"skipped\":0,\"pct\":100},\"functions\":{\"total\":1,\"covered\":1,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":18,\"covered\":18,\"skipped\":0,\"pct\":100},\"branches\":{\"total\":21,\"covered\":21,\"skipped\":0,\"pct\":100}}\n-,\"/Users/zachleat/Code/eleventy/src/Plugins/Pagination.js\": {\"lines\":{\"total\":103,\"covered\":95,\"skipped\":0,\"pct\":92.23},\"functions\":{\"total\":14,\"covered\":13,\"skipped\":0,\"pct\":92.86},\"statements\":{\"total\":103,\"covered\":95,\"skipped\":0,\"pct\":92.23},\"branches\":{\"total\":54,\"covered\":43,\"skipped\":0,\"pct\":79.63}}\n+,\"/Users/zachleat/Code/eleventy/src/Plugins/Pagination.js\": {\"lines\":{\"total\":106,\"covered\":98,\"skipped\":0,\"pct\":92.45},\"functions\":{\"total\":14,\"covered\":13,\"skipped\":0,\"pct\":92.86},\"statements\":{\"total\":106,\"covered\":98,\"skipped\":0,\"pct\":92.45},\"branches\":{\"total\":56,\"covered\":45,\"skipped\":0,\"pct\":80.36}}\n,\"/Users/zachleat/Code/eleventy/src/Util/Capitalize.js\": {\"lines\":{\"total\":4,\"covered\":4,\"skipped\":0,\"pct\":100},\"functions\":{\"total\":2,\"covered\":2,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":4,\"covered\":4,\"skipped\":0,\"pct\":100},\"branches\":{\"total\":2,\"covered\":2,\"skipped\":0,\"pct\":100}}\n,\"/Users/zachleat/Code/eleventy/src/Util/Merge.js\": {\"lines\":{\"total\":28,\"covered\":26,\"skipped\":0,\"pct\":92.86},\"functions\":{\"total\":2,\"covered\":2,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":28,\"covered\":26,\"skipped\":0,\"pct\":92.86},\"branches\":{\"total\":22,\"covered\":19,\"skipped\":0,\"pct\":86.36}}\n,\"/Users/zachleat/Code/eleventy/src/Util/Pluralize.js\": {\"lines\":{\"total\":2,\"covered\":2,\"skipped\":0,\"pct\":100},\"functions\":{\"total\":1,\"covered\":1,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":2,\"covered\":2,\"skipped\":0,\"pct\":100},\"branches\":{\"total\":2,\"covered\":2,\"skipped\":0,\"pct\":100}}\n" }, { "change_type": "MODIFY", "old_path": "docs/coverage.md", "new_path": "docs/coverage.md", "diff": "-# Code Coverage for Eleventy v0.6.0\n+# Code Coverage for Eleventy v0.7.0\n| Filename | % Lines | % Statements | % Functions | % Branches |\n| ------------------------------------------ | ------- | ------------ | ----------- | ---------- |\n-| `total` | 87.69% | 87.72% | 85.9% | 76.73% |\n+| `total` | 88.09% | 88.11% | 86.95% | 79.63% |\n| `config.js` | 100% | 100% | 100% | 100% |\n| `src/Benchmark.js` | 91.67% | 91.67% | 83.33% | 66.67% |\n| `src/BenchmarkGroup.js` | 75.86% | 75.86% | 83.33% | 50% |\n| `src/BenchmarkManager.js` | 76.47% | 76.47% | 71.43% | 50% |\n| `src/Config.js` | 100% | 100% | 100% | 100% |\n-| `src/Eleventy.js` | 58.55% | 58.55% | 43.48% | 34.09% |\n+| `src/Eleventy.js` | 59.07% | 59.07% | 51.61% | 45.83% |\n| `src/EleventyBaseError.js` | 100% | 100% | 100% | 100% |\n| `src/EleventyCommandCheck.js` | 100% | 100% | 100% | 87.5% |\n| `src/EleventyConfig.js` | 100% | 100% | 100% | 100% |\n-| `src/EleventyErrorHandler.js` | 86.36% | 86.36% | 83.33% | 52.94% |\n-| `src/EleventyExtensionMap.js` | 100% | 100% | 100% | 91.67% |\n-| `src/EleventyFiles.js` | 94.62% | 94.62% | 85.71% | 91.67% |\n-| `src/EleventyServe.js` | 19.64% | 19.64% | 46.15% | 3.03% |\n-| `src/Template.js` | 92.65% | 92.65% | 95.24% | 82.42% |\n+| `src/EleventyErrorHandler.js` | 85.19% | 85.19% | 83.33% | 64% |\n+| `src/EleventyExtensionMap.js` | 100% | 100% | 100% | 100% |\n+| `src/EleventyFiles.js` | 95.61% | 95.61% | 88.57% | 91.18% |\n+| `src/EleventyServe.js` | 36.07% | 36.07% | 56.25% | 24.39% |\n+| `src/EleventyWatchTargets.js` | 93.33% | 93.33% | 89.47% | 93.33% |\n+| `src/Template.js` | 93.52% | 93.52% | 95.35% | 84.21% |\n| `src/TemplateCache.js` | 100% | 100% | 100% | 100% |\n| `src/TemplateCollection.js` | 90% | 90.63% | 92.31% | 75% |\n-| `src/TemplateConfig.js` | 88.89% | 88.89% | 55.56% | 90% |\n-| `src/TemplateContent.js` | 92.86% | 92.86% | 100% | 81.25% |\n-| `src/TemplateData.js` | 94.41% | 94.41% | 100% | 80.95% |\n+| `src/TemplateConfig.js` | 90.91% | 90.91% | 66.67% | 90% |\n+| `src/TemplateContent.js` | 94.2% | 94.2% | 100% | 90.91% |\n+| `src/TemplateData.js` | 94.59% | 94.59% | 100% | 78.57% |\n| `src/TemplateFileSlug.js` | 100% | 100% | 100% | 100% |\n| `src/TemplateGlob.js` | 93.33% | 93.33% | 100% | 87.5% |\n| `src/TemplateLayout.js` | 100% | 100% | 100% | 100% |\n| `src/TemplateMap.js` | 98.23% | 98.23% | 100% | 88.64% |\n| `src/TemplatePassthrough.js` | 76.92% | 76.92% | 75% | 0% |\n| `src/TemplatePassthroughManager.js` | 81.48% | 81.48% | 81.25% | 75% |\n-| `src/TemplatePath.js` | 97.85% | 97.85% | 95.24% | 96.77% |\n+| `src/TemplatePath.js` | 97.98% | 97.98% | 95.83% | 96.77% |\n| `src/TemplatePermalink.js` | 100% | 100% | 100% | 100% |\n| `src/TemplatePermalinkNoWrite.js` | 100% | 100% | 100% | 100% |\n-| `src/TemplateRender.js` | 97.56% | 97.56% | 100% | 90% |\n-| `src/TemplateWriter.js` | 86.05% | 86.05% | 75% | 37.5% |\n-| `src/UserConfig.js` | 66.21% | 66.44% | 53.66% | 53.33% |\n-| `src/Engines/Ejs.js` | 95.24% | 95.24% | 85.71% | 66.67% |\n+| `src/TemplateRender.js` | 97.4% | 97.4% | 100% | 90.48% |\n+| `src/TemplateWriter.js` | 86.21% | 86.21% | 75% | 37.5% |\n+| `src/UserConfig.js` | 64.42% | 64.63% | 52.27% | 53.97% |\n+| `src/Engines/Ejs.js` | 95% | 95% | 85.71% | 66.67% |\n| `src/Engines/Haml.js` | 100% | 100% | 100% | 100% |\n| `src/Engines/Handlebars.js` | 100% | 100% | 100% | 83.33% |\n| `src/Engines/Html.js` | 100% | 100% | 100% | 100% |\n+| `src/Engines/JavaScript.js` | 100% | 100% | 100% | 100% |\n| `src/Engines/JavaScriptTemplateLiteral.js` | 94.44% | 94.44% | 100% | 100% |\n-| `src/Engines/Liquid.js` | 95.38% | 95.38% | 96% | 75% |\n-| `src/Engines/Markdown.js` | 89.66% | 89.66% | 87.5% | 75% |\n+| `src/Engines/Liquid.js` | 95.65% | 95.65% | 96.15% | 80% |\n+| `src/Engines/Markdown.js` | 89.29% | 89.29% | 87.5% | 75% |\n| `src/Engines/Mustache.js` | 100% | 100% | 100% | 100% |\n-| `src/Engines/Nunjucks.js` | 93.55% | 93.55% | 100% | 83.33% |\n+| `src/Engines/Nunjucks.js` | 93.55% | 93.55% | 100% | 87.5% |\n| `src/Engines/Pug.js` | 100% | 100% | 100% | 75% |\n| `src/Engines/TemplateEngine.js` | 100% | 100% | 100% | 100% |\n| `src/Filters/Slug.js` | 100% | 100% | 100% | 100% |\n| `src/Filters/Url.js` | 100% | 100% | 100% | 100% |\n-| `src/Plugins/Pagination.js` | 92.23% | 92.23% | 92.86% | 79.63% |\n+| `src/Plugins/Pagination.js` | 92.45% | 92.45% | 92.86% | 80.36% |\n| `src/Util/Capitalize.js` | 100% | 100% | 100% | 100% |\n| `src/Util/Merge.js` | 92.86% | 92.86% | 100% | 86.36% |\n| `src/Util/Pluralize.js` | 100% | 100% | 100% | 100% |\n" } ]
JavaScript
MIT License
11ty/eleventy
0.7.0 coverage
699
11.01.2019 20:53:23
21,600
e78bfc7f36f68384df92e1ac11e45fbb4aae2e89
Adds collection iteration test
[ { "change_type": "MODIFY", "old_path": "test/TemplateRenderJavaScriptTest.js", "new_path": "test/TemplateRenderJavaScriptTest.js", "diff": "@@ -63,6 +63,30 @@ test(\"JS Render a function (Markdown)\", async t => {\nt.is((await fn({ name: \"Bill\" })).trim(), \"<h1>Bill</h1>\");\n});\n+test(\"JS Render a function (Collections)\", async t => {\n+ let tr = new TemplateRender(\"./test/stubs/use-collection.11ty.js\");\n+ let fn = await tr.getCompiledTemplate();\n+ t.is(\n+ (await fn({\n+ collections: {\n+ post: [\n+ {\n+ data: {\n+ title: \"Testing\"\n+ }\n+ },\n+ {\n+ data: {\n+ title: \"Testing2\"\n+ }\n+ }\n+ ]\n+ }\n+ })).trim(),\n+ `<ul><li>Testing</li><li>Testing2</li></ul>`\n+ );\n+});\n+\ntest(\"JS Render an async function\", async t => {\nlet fn = await new TemplateRender(\n\"./test/stubs/function-async.11ty.js\"\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/use-collection.11ty.js", "diff": "+module.exports = function({ collections }) {\n+ return `<ul>${collections.post\n+ .map(post => `<li>${post.data.title}</li>`)\n+ .join(\"\")}</ul>`;\n+};\n" } ]
JavaScript
MIT License
11ty/eleventy
Adds collection iteration test
699
11.01.2019 21:16:35
21,600
d15c5f57841c097953e993584fb19ac306594d9e
More travis operating systems.
[ { "change_type": "MODIFY", "old_path": ".travis.yml", "new_path": ".travis.yml", "diff": "language: node_js\nnode_js:\n- 8\n+ - 10\nbefore_script:\n- npm install\nscript: npm run test\n@@ -8,3 +9,7 @@ branches:\nexcept:\n- gh-pages\nsudo: false\n+os:\n+ - windows\n+ - linux\n+ - osx\n\\ No newline at end of file\n" } ]
JavaScript
MIT License
11ty/eleventy
More travis operating systems. #353
699
11.01.2019 21:42:14
21,600
4b498396c4a9cea00276d6ceed8f2482e43a1dbe
Version 0.7.1 quick maintenance release.
[ { "change_type": "MODIFY", "old_path": "docs-src/_data/coverage.json", "new_path": "docs-src/_data/coverage.json", "diff": "-{\"total\": {\"lines\":{\"total\":2503,\"covered\":2205,\"skipped\":0,\"pct\":88.09},\"statements\":{\"total\":2507,\"covered\":2209,\"skipped\":0,\"pct\":88.11},\"functions\":{\"total\":613,\"covered\":533,\"skipped\":0,\"pct\":86.95},\"branches\":{\"total\":913,\"covered\":727,\"skipped\":0,\"pct\":79.63}}\n+{\"total\": {\"lines\":{\"total\":2487,\"covered\":2186,\"skipped\":0,\"pct\":87.9},\"statements\":{\"total\":2491,\"covered\":2190,\"skipped\":0,\"pct\":87.92},\"functions\":{\"total\":617,\"covered\":537,\"skipped\":0,\"pct\":87.03},\"branches\":{\"total\":919,\"covered\":730,\"skipped\":0,\"pct\":79.43}}\n,\"/Users/zachleat/Code/eleventy/config.js\": {\"lines\":{\"total\":6,\"covered\":6,\"skipped\":0,\"pct\":100},\"functions\":{\"total\":1,\"covered\":1,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":6,\"covered\":6,\"skipped\":0,\"pct\":100},\"branches\":{\"total\":0,\"covered\":0,\"skipped\":0,\"pct\":100}}\n,\"/Users/zachleat/Code/eleventy/src/Benchmark.js\": {\"lines\":{\"total\":12,\"covered\":11,\"skipped\":0,\"pct\":91.67},\"functions\":{\"total\":6,\"covered\":5,\"skipped\":0,\"pct\":83.33},\"statements\":{\"total\":12,\"covered\":11,\"skipped\":0,\"pct\":91.67},\"branches\":{\"total\":6,\"covered\":4,\"skipped\":0,\"pct\":66.67}}\n-,\"/Users/zachleat/Code/eleventy/src/BenchmarkGroup.js\": {\"lines\":{\"total\":29,\"covered\":22,\"skipped\":0,\"pct\":75.86},\"functions\":{\"total\":6,\"covered\":5,\"skipped\":0,\"pct\":83.33},\"statements\":{\"total\":29,\"covered\":22,\"skipped\":0,\"pct\":75.86},\"branches\":{\"total\":6,\"covered\":3,\"skipped\":0,\"pct\":50}}\n-,\"/Users/zachleat/Code/eleventy/src/BenchmarkManager.js\": {\"lines\":{\"total\":17,\"covered\":13,\"skipped\":0,\"pct\":76.47},\"functions\":{\"total\":7,\"covered\":5,\"skipped\":0,\"pct\":71.43},\"statements\":{\"total\":17,\"covered\":13,\"skipped\":0,\"pct\":76.47},\"branches\":{\"total\":4,\"covered\":2,\"skipped\":0,\"pct\":50}}\n+,\"/Users/zachleat/Code/eleventy/src/BenchmarkGroup.js\": {\"lines\":{\"total\":34,\"covered\":23,\"skipped\":0,\"pct\":67.65},\"functions\":{\"total\":7,\"covered\":5,\"skipped\":0,\"pct\":71.43},\"statements\":{\"total\":34,\"covered\":23,\"skipped\":0,\"pct\":67.65},\"branches\":{\"total\":10,\"covered\":3,\"skipped\":0,\"pct\":30}}\n+,\"/Users/zachleat/Code/eleventy/src/BenchmarkManager.js\": {\"lines\":{\"total\":17,\"covered\":13,\"skipped\":0,\"pct\":76.47},\"functions\":{\"total\":7,\"covered\":5,\"skipped\":0,\"pct\":71.43},\"statements\":{\"total\":17,\"covered\":13,\"skipped\":0,\"pct\":76.47},\"branches\":{\"total\":4,\"covered\":3,\"skipped\":0,\"pct\":75}}\n,\"/Users/zachleat/Code/eleventy/src/Config.js\": {\"lines\":{\"total\":5,\"covered\":5,\"skipped\":0,\"pct\":100},\"functions\":{\"total\":0,\"covered\":0,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":5,\"covered\":5,\"skipped\":0,\"pct\":100},\"branches\":{\"total\":0,\"covered\":0,\"skipped\":0,\"pct\":100}}\n-,\"/Users/zachleat/Code/eleventy/src/Eleventy.js\": {\"lines\":{\"total\":193,\"covered\":114,\"skipped\":0,\"pct\":59.07},\"functions\":{\"total\":31,\"covered\":16,\"skipped\":0,\"pct\":51.61},\"statements\":{\"total\":193,\"covered\":114,\"skipped\":0,\"pct\":59.07},\"branches\":{\"total\":48,\"covered\":22,\"skipped\":0,\"pct\":45.83}}\n+,\"/Users/zachleat/Code/eleventy/src/Eleventy.js\": {\"lines\":{\"total\":173,\"covered\":95,\"skipped\":0,\"pct\":54.91},\"functions\":{\"total\":33,\"covered\":19,\"skipped\":0,\"pct\":57.58},\"statements\":{\"total\":173,\"covered\":95,\"skipped\":0,\"pct\":54.91},\"branches\":{\"total\":50,\"covered\":24,\"skipped\":0,\"pct\":48}}\n,\"/Users/zachleat/Code/eleventy/src/EleventyBaseError.js\": {\"lines\":{\"total\":5,\"covered\":5,\"skipped\":0,\"pct\":100},\"functions\":{\"total\":1,\"covered\":1,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":5,\"covered\":5,\"skipped\":0,\"pct\":100},\"branches\":{\"total\":0,\"covered\":0,\"skipped\":0,\"pct\":100}}\n,\"/Users/zachleat/Code/eleventy/src/EleventyCommandCheck.js\": {\"lines\":{\"total\":28,\"covered\":28,\"skipped\":0,\"pct\":100},\"functions\":{\"total\":5,\"covered\":5,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":28,\"covered\":28,\"skipped\":0,\"pct\":100},\"branches\":{\"total\":8,\"covered\":7,\"skipped\":0,\"pct\":87.5}}\n,\"/Users/zachleat/Code/eleventy/src/EleventyConfig.js\": {\"lines\":{\"total\":2,\"covered\":2,\"skipped\":0,\"pct\":100},\"functions\":{\"total\":0,\"covered\":0,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":2,\"covered\":2,\"skipped\":0,\"pct\":100},\"branches\":{\"total\":0,\"covered\":0,\"skipped\":0,\"pct\":100}}\n,\"/Users/zachleat/Code/eleventy/src/EleventyExtensionMap.js\": {\"lines\":{\"total\":60,\"covered\":60,\"skipped\":0,\"pct\":100},\"functions\":{\"total\":25,\"covered\":25,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":60,\"covered\":60,\"skipped\":0,\"pct\":100},\"branches\":{\"total\":27,\"covered\":27,\"skipped\":0,\"pct\":100}}\n,\"/Users/zachleat/Code/eleventy/src/EleventyFiles.js\": {\"lines\":{\"total\":114,\"covered\":109,\"skipped\":0,\"pct\":95.61},\"functions\":{\"total\":35,\"covered\":31,\"skipped\":0,\"pct\":88.57},\"statements\":{\"total\":114,\"covered\":109,\"skipped\":0,\"pct\":95.61},\"branches\":{\"total\":34,\"covered\":31,\"skipped\":0,\"pct\":91.18}}\n,\"/Users/zachleat/Code/eleventy/src/EleventyServe.js\": {\"lines\":{\"total\":61,\"covered\":22,\"skipped\":0,\"pct\":36.07},\"functions\":{\"total\":16,\"covered\":9,\"skipped\":0,\"pct\":56.25},\"statements\":{\"total\":61,\"covered\":22,\"skipped\":0,\"pct\":36.07},\"branches\":{\"total\":41,\"covered\":10,\"skipped\":0,\"pct\":24.39}}\n-,\"/Users/zachleat/Code/eleventy/src/EleventyWatchTargets.js\": {\"lines\":{\"total\":45,\"covered\":42,\"skipped\":0,\"pct\":93.33},\"functions\":{\"total\":19,\"covered\":17,\"skipped\":0,\"pct\":89.47},\"statements\":{\"total\":45,\"covered\":42,\"skipped\":0,\"pct\":93.33},\"branches\":{\"total\":15,\"covered\":14,\"skipped\":0,\"pct\":93.33}}\n+,\"/Users/zachleat/Code/eleventy/src/EleventyWatchTargets.js\": {\"lines\":{\"total\":46,\"covered\":43,\"skipped\":0,\"pct\":93.48},\"functions\":{\"total\":20,\"covered\":18,\"skipped\":0,\"pct\":90},\"statements\":{\"total\":46,\"covered\":43,\"skipped\":0,\"pct\":93.48},\"branches\":{\"total\":15,\"covered\":14,\"skipped\":0,\"pct\":93.33}}\n,\"/Users/zachleat/Code/eleventy/src/Template.js\": {\"lines\":{\"total\":247,\"covered\":231,\"skipped\":0,\"pct\":93.52},\"functions\":{\"total\":43,\"covered\":41,\"skipped\":0,\"pct\":95.35},\"statements\":{\"total\":247,\"covered\":231,\"skipped\":0,\"pct\":93.52},\"branches\":{\"total\":95,\"covered\":80,\"skipped\":0,\"pct\":84.21}}\n,\"/Users/zachleat/Code/eleventy/src/TemplateCache.js\": {\"lines\":{\"total\":9,\"covered\":9,\"skipped\":0,\"pct\":100},\"functions\":{\"total\":6,\"covered\":6,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":9,\"covered\":9,\"skipped\":0,\"pct\":100},\"branches\":{\"total\":2,\"covered\":2,\"skipped\":0,\"pct\":100}}\n,\"/Users/zachleat/Code/eleventy/src/TemplateCollection.js\": {\"lines\":{\"total\":30,\"covered\":27,\"skipped\":0,\"pct\":90},\"functions\":{\"total\":13,\"covered\":12,\"skipped\":0,\"pct\":92.31},\"statements\":{\"total\":32,\"covered\":29,\"skipped\":0,\"pct\":90.63},\"branches\":{\"total\":12,\"covered\":9,\"skipped\":0,\"pct\":75}}\n,\"/Users/zachleat/Code/eleventy/src/Engines/Haml.js\": {\"lines\":{\"total\":9,\"covered\":9,\"skipped\":0,\"pct\":100},\"functions\":{\"total\":3,\"covered\":3,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":9,\"covered\":9,\"skipped\":0,\"pct\":100},\"branches\":{\"total\":2,\"covered\":2,\"skipped\":0,\"pct\":100}}\n,\"/Users/zachleat/Code/eleventy/src/Engines/Handlebars.js\": {\"lines\":{\"total\":30,\"covered\":30,\"skipped\":0,\"pct\":100},\"functions\":{\"total\":9,\"covered\":9,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":30,\"covered\":30,\"skipped\":0,\"pct\":100},\"branches\":{\"total\":6,\"covered\":5,\"skipped\":0,\"pct\":83.33}}\n,\"/Users/zachleat/Code/eleventy/src/Engines/Html.js\": {\"lines\":{\"total\":9,\"covered\":9,\"skipped\":0,\"pct\":100},\"functions\":{\"total\":3,\"covered\":3,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":9,\"covered\":9,\"skipped\":0,\"pct\":100},\"branches\":{\"total\":2,\"covered\":2,\"skipped\":0,\"pct\":100}}\n-,\"/Users/zachleat/Code/eleventy/src/Engines/JavaScript.js\": {\"lines\":{\"total\":37,\"covered\":37,\"skipped\":0,\"pct\":100},\"functions\":{\"total\":10,\"covered\":10,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":37,\"covered\":37,\"skipped\":0,\"pct\":100},\"branches\":{\"total\":22,\"covered\":22,\"skipped\":0,\"pct\":100}}\n+,\"/Users/zachleat/Code/eleventy/src/Engines/JavaScript.js\": {\"lines\":{\"total\":35,\"covered\":35,\"skipped\":0,\"pct\":100},\"functions\":{\"total\":10,\"covered\":10,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":35,\"covered\":35,\"skipped\":0,\"pct\":100},\"branches\":{\"total\":22,\"covered\":22,\"skipped\":0,\"pct\":100}}\n,\"/Users/zachleat/Code/eleventy/src/Engines/JavaScriptTemplateLiteral.js\": {\"lines\":{\"total\":18,\"covered\":17,\"skipped\":0,\"pct\":94.44},\"functions\":{\"total\":3,\"covered\":3,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":18,\"covered\":17,\"skipped\":0,\"pct\":94.44},\"branches\":{\"total\":6,\"covered\":6,\"skipped\":0,\"pct\":100}}\n,\"/Users/zachleat/Code/eleventy/src/Engines/Liquid.js\": {\"lines\":{\"total\":69,\"covered\":66,\"skipped\":0,\"pct\":95.65},\"functions\":{\"total\":26,\"covered\":25,\"skipped\":0,\"pct\":96.15},\"statements\":{\"total\":69,\"covered\":66,\"skipped\":0,\"pct\":95.65},\"branches\":{\"total\":10,\"covered\":8,\"skipped\":0,\"pct\":80}}\n,\"/Users/zachleat/Code/eleventy/src/Engines/Markdown.js\": {\"lines\":{\"total\":28,\"covered\":25,\"skipped\":0,\"pct\":89.29},\"functions\":{\"total\":8,\"covered\":7,\"skipped\":0,\"pct\":87.5},\"statements\":{\"total\":28,\"covered\":25,\"skipped\":0,\"pct\":89.29},\"branches\":{\"total\":12,\"covered\":9,\"skipped\":0,\"pct\":75}}\n" }, { "change_type": "MODIFY", "old_path": "docs/coverage.md", "new_path": "docs/coverage.md", "diff": "-# Code Coverage for Eleventy v0.7.0\n+# Code Coverage for Eleventy v0.7.1\n| Filename | % Lines | % Statements | % Functions | % Branches |\n| ------------------------------------------ | ------- | ------------ | ----------- | ---------- |\n-| `total` | 88.09% | 88.11% | 86.95% | 79.63% |\n+| `total` | 87.9% | 87.92% | 87.03% | 79.43% |\n| `config.js` | 100% | 100% | 100% | 100% |\n| `src/Benchmark.js` | 91.67% | 91.67% | 83.33% | 66.67% |\n-| `src/BenchmarkGroup.js` | 75.86% | 75.86% | 83.33% | 50% |\n-| `src/BenchmarkManager.js` | 76.47% | 76.47% | 71.43% | 50% |\n+| `src/BenchmarkGroup.js` | 67.65% | 67.65% | 71.43% | 30% |\n+| `src/BenchmarkManager.js` | 76.47% | 76.47% | 71.43% | 75% |\n| `src/Config.js` | 100% | 100% | 100% | 100% |\n-| `src/Eleventy.js` | 59.07% | 59.07% | 51.61% | 45.83% |\n+| `src/Eleventy.js` | 54.91% | 54.91% | 57.58% | 48% |\n| `src/EleventyBaseError.js` | 100% | 100% | 100% | 100% |\n| `src/EleventyCommandCheck.js` | 100% | 100% | 100% | 87.5% |\n| `src/EleventyConfig.js` | 100% | 100% | 100% | 100% |\n| `src/EleventyExtensionMap.js` | 100% | 100% | 100% | 100% |\n| `src/EleventyFiles.js` | 95.61% | 95.61% | 88.57% | 91.18% |\n| `src/EleventyServe.js` | 36.07% | 36.07% | 56.25% | 24.39% |\n-| `src/EleventyWatchTargets.js` | 93.33% | 93.33% | 89.47% | 93.33% |\n+| `src/EleventyWatchTargets.js` | 93.48% | 93.48% | 90% | 93.33% |\n| `src/Template.js` | 93.52% | 93.52% | 95.35% | 84.21% |\n| `src/TemplateCache.js` | 100% | 100% | 100% | 100% |\n| `src/TemplateCollection.js` | 90% | 90.63% | 92.31% | 75% |\n" }, { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "{\n\"name\": \"@11ty/eleventy\",\n- \"version\": \"0.7.0\",\n+ \"version\": \"0.7.1\",\n\"description\": \"Transform a directory of templates into HTML.\",\n\"main\": \"src/Eleventy.js\",\n\"license\": \"MIT\",\n" } ]
JavaScript
MIT License
11ty/eleventy
Version 0.7.1 quick maintenance release.
669
12.01.2019 15:36:32
-3,600
2e85d4dc83ea74efbf399d73d0e9bd3e508a8376
Fix broken tests on Windows (yes, it's newlines)
[ { "change_type": "MODIFY", "old_path": "test/TemplateMapTest.js", "new_path": "test/TemplateMapTest.js", "diff": "@@ -2,6 +2,7 @@ import test from \"ava\";\nimport Template from \"../src/Template\";\nimport TemplateMap from \"../src/TemplateMap\";\nimport TemplateCollection from \"../src/TemplateCollection\";\n+import normalizeNewLines from \"./Util/normalizeNewLines\";\nlet tmpl1 = new Template(\n\"./test/stubs/templateMapCollection/test1.md\",\n@@ -199,7 +200,7 @@ test(\"Issue #115, mixing pagination and collections\", async t => {\nt.is(Object.keys(map[2].data.collections.bars).length, 1);\nt.deepEqual(\n- map[2].templateContent,\n+ normalizeNewLines(map[2].templateContent),\n`This page is foos\nThis page is bars\n`\n@@ -259,7 +260,7 @@ test(\"Issue #115 with layout, mixing pagination and collections\", async t => {\nt.is(Object.keys(map[2].data.collections.bars).length, 1);\nt.deepEqual(\n- map[2].templateContent,\n+ normalizeNewLines(map[2].templateContent),\n`This page is foos\nThis page is bars\n`\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateTest.js", "new_path": "test/TemplateTest.js", "diff": "@@ -4,6 +4,7 @@ import pretty from \"pretty\";\nimport TemplateData from \"../src/TemplateData\";\nimport Template from \"../src/Template\";\nimport templateConfig from \"../src/Config\";\n+import normalizeNewLines from \"./Util/normalizeNewLines\";\nconst config = templateConfig.getConfig();\n@@ -176,7 +177,7 @@ test(\"One Layout (using new content var)\", async t => {\nt.is(data[config.keys.layout], \"defaultLayout\");\nt.is(\n- cleanHtml(await tmpl.renderLayout(tmpl, data)),\n+ normalizeNewLines(cleanHtml(await tmpl.renderLayout(tmpl, data))),\n`<div id=\"layout\">\n<p>Hello.</p>\n</div>`\n@@ -204,7 +205,7 @@ test(\"One Layout (using layoutContent)\", async t => {\nt.is(data[config.keys.layout], \"defaultLayoutLayoutContent\");\nt.is(\n- cleanHtml(await tmpl.renderLayout(tmpl, data)),\n+ normalizeNewLines(cleanHtml(await tmpl.renderLayout(tmpl, data))),\n`<div id=\"layout\">\n<p>Hello.</p>\n</div>`\n@@ -257,7 +258,7 @@ test(\"One Layout (_layoutContent deprecated but supported)\", async t => {\nt.is(data[config.keys.layout], \"defaultLayout_layoutContent\");\nt.is(\n- cleanHtml(await tmpl.renderLayout(tmpl, data)),\n+ normalizeNewLines(cleanHtml(await tmpl.renderLayout(tmpl, data))),\n`<div id=\"layout\">\n<p>Hello.</p>\n</div>`\n@@ -285,7 +286,7 @@ test(\"One Layout (liquid test)\", async t => {\nt.is(data[config.keys.layout], \"layoutLiquid.liquid\");\nt.is(\n- cleanHtml(await tmpl.renderLayout(tmpl, data)),\n+ normalizeNewLines(cleanHtml(await tmpl.renderLayout(tmpl, data))),\n`<div id=\"layout\">\n<p>Hello.</p>\n</div>`\n@@ -311,7 +312,7 @@ test(\"Two Layouts\", async t => {\nt.is(data.key1, \"value1\");\nt.is(\n- cleanHtml(await tmpl.renderLayout(tmpl, data)),\n+ normalizeNewLines(cleanHtml(await tmpl.renderLayout(tmpl, data))),\n`<div id=\"layout-b\">\n<div id=\"layout-a\">\n<p>value2-a</p>\n@@ -487,7 +488,7 @@ test(\"Posts inherits local JSON, layouts\", async t => {\nt.is(localData.layout, \"mylocallayout.njk\");\nt.is(\n- (await tmpl.render(data)).trim(),\n+ normalizeNewLines((await tmpl.render(data)).trim()),\n`<div id=\"locallayout\">Post1\n</div>`\n);\n@@ -519,7 +520,7 @@ test(\"Template and folder name are the same, make sure data imports work ok\", as\nt.is(localData.layout, \"mylocallayout.njk\");\nt.is(\n- (await tmpl.render(data)).trim(),\n+ normalizeNewLines((await tmpl.render(data)).trim()),\n`<div id=\"locallayout\">Posts\n</div>`\n);\n@@ -979,7 +980,7 @@ test(\"Using a markdown source file (with a layout that uses njk), markdown shoul\n);\nt.is(\n- (await tmpl.render()).trim(),\n+ normalizeNewLines((await tmpl.render()).trim()),\n`# Layout header\n<div id=\"layoutvalue\"><h1>My Title</h1>\n@@ -995,7 +996,7 @@ test(\"Override base templating engine from .md to ejs,md (with a layout that use\n);\nt.is(\n- (await tmpl.render()).trim(),\n+ normalizeNewLines((await tmpl.render()).trim()),\n`# Layout header\n<div id=\"layoutvalue\"><h1>My Title</h1>\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/Util/normalizeNewLines.js", "diff": "+function normalizeNewLines(str) {\n+ return str.replace(/\\r/g, \"\");\n+}\n+\n+module.exports = normalizeNewLines;\n" } ]
JavaScript
MIT License
11ty/eleventy
Fix broken tests on Windows (yes, it's newlines)
669
12.01.2019 16:46:28
-3,600
51adb790a24665178d699131651816016f61aa53
Add tests for normalizeNewLines
[ { "change_type": "ADD", "old_path": null, "new_path": "test/TestUtilityTest.js", "diff": "+import test from \"ava\";\n+import normalizeNewLines from \"./Util/normalizeNewLines\";\n+\n+test(\"normalizeNewLines\", t => {\n+ t.is(normalizeNewLines(\"\\r\"), \"\");\n+ t.is(normalizeNewLines(\"\\\\r\"), \"\\\\r\");\n+ t.is(normalizeNewLines(\"\\r\\n\"), \"\\n\");\n+ t.is(normalizeNewLines(\"\\r\\n\\r\"), \"\\n\");\n+ t.is(normalizeNewLines(\"\\r\\n\\n\"), \"\\n\\n\");\n+});\n" } ]
JavaScript
MIT License
11ty/eleventy
Add tests for normalizeNewLines
669
11.01.2019 16:34:31
-3,600
180485b65ff52d5ee453f9a94137b87ba2649977
TemplatePath: _getModuleDir
[ { "change_type": "MODIFY", "old_path": "src/TemplatePath.js", "new_path": "src/TemplatePath.js", "diff": "@@ -5,10 +5,6 @@ const fs = require(\"fs-extra\");\nfunction TemplatePath() {}\n-TemplatePath.getModuleDir = function() {\n- return path.resolve(__dirname, \"..\");\n-};\n-\nTemplatePath.getWorkingDir = function() {\nreturn path.resolve(\"./\");\n};\n@@ -205,4 +201,13 @@ TemplatePath.removeExtension = function(path, extension) {\nreturn path;\n};\n+/**\n+ * USE ONLY IN TESTS.\n+ *\n+ * @returns {String} the absolute path to this module.\n+ */\n+TemplatePath._getModuleDir = function() {\n+ return path.resolve(__dirname, \"..\");\n+};\n+\nmodule.exports = TemplatePath;\n" }, { "change_type": "MODIFY", "old_path": "test/TemplatePathTest.js", "new_path": "test/TemplatePathTest.js", "diff": "@@ -5,7 +5,7 @@ import TemplatePath from \"../src/TemplatePath\";\ntest(\"Working dir\", t => {\nt.is(TemplatePath.getWorkingDir(), path.resolve(\"./\"));\n- t.is(TemplatePath.getModuleDir(), path.resolve(__dirname, \"..\"));\n+ t.is(TemplatePath._getModuleDir(), path.resolve(__dirname, \"..\"));\n});\ntest(\"normalize\", async t => {\n" } ]
JavaScript
MIT License
11ty/eleventy
TemplatePath: _getModuleDir
669
11.01.2019 16:35:47
-3,600
8d97c594c65219d82c3ff22de85908ada226f322
TemplatePath: getWorkingDir
[ { "change_type": "MODIFY", "old_path": "test/TemplatePathTest.js", "new_path": "test/TemplatePathTest.js", "diff": "@@ -3,7 +3,7 @@ import path from \"path\";\nimport normalize from \"normalize-path\";\nimport TemplatePath from \"../src/TemplatePath\";\n-test(\"Working dir\", t => {\n+test(\"getWorkingDir\", t => {\nt.is(TemplatePath.getWorkingDir(), path.resolve(\"./\"));\nt.is(TemplatePath._getModuleDir(), path.resolve(__dirname, \"..\"));\n});\n" } ]
JavaScript
MIT License
11ty/eleventy
TemplatePath: getWorkingDir
669
11.01.2019 16:37:34
-3,600
23ec3b9e515c192d88c15cb566d8d9451bf04e72
TemplatePath: getDir
[ { "change_type": "MODIFY", "old_path": "test/TemplatePathTest.js", "new_path": "test/TemplatePathTest.js", "diff": "@@ -8,6 +8,15 @@ test(\"getWorkingDir\", t => {\nt.is(TemplatePath._getModuleDir(), path.resolve(__dirname, \"..\"));\n});\n+test(\"getDir\", t => {\n+ t.is(TemplatePath.getDir(\"README.md\"), \".\");\n+ t.is(TemplatePath.getDir(\"test/stubs/config.js\"), \"test/stubs\");\n+ t.is(TemplatePath.getDir(\"./test/stubs/config.js\"), \"./test/stubs\");\n+ t.is(TemplatePath.getDir(\"test/stubs/*.md\"), \"test/stubs\");\n+ t.is(TemplatePath.getDir(\"test/stubs/**\"), \"test/stubs\");\n+ t.is(TemplatePath.getDir(\"test/stubs/!(multiple.md)\"), \"test/stubs\");\n+});\n+\ntest(\"normalize\", async t => {\nt.is(TemplatePath.normalize(\"\"), \".\");\nt.is(TemplatePath.normalize(\".\"), \".\");\n@@ -134,12 +143,6 @@ test(\"stripPathFromDir\", t => {\nt.is(TemplatePath.stripPathFromDir(\".htaccess\", \".\"), \".htaccess\");\n});\n-test(\"getDir\", t => {\n- t.is(TemplatePath.getDir(\"README.md\"), \".\");\n- t.is(TemplatePath.getDir(\"test/stubs/config.js\"), \"test/stubs\");\n- t.is(TemplatePath.getDir(\"./test/stubs/config.js\"), \"./test/stubs\");\n-});\n-\ntest(\"getLastDir\", t => {\nt.is(TemplatePath.getLastDir(\"./testing/hello\"), \"hello\");\nt.is(TemplatePath.getLastDir(\"./testing\"), \"testing\");\n" } ]
JavaScript
MIT License
11ty/eleventy
TemplatePath: getDir
669
11.01.2019 16:39:26
-3,600
c20f205a1e5dff86f2cd063168219497e0f36c2e
TemplatePath: getDirFromFilePath
[ { "change_type": "MODIFY", "old_path": "src/TemplatePath.js", "new_path": "src/TemplatePath.js", "diff": "@@ -27,9 +27,19 @@ TemplatePath.getDir = function(path) {\nreturn TemplatePath.getDirFromFilePath(path);\n};\n-// Input points to a file\n-TemplatePath.getDirFromFilePath = function(filepath) {\n- return parsePath(filepath).dir || \".\";\n+/**\n+ * Returns the directory portion of a path that either points to a file\n+ * or ends in a glob pattern. If `path` points to a directory,\n+ * the returned value will have its last path segment stripped\n+ * due to how [`parsePath`][1] works.\n+ *\n+ * [1]: https://www.npmjs.com/package/parse-filepath\n+ *\n+ * @param {String} path A path\n+ * @returns {String} the directory portion of a path.\n+ */\n+TemplatePath.getDirFromFilePath = function(path) {\n+ return parsePath(path).dir || \".\";\n};\n// can assume a parse-filepath .dir is passed in here\n" }, { "change_type": "MODIFY", "old_path": "test/TemplatePathTest.js", "new_path": "test/TemplatePathTest.js", "diff": "@@ -17,6 +17,11 @@ test(\"getDir\", t => {\nt.is(TemplatePath.getDir(\"test/stubs/!(multiple.md)\"), \"test/stubs\");\n});\n+test(\"getDirFromFilePath\", t => {\n+ t.is(TemplatePath.getDirFromFilePath(\"test/stubs/*.md\"), \"test/stubs\");\n+ t.is(TemplatePath.getDirFromFilePath(\"test/stubs/!(x.md)\"), \"test/stubs\");\n+});\n+\ntest(\"normalize\", async t => {\nt.is(TemplatePath.normalize(\"\"), \".\");\nt.is(TemplatePath.normalize(\".\"), \".\");\n" } ]
JavaScript
MIT License
11ty/eleventy
TemplatePath: getDirFromFilePath
669
11.01.2019 16:41:54
-3,600
b6ff26758682695b4b52368ffbf0cb57546785ba
TemplatePath: getLastPathSegment
[ { "change_type": "MODIFY", "old_path": "src/TemplateData.js", "new_path": "src/TemplateData.js", "diff": "@@ -283,7 +283,7 @@ class TemplateData {\nlet allDirs = TemplatePath.getAllDirs(parsed.dir);\ndebugDev(\"allDirs: %o\", allDirs);\nfor (let dir of allDirs) {\n- let lastDir = TemplatePath.getLastDir(dir);\n+ let lastDir = TemplatePath.getLastPathSegment(dir);\nlet dirPathNoExt = dir + \"/\" + lastDir;\nif (!inputDir) {\n" }, { "change_type": "MODIFY", "old_path": "src/TemplatePath.js", "new_path": "src/TemplatePath.js", "diff": "@@ -42,17 +42,24 @@ TemplatePath.getDirFromFilePath = function(path) {\nreturn parsePath(path).dir || \".\";\n};\n-// can assume a parse-filepath .dir is passed in here\n-TemplatePath.getLastDir = function(path) {\n- let slashIndex = path.lastIndexOf(\"/\");\n-\n- if (slashIndex === -1) {\n+/**\n+ * Returns the last path segment in a path (no leading/trailing slashes).\n+ *\n+ * Assumes [`parsePath`][1] was called on `path` before.\n+ *\n+ * [1]: https://www.npmjs.com/package/parse-filepath\n+ *\n+ * @param {String} path A path\n+ * @returns {String} the last path segment in a path\n+ */\n+TemplatePath.getLastPathSegment = function(path) {\n+ if (!path.includes(\"/\")) {\nreturn path;\n- } else if (slashIndex === path.length - 1) {\n- // last character is a slash\n- path = path.substring(0, path.length - 1);\n}\n+ // Trim a trailing slash if there is one\n+ path = path.replace(/\\/$/, \"\");\n+\nreturn path.substr(path.lastIndexOf(\"/\") + 1);\n};\n" }, { "change_type": "MODIFY", "old_path": "test/TemplatePathTest.js", "new_path": "test/TemplatePathTest.js", "diff": "@@ -22,6 +22,14 @@ test(\"getDirFromFilePath\", t => {\nt.is(TemplatePath.getDirFromFilePath(\"test/stubs/!(x.md)\"), \"test/stubs\");\n});\n+test(\"getLastPathSegment\", t => {\n+ t.is(TemplatePath.getLastPathSegment(\"./testing/hello\"), \"hello\");\n+ t.is(TemplatePath.getLastPathSegment(\"./testing\"), \"testing\");\n+ t.is(TemplatePath.getLastPathSegment(\"./testing/\"), \"testing\");\n+ t.is(TemplatePath.getLastPathSegment(\"testing/\"), \"testing\");\n+ t.is(TemplatePath.getLastPathSegment(\"testing\"), \"testing\");\n+});\n+\ntest(\"normalize\", async t => {\nt.is(TemplatePath.normalize(\"\"), \".\");\nt.is(TemplatePath.normalize(\".\"), \".\");\n@@ -148,14 +156,6 @@ test(\"stripPathFromDir\", t => {\nt.is(TemplatePath.stripPathFromDir(\".htaccess\", \".\"), \".htaccess\");\n});\n-test(\"getLastDir\", t => {\n- t.is(TemplatePath.getLastDir(\"./testing/hello\"), \"hello\");\n- t.is(TemplatePath.getLastDir(\"./testing\"), \"testing\");\n- t.is(TemplatePath.getLastDir(\"./testing/\"), \"testing\");\n- t.is(TemplatePath.getLastDir(\"testing/\"), \"testing\");\n- t.is(TemplatePath.getLastDir(\"testing\"), \"testing\");\n-});\n-\ntest(\"getAllDirs\", t => {\nt.deepEqual(TemplatePath.getAllDirs(\".\"), [\".\"]);\nt.deepEqual(TemplatePath.getAllDirs(\"./testing/hello\"), [\n" } ]
JavaScript
MIT License
11ty/eleventy
TemplatePath: getLastPathSegment
669
11.01.2019 16:44:22
-3,600
dd28b2bee3ec17c118f484893c8e3c21d0656b19
TemplatePath: getAllDirs
[ { "change_type": "MODIFY", "old_path": "src/TemplatePath.js", "new_path": "src/TemplatePath.js", "diff": "@@ -63,21 +63,23 @@ TemplatePath.getLastPathSegment = function(path) {\nreturn path.substr(path.lastIndexOf(\"/\") + 1);\n};\n+/**\n+ * @param {String} path A path\n+ * @returns {String[]} an array of paths pointing to each path segment of the\n+ * provided `path`.\n+ */\nTemplatePath.getAllDirs = function(path) {\n- if (path.indexOf(\"/\") === -1) {\n+ // Trim a trailing slash if there is one\n+ path = path.replace(/\\/$/, \"\");\n+\n+ if (!path.includes(\"/\")) {\nreturn [path];\n}\n- let split = path.split(\"/\");\n- let results = [];\n- while (split.length) {\n- let folder = split.pop();\n- let parent = split.join(\"/\");\n- if (folder && folder !== \".\") {\n- results.push((parent ? parent + \"/\" : \"\") + folder);\n- }\n- }\n- return results;\n+ return path\n+ .split(\"/\")\n+ .map(segment => path.substring(0, path.indexOf(segment) + segment.length))\n+ .filter(path => path !== \".\");\n};\n/**\n" }, { "change_type": "MODIFY", "old_path": "test/TemplatePathTest.js", "new_path": "test/TemplatePathTest.js", "diff": "@@ -30,6 +30,24 @@ test(\"getLastPathSegment\", t => {\nt.is(TemplatePath.getLastPathSegment(\"testing\"), \"testing\");\n});\n+test(\"getAllDirs\", t => {\n+ t.deepEqual(TemplatePath.getAllDirs(\".\"), [\".\"]);\n+ t.deepEqual(TemplatePath.getAllDirs(\"./\"), [\".\"]);\n+ t.deepEqual(TemplatePath.getAllDirs(\"./testing\"), [\"./testing\"]);\n+ t.deepEqual(TemplatePath.getAllDirs(\"./testing/\"), [\"./testing\"]);\n+ t.deepEqual(TemplatePath.getAllDirs(\"testing/\"), [\"testing\"]);\n+ t.deepEqual(TemplatePath.getAllDirs(\"testing\"), [\"testing\"]);\n+ t.deepEqual(TemplatePath.getAllDirs(\"./testing/hello\"), [\n+ \"./testing\",\n+ \"./testing/hello\"\n+ ]);\n+ t.deepEqual(TemplatePath.getAllDirs(\"./src/collections/posts\"), [\n+ \"./src\",\n+ \"./src/collections\",\n+ \"./src/collections/posts\"\n+ ]);\n+});\n+\ntest(\"normalize\", async t => {\nt.is(TemplatePath.normalize(\"\"), \".\");\nt.is(TemplatePath.normalize(\".\"), \".\");\n@@ -156,23 +174,6 @@ test(\"stripPathFromDir\", t => {\nt.is(TemplatePath.stripPathFromDir(\".htaccess\", \".\"), \".htaccess\");\n});\n-test(\"getAllDirs\", t => {\n- t.deepEqual(TemplatePath.getAllDirs(\".\"), [\".\"]);\n- t.deepEqual(TemplatePath.getAllDirs(\"./testing/hello\"), [\n- \"./testing/hello\",\n- \"./testing\"\n- ]);\n- t.deepEqual(TemplatePath.getAllDirs(\"./testing\"), [\"./testing\"]);\n- t.deepEqual(TemplatePath.getAllDirs(\"./testing/\"), [\"./testing\"]);\n- t.deepEqual(TemplatePath.getAllDirs(\"testing/\"), [\"testing\"]);\n- t.deepEqual(TemplatePath.getAllDirs(\"testing\"), [\"testing\"]);\n- t.deepEqual(TemplatePath.getAllDirs(\"./src/collections/posts\"), [\n- \"./src/collections/posts\",\n- \"./src/collections\",\n- \"./src\"\n- ]);\n-});\n-\ntest(\"Convert to glob\", t => {\nt.is(TemplatePath.convertToGlob(\"\"), \"./**\");\nt.is(TemplatePath.convertToGlob(\"test/stubs\"), \"./test/stubs/**\");\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateTest.js", "new_path": "test/TemplateTest.js", "diff": "@@ -447,12 +447,12 @@ test(\"Local template data file import (two subdirectories deep)\", async t => {\n);\nt.deepEqual(await dataObj.getLocalDataPaths(tmpl.getInputPath()), [\n- \"./test/stubs/firstdir/firstdir.json\",\n- \"./test/stubs/firstdir/firstdir.11tydata.json\",\n- \"./test/stubs/firstdir/firstdir.11tydata.js\",\n\"./test/stubs/firstdir/seconddir/seconddir.json\",\n\"./test/stubs/firstdir/seconddir/seconddir.11tydata.json\",\n\"./test/stubs/firstdir/seconddir/seconddir.11tydata.js\",\n+ \"./test/stubs/firstdir/firstdir.json\",\n+ \"./test/stubs/firstdir/firstdir.11tydata.json\",\n+ \"./test/stubs/firstdir/firstdir.11tydata.js\",\n\"./test/stubs/firstdir/seconddir/component.json\",\n\"./test/stubs/firstdir/seconddir/component.11tydata.json\",\n\"./test/stubs/firstdir/seconddir/component.11tydata.js\"\n" } ]
JavaScript
MIT License
11ty/eleventy
TemplatePath: getAllDirs
669
11.01.2019 16:46:07
-3,600
cd04b7ade4f76579bab70796abefc610e30fac6e
TemplatePath: hasTrailingSlash
[ { "change_type": "MODIFY", "old_path": "src/TemplatePath.js", "new_path": "src/TemplatePath.js", "diff": "@@ -111,17 +111,25 @@ TemplatePath.join = function(...paths) {\nreturn normalize(path.join(...paths));\n};\n-TemplatePath.hasTrailingSlash = function(thePath, isPreNormalized) {\n- if (!thePath) {\n+/**\n+ * Determines whether a path ends in a path separating character.\n+ *\n+ * @param {String|undefined} path\n+ * @param {Boolean} pathIsNormalized\n+ * @returns {Boolean} whether `path` ends with a path separating character.\n+ */\n+TemplatePath.hasTrailingSlash = function(path, pathIsNormalized = false) {\n+ if (path === undefined || path.length === 0) {\nreturn false;\n}\n- let slash = \"/\";\n- // handle windows slashes too\n- if (isPreNormalized && process.platform === \"win32\") {\n- slash = \"\\\\\";\n+ let pathSeparator = \"/\";\n+ // Handle Windows path separators\n+ if (pathIsNormalized && process.platform === \"win32\") {\n+ pathSeparator = \"\\\\\";\n}\n- return thePath.length && thePath.charAt(thePath.length - 1) === slash;\n+\n+ return path.endsWith(pathSeparator);\n};\nTemplatePath.normalizeUrlPath = function(...paths) {\n" }, { "change_type": "MODIFY", "old_path": "test/TemplatePathTest.js", "new_path": "test/TemplatePathTest.js", "diff": "@@ -86,17 +86,8 @@ test(\"join\", async t => {\nt.is(TemplatePath.join(\"src\", \"test\", \"..\", \"_includes\"), \"src/_includes\");\n});\n-test(\"stripLeadingDotSlash\", t => {\n- t.is(TemplatePath.stripLeadingDotSlash(\"./test/stubs\"), \"test/stubs\");\n- t.is(TemplatePath.stripLeadingDotSlash(\"./dist\"), \"dist\");\n- t.is(TemplatePath.stripLeadingDotSlash(\"../dist\"), \"../dist\");\n- t.is(TemplatePath.stripLeadingDotSlash(\"dist\"), \"dist\");\n-\n- t.is(TemplatePath.stripLeadingDotSlash(\".htaccess\"), \".htaccess\");\n-});\n-\ntest(\"hasTrailingSlash\", t => {\n- t.is(TemplatePath.hasTrailingSlash(), false);\n+ t.is(TemplatePath.hasTrailingSlash(undefined), false);\nt.is(TemplatePath.hasTrailingSlash(\"\"), false);\nt.is(TemplatePath.hasTrailingSlash(\"dist\"), false);\nt.is(TemplatePath.hasTrailingSlash(\"./test/stubs\"), false);\n@@ -105,6 +96,15 @@ test(\"hasTrailingSlash\", t => {\nt.is(TemplatePath.hasTrailingSlash(\"./test/stubs/\"), true);\n});\n+test(\"stripLeadingDotSlash\", t => {\n+ t.is(TemplatePath.stripLeadingDotSlash(\"./test/stubs\"), \"test/stubs\");\n+ t.is(TemplatePath.stripLeadingDotSlash(\"./dist\"), \"dist\");\n+ t.is(TemplatePath.stripLeadingDotSlash(\"../dist\"), \"../dist\");\n+ t.is(TemplatePath.stripLeadingDotSlash(\"dist\"), \"dist\");\n+\n+ t.is(TemplatePath.stripLeadingDotSlash(\".htaccess\"), \".htaccess\");\n+});\n+\ntest(\"addLeadingDotSlash\", t => {\nt.is(TemplatePath.addLeadingDotSlash(\".\"), \"./\");\nt.is(TemplatePath.addLeadingDotSlash(\"..\"), \"../\");\n" } ]
JavaScript
MIT License
11ty/eleventy
TemplatePath: hasTrailingSlash
669
11.01.2019 16:47:23
-3,600
48b8ad96a620abe0e6bb7ce4cdacf66882e3360a
TemplatePath: normalizeUrlPath
[ { "change_type": "MODIFY", "old_path": "src/TemplatePath.js", "new_path": "src/TemplatePath.js", "diff": "@@ -132,13 +132,23 @@ TemplatePath.hasTrailingSlash = function(path, pathIsNormalized = false) {\nreturn path.endsWith(pathSeparator);\n};\n-TemplatePath.normalizeUrlPath = function(...paths) {\n- let thePath = path.join(...paths);\n- let hasTrailingSlashBefore = TemplatePath.hasTrailingSlash(thePath, true);\n- let normalizedPath = normalize(thePath);\n- let hasTrailingSlashAfter = TemplatePath.hasTrailingSlash(normalizedPath);\n+/**\n+ * Joins the given URL path segments and normalizes the resulting path.\n+ * Maintains traling path separators.\n+ *\n+ * @param {String[]} urlPaths\n+ * @returns {String} a normalized URL path described by the given URL path segments.\n+ */\n+TemplatePath.normalizeUrlPath = function(...urlPaths) {\n+ const urlPath = path.join(...urlPaths);\n+ const hasTrailingSlashBefore = TemplatePath.hasTrailingSlash(urlPath, true);\n+ const normalizedUrlPath = normalize(urlPath);\n+ const hasTrailingSlashAfter = TemplatePath.hasTrailingSlash(\n+ normalizedUrlPath\n+ );\n+\nreturn (\n- normalizedPath +\n+ normalizedUrlPath +\n(hasTrailingSlashBefore && !hasTrailingSlashAfter ? \"/\" : \"\")\n);\n};\n" } ]
JavaScript
MIT License
11ty/eleventy
TemplatePath: normalizeUrlPath
669
11.01.2019 16:54:07
-3,600
d2cb60b0a69438ca2cf3eeb591efc19856a7f8ce
TemplatePath: absolutePath + relativePath
[ { "change_type": "MODIFY", "old_path": "src/Eleventy.js", "new_path": "src/Eleventy.js", "diff": "@@ -85,7 +85,7 @@ class Eleventy {\n// reload package.json values (if applicable)\n// TODO only reset this if it changed\n- delete require.cache[TemplatePath.localPath(\"package.json\")];\n+ delete require.cache[TemplatePath.absolutePath(\"package.json\")];\nawait this.init();\n}\n" }, { "change_type": "MODIFY", "old_path": "src/EleventyFiles.js", "new_path": "src/EleventyFiles.js", "diff": "@@ -191,7 +191,7 @@ class EleventyFiles {\nEleventyFiles.getFileIgnores(\n[\nTemplatePath.join(\n- this.localPathRoot || TemplatePath.localPath(),\n+ this.localPathRoot || TemplatePath.getWorkingDir(),\n\".gitignore\"\n),\nTemplatePath.join(this.inputDir, \".gitignore\")\n@@ -204,7 +204,7 @@ class EleventyFiles {\nfiles = files.concat(\nEleventyFiles.getFileIgnores([\nTemplatePath.join(\n- this.localPathRoot || TemplatePath.localPath(),\n+ this.localPathRoot || TemplatePath.getWorkingDir(),\n\".eleventyignore\"\n),\nTemplatePath.join(this.inputDir, \".eleventyignore\")\n" }, { "change_type": "MODIFY", "old_path": "src/EleventyWatchTargets.js", "new_path": "src/EleventyWatchTargets.js", "diff": "@@ -84,14 +84,14 @@ class EleventyWatchTargets {\ndependencyTree\n.toList({\nfilename: file,\n- directory: TemplatePath.localPath(),\n+ directory: TemplatePath.absolutePath(),\nfilter: function(path) {\nreturn path.indexOf(\"node_modules\") === -1;\n}\n})\n.map(dependency => {\nreturn TemplatePath.addLeadingDotSlash(\n- TemplatePath.delocalPath(dependency)\n+ TemplatePath.relativePath(dependency)\n);\n})\n.filter(dependency => {\n@@ -109,7 +109,7 @@ class EleventyWatchTargets {\nclearDependencyRequireCache() {\nfor (let path of this.dependencies) {\n- delete require.cache[TemplatePath.localPath(path)];\n+ delete require.cache[TemplatePath.absolutePath(path)];\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "src/Engines/JavaScript.js", "new_path": "src/Engines/JavaScript.js", "diff": "@@ -11,7 +11,7 @@ class JavaScript extends TemplateEngine {\n}\n_getRequire(inputPath) {\n- let requirePath = TemplatePath.localPath(inputPath);\n+ let requirePath = TemplatePath.absolutePath(inputPath);\nreturn require(requirePath);\n}\n@@ -21,7 +21,7 @@ class JavaScript extends TemplateEngine {\n// only remove from cache once on startup (if it already exists)\ninitRequireCache(inputPath) {\n- let requirePath = TemplatePath.localPath(inputPath);\n+ let requirePath = TemplatePath.absolutePath(inputPath);\nif (requirePath in require.cache) {\ndelete require.cache[requirePath];\n}\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateData.js", "new_path": "src/TemplateData.js", "diff": "@@ -44,7 +44,7 @@ class TemplateData {\n}\ngetRawImports() {\n- let pkgPath = TemplatePath.localPath(\"package.json\");\n+ let pkgPath = TemplatePath.absolutePath(\"package.json\");\ntry {\nthis.rawImports[this.config.keys.package] = require(pkgPath);\n@@ -224,7 +224,7 @@ class TemplateData {\nasync getDataValue(path, rawImports, ignoreProcessing) {\nif (ignoreProcessing || TemplatePath.getExtension(path) === \"js\") {\n- let localPath = TemplatePath.localPath(path);\n+ let localPath = TemplatePath.absolutePath(path);\nif (await fs.pathExists(localPath)) {\nlet dataBench = bench.get(`\\`${path}\\``);\ndataBench.before();\n" }, { "change_type": "MODIFY", "old_path": "test/TemplatePathTest.js", "new_path": "test/TemplatePathTest.js", "diff": "@@ -96,6 +96,22 @@ test(\"hasTrailingSlash\", t => {\nt.is(TemplatePath.hasTrailingSlash(\"./test/stubs/\"), true);\n});\n+test(\"absolutePath\", t => {\n+ t.is(\n+ TemplatePath.absolutePath(\".eleventy.js\")\n+ .split(\"/\")\n+ .pop(),\n+ \".eleventy.js\"\n+ );\n+});\n+\n+test(\"absolutePath and relativePath\", t => {\n+ t.is(\n+ TemplatePath.relativePath(TemplatePath.absolutePath(\".eleventy.js\")),\n+ \".eleventy.js\"\n+ );\n+});\n+\ntest(\"stripLeadingDotSlash\", t => {\nt.is(TemplatePath.stripLeadingDotSlash(\"./test/stubs\"), \"test/stubs\");\nt.is(TemplatePath.stripLeadingDotSlash(\"./dist\"), \"dist\");\n@@ -228,19 +244,3 @@ test(\"stripLeadingDots\", t => {\nt.is(TemplatePath.stripLeadingDots(\"../dist\"), \"/dist\");\nt.is(TemplatePath.stripLeadingDots(\"dist\"), \"dist\");\n});\n-\n-test(\"localPath\", t => {\n- t.is(\n- TemplatePath.localPath(\".eleventy.js\")\n- .split(\"/\")\n- .pop(),\n- \".eleventy.js\"\n- );\n-});\n-\n-test(\"localPath and delocalPath\", t => {\n- t.is(\n- TemplatePath.delocalPath(TemplatePath.localPath(\".eleventy.js\")),\n- \".eleventy.js\"\n- );\n-});\n" } ]
JavaScript
MIT License
11ty/eleventy
TemplatePath: absolutePath + relativePath
669
11.01.2019 16:59:17
-3,600
22ee8052b9b6a0cb81b8ac0de2f2d6ec5929434e
TemplatePath: addLeadingDotSlash + addLeadingDotSlashArray
[ { "change_type": "MODIFY", "old_path": "src/TemplatePath.js", "new_path": "src/TemplatePath.js", "diff": "@@ -177,22 +177,31 @@ TemplatePath.relativePath = function(absolutePath) {\n);\n};\n+/**\n+ * Adds a leading dot-slash segment to each path in the `paths` array.\n+ *\n+ * @param {String[]} paths\n+ * @returns {String[]}\n+ */\nTemplatePath.addLeadingDotSlashArray = function(paths) {\n- return paths.map(function(path) {\n- return TemplatePath.addLeadingDotSlash(path);\n- });\n+ return paths.map(path => TemplatePath.addLeadingDotSlash(path));\n};\n+/**\n+ * Adds a leading dot-slash segment to `path`.\n+ *\n+ * @param {String} path\n+ * @returns {String}\n+ */\nTemplatePath.addLeadingDotSlash = function(path) {\nif (path === \".\" || path === \"..\") {\nreturn path + \"/\";\n- } else if (\n- path.indexOf(\"/\") === 0 ||\n- path.indexOf(\"./\") === 0 ||\n- path.indexOf(\"../\") === 0\n- ) {\n+ }\n+\n+ if (path.startsWith(\"/\") || path.startsWith(\"./\") || path.startsWith(\"../\")) {\nreturn path;\n}\n+\nreturn \"./\" + path;\n};\n" }, { "change_type": "MODIFY", "old_path": "test/TemplatePathTest.js", "new_path": "test/TemplatePathTest.js", "diff": "@@ -112,15 +112,6 @@ test(\"absolutePath and relativePath\", t => {\n);\n});\n-test(\"stripLeadingDotSlash\", t => {\n- t.is(TemplatePath.stripLeadingDotSlash(\"./test/stubs\"), \"test/stubs\");\n- t.is(TemplatePath.stripLeadingDotSlash(\"./dist\"), \"dist\");\n- t.is(TemplatePath.stripLeadingDotSlash(\"../dist\"), \"../dist\");\n- t.is(TemplatePath.stripLeadingDotSlash(\"dist\"), \"dist\");\n-\n- t.is(TemplatePath.stripLeadingDotSlash(\".htaccess\"), \".htaccess\");\n-});\n-\ntest(\"addLeadingDotSlash\", t => {\nt.is(TemplatePath.addLeadingDotSlash(\".\"), \"./\");\nt.is(TemplatePath.addLeadingDotSlash(\"..\"), \"../\");\n@@ -147,6 +138,15 @@ test(\"addLeadingDotSlashArray\", t => {\n]);\n});\n+test(\"stripLeadingDotSlash\", t => {\n+ t.is(TemplatePath.stripLeadingDotSlash(\"./test/stubs\"), \"test/stubs\");\n+ t.is(TemplatePath.stripLeadingDotSlash(\"./dist\"), \"dist\");\n+ t.is(TemplatePath.stripLeadingDotSlash(\"../dist\"), \"../dist\");\n+ t.is(TemplatePath.stripLeadingDotSlash(\"dist\"), \"dist\");\n+\n+ t.is(TemplatePath.stripLeadingDotSlash(\".htaccess\"), \".htaccess\");\n+});\n+\ntest(\"contains\", t => {\nt.false(TemplatePath.contains(\"./testing/hello\", \"./lskdjklfjz\"));\nt.false(TemplatePath.contains(\"./testing/hello\", \"lskdjklfjz\"));\n" } ]
JavaScript
MIT License
11ty/eleventy
TemplatePath: addLeadingDotSlash + addLeadingDotSlashArray
669
11.01.2019 17:02:03
-3,600
1f6d587fd920b5df64226c61fa00099819b9f739
TemplatePath: stripLeadingDotSlash
[ { "change_type": "MODIFY", "old_path": "src/TemplatePath.js", "new_path": "src/TemplatePath.js", "diff": "@@ -205,12 +205,18 @@ TemplatePath.addLeadingDotSlash = function(path) {\nreturn \"./\" + path;\n};\n-TemplatePath.stripLeadingDots = function(str) {\n- return str.replace(/^\\.*/, \"\");\n+/**\n+ * Removes a leading dot-slash segment.\n+ *\n+ * @param {String} path\n+ * @returns {String} the `path` without a leading dot-slash segment.\n+ */\n+TemplatePath.stripLeadingDotSlash = function(path) {\n+ return path.replace(/^\\.\\//, \"\");\n};\n-TemplatePath.stripLeadingDotSlash = function(dir) {\n- return dir.replace(/^\\.\\//, \"\");\n+TemplatePath.stripLeadingDots = function(str) {\n+ return str.replace(/^\\.*/, \"\");\n};\nTemplatePath.contains = function(haystack, needle) {\n" } ]
JavaScript
MIT License
11ty/eleventy
TemplatePath: stripLeadingDotSlash
669
11.01.2019 17:03:53
-3,600
a106f178874118049b3a35b38e5414619964a9f7
TemplatePath: startsWithSubPath
[ { "change_type": "MODIFY", "old_path": "src/Eleventy.js", "new_path": "src/Eleventy.js", "diff": "@@ -262,7 +262,7 @@ Arguments:\nthis.watcher.add(this.watchTargets.getNewTargetsSinceLastReset());\nlet isInclude =\n- path && TemplatePath.contains(path, this.eleventyFiles.getIncludesDir());\n+ path && TemplatePath.startsWithSubPath(path, this.eleventyFiles.getIncludesDir());\nthis.eleventyServe.reload(path, isInclude);\nthis.active = false;\n" }, { "change_type": "MODIFY", "old_path": "src/TemplatePath.js", "new_path": "src/TemplatePath.js", "diff": "@@ -215,15 +215,22 @@ TemplatePath.stripLeadingDotSlash = function(path) {\nreturn path.replace(/^\\.\\//, \"\");\n};\n-TemplatePath.stripLeadingDots = function(str) {\n- return str.replace(/^\\.*/, \"\");\n-};\n+/**\n+ * Determines whether a path starts with a given sub path.\n+ *\n+ * @param {String} path A path\n+ * @param {String} subPath A path\n+ * @returns {Boolean} whether `path` starts with `subPath`.\n+ */\n+TemplatePath.startsWithSubPath = function(path, subPath) {\n+ path = TemplatePath.normalize(path);\n+ subPath = TemplatePath.normalize(subPath);\n-TemplatePath.contains = function(haystack, needle) {\n- haystack = TemplatePath.stripLeadingDotSlash(normalize(haystack));\n- needle = TemplatePath.stripLeadingDotSlash(normalize(needle));\n+ return path.startsWith(subPath);\n+};\n- return haystack.indexOf(needle) === 0;\n+TemplatePath.stripLeadingDots = function(str) {\n+ return str.replace(/^\\.*/, \"\");\n};\nTemplatePath.stripPathFromDir = function(targetDir, prunedPath) {\n" }, { "change_type": "MODIFY", "old_path": "test/TemplatePathTest.js", "new_path": "test/TemplatePathTest.js", "diff": "@@ -147,25 +147,32 @@ test(\"stripLeadingDotSlash\", t => {\nt.is(TemplatePath.stripLeadingDotSlash(\".htaccess\"), \".htaccess\");\n});\n-test(\"contains\", t => {\n- t.false(TemplatePath.contains(\"./testing/hello\", \"./lskdjklfjz\"));\n- t.false(TemplatePath.contains(\"./testing/hello\", \"lskdjklfjz\"));\n- t.false(TemplatePath.contains(\"testing/hello\", \"./lskdjklfjz\"));\n- t.false(TemplatePath.contains(\"testing/hello\", \"lskdjklfjz\"));\n-\n- t.true(TemplatePath.contains(\"./testing/hello\", \"./testing\"));\n- t.true(TemplatePath.contains(\"./testing/hello\", \"testing\"));\n- t.true(TemplatePath.contains(\"testing/hello\", \"./testing\"));\n- t.true(TemplatePath.contains(\"testing/hello\", \"testing\"));\n-\n- t.true(TemplatePath.contains(\"testing/hello/subdir/test\", \"testing\"));\n- t.false(TemplatePath.contains(\"testing/hello/subdir/test\", \"hello\"));\n- t.false(TemplatePath.contains(\"testing/hello/subdir/test\", \"hello/subdir\"));\n+test(\"startsWithSubPath\", t => {\n+ t.false(TemplatePath.startsWithSubPath(\"./testing/hello\", \"./lskdjklfjz\"));\n+ t.false(TemplatePath.startsWithSubPath(\"./testing/hello\", \"lskdjklfjz\"));\n+ t.false(TemplatePath.startsWithSubPath(\"testing/hello\", \"./lskdjklfjz\"));\n+ t.false(TemplatePath.startsWithSubPath(\"testing/hello\", \"lskdjklfjz\"));\n+\n+ t.true(TemplatePath.startsWithSubPath(\"./testing/hello\", \"./testing\"));\n+ t.true(TemplatePath.startsWithSubPath(\"./testing/hello\", \"testing\"));\n+ t.true(TemplatePath.startsWithSubPath(\"testing/hello\", \"./testing\"));\n+ t.true(TemplatePath.startsWithSubPath(\"testing/hello\", \"testing\"));\n+\nt.true(\n- TemplatePath.contains(\"testing/hello/subdir/test\", \"testing/hello/subdir\")\n+ TemplatePath.startsWithSubPath(\"testing/hello/subdir/test\", \"testing\")\n+ );\n+ t.false(TemplatePath.startsWithSubPath(\"testing/hello/subdir/test\", \"hello\"));\n+ t.false(\n+ TemplatePath.startsWithSubPath(\"testing/hello/subdir/test\", \"hello/subdir\")\n+ );\n+ t.true(\n+ TemplatePath.startsWithSubPath(\n+ \"testing/hello/subdir/test\",\n+ \"testing/hello/subdir\"\n+ )\n);\nt.true(\n- TemplatePath.contains(\n+ TemplatePath.startsWithSubPath(\n\"testing/hello/subdir/test\",\n\"testing/hello/subdir/test\"\n)\n" } ]
JavaScript
MIT License
11ty/eleventy
TemplatePath: startsWithSubPath
669
11.01.2019 17:07:12
-3,600
f57c3ed97e6581f40739c9dba91f4d90fe8db69a
TemplatePath: stripLeadingSubPath
[ { "change_type": "MODIFY", "old_path": "docs-src/.eleventy.docs.js", "new_path": "docs-src/.eleventy.docs.js", "diff": "@@ -9,7 +9,7 @@ module.exports = {\n},\nnunjucksFilters: {\nremoveDir: function(str) {\n- return TemplatePath.stripPathFromDir(\n+ return TemplatePath.stripLeadingSubPath(\nstr,\nTemplatePath.join(__dirname, \"..\")\n);\n" }, { "change_type": "MODIFY", "old_path": "src/Engines/TemplateEngine.js", "new_path": "src/Engines/TemplateEngine.js", "diff": "@@ -62,7 +62,7 @@ class TemplateEngine {\npartialFiles = TemplatePath.addLeadingDotSlashArray(partialFiles);\nfor (let j = 0, k = partialFiles.length; j < k; j++) {\n- let partialPath = TemplatePath.stripPathFromDir(\n+ let partialPath = TemplatePath.stripLeadingSubPath(\npartialFiles[j],\nthis.inputDir\n);\n" }, { "change_type": "MODIFY", "old_path": "src/Template.js", "new_path": "src/Template.js", "diff": "@@ -66,7 +66,7 @@ class Template extends TemplateContent {\n}\ngetTemplateSubfolder() {\n- return TemplatePath.stripPathFromDir(this.parsed.dir, this.inputDir);\n+ return TemplatePath.stripLeadingSubPath(this.parsed.dir, this.inputDir);\n}\nget baseFile() {\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateData.js", "new_path": "src/TemplateData.js", "diff": "@@ -135,7 +135,7 @@ class TemplateData {\n}\ngetObjectPathForDataFile(path) {\n- let reducedPath = TemplatePath.stripPathFromDir(path, this.dataDir);\n+ let reducedPath = TemplatePath.stripLeadingSubPath(path, this.dataDir);\nlet parsed = parsePath(reducedPath);\nlet folders = parsed.dir ? parsed.dir.split(\"/\") : [];\nfolders.push(parsed.name);\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateFileSlug.js", "new_path": "src/TemplateFileSlug.js", "diff": "@@ -3,7 +3,7 @@ const TemplatePath = require(\"./TemplatePath\");\nclass TemplateFileSlug {\nconstructor(inputPath, inputDir) {\nif (inputDir) {\n- inputPath = TemplatePath.stripPathFromDir(inputPath, inputDir);\n+ inputPath = TemplatePath.stripLeadingSubPath(inputPath, inputDir);\n}\nthis.inputPath = inputPath;\n" }, { "change_type": "MODIFY", "old_path": "src/TemplatePassthrough.js", "new_path": "src/TemplatePassthrough.js", "diff": "@@ -13,7 +13,7 @@ class TemplatePassthrough {\ngetOutputPath() {\nreturn TemplatePath.join(\nthis.outputDir,\n- TemplatePath.stripPathFromDir(this.path, this.inputDir)\n+ TemplatePath.stripLeadingSubPath(this.path, this.inputDir)\n);\n}\n" }, { "change_type": "MODIFY", "old_path": "src/TemplatePath.js", "new_path": "src/TemplatePath.js", "diff": "@@ -171,7 +171,7 @@ TemplatePath.absolutePath = function(...paths) {\n* @returns {String} the relative path.\n*/\nTemplatePath.relativePath = function(absolutePath) {\n- return TemplatePath.stripPathFromDir(\n+ return TemplatePath.stripLeadingSubPath(\nabsolutePath,\nTemplatePath.getWorkingDir()\n);\n@@ -229,19 +229,23 @@ TemplatePath.startsWithSubPath = function(path, subPath) {\nreturn path.startsWith(subPath);\n};\n-TemplatePath.stripLeadingDots = function(str) {\n- return str.replace(/^\\.*/, \"\");\n-};\n-\n-TemplatePath.stripPathFromDir = function(targetDir, prunedPath) {\n- targetDir = TemplatePath.stripLeadingDotSlash(normalize(targetDir));\n- prunedPath = TemplatePath.stripLeadingDotSlash(normalize(prunedPath));\n+/**\n+ * Removes the `subPath` at the start of `path` if present\n+ * and returns the remainding path.\n+ *\n+ * @param {String} path A path\n+ * @param {String} subPath A path\n+ * @returns {String} the `path` without `subPath` at the start of it.\n+ */\n+TemplatePath.stripLeadingSubPath = function(path, subPath) {\n+ path = TemplatePath.normalize(path);\n+ subPath = TemplatePath.normalize(subPath);\n- if (prunedPath && prunedPath !== \".\" && targetDir.indexOf(prunedPath) === 0) {\n- return targetDir.substr(prunedPath.length + 1);\n+ if (subPath !== \".\" && path.startsWith(subPath)) {\n+ return path.substr(subPath.length + 1);\n}\n- return targetDir;\n+ return path;\n};\nTemplatePath.isDirectorySync = function(path) {\n" }, { "change_type": "MODIFY", "old_path": "test/TemplatePathTest.js", "new_path": "test/TemplatePathTest.js", "diff": "@@ -179,22 +179,23 @@ test(\"startsWithSubPath\", t => {\n);\n});\n-test(\"stripPathFromDir\", t => {\n+test(\"stripLeadingSubPath\", t => {\nt.is(\n- TemplatePath.stripPathFromDir(\"./testing/hello\", \"./lskdjklfjz\"),\n+ TemplatePath.stripLeadingSubPath(\"./testing/hello\", \"./lskdjklfjz\"),\n\"testing/hello\"\n);\n- t.is(TemplatePath.stripPathFromDir(\"./test/stubs\", \"./test\"), \"stubs\");\n- t.is(TemplatePath.stripPathFromDir(\"./testing/hello\", \"testing\"), \"hello\");\n- t.is(TemplatePath.stripPathFromDir(\"testing/hello\", \"testing\"), \"hello\");\n- t.is(TemplatePath.stripPathFromDir(\"testing/hello\", \"./testing\"), \"hello\");\n+ t.is(TemplatePath.stripLeadingSubPath(\"./test/stubs\", \"stubs\"), \"test/stubs\");\n+ t.is(TemplatePath.stripLeadingSubPath(\"./test/stubs\", \"./test\"), \"stubs\");\n+ t.is(TemplatePath.stripLeadingSubPath(\"./testing/hello\", \"testing\"), \"hello\");\n+ t.is(TemplatePath.stripLeadingSubPath(\"testing/hello\", \"testing\"), \"hello\");\n+ t.is(TemplatePath.stripLeadingSubPath(\"testing/hello\", \"./testing\"), \"hello\");\nt.is(\n- TemplatePath.stripPathFromDir(\"testing/hello/subdir/test\", \"testing\"),\n+ TemplatePath.stripLeadingSubPath(\"testing/hello/subdir/test\", \"testing\"),\n\"hello/subdir/test\"\n);\n- t.is(TemplatePath.stripPathFromDir(\".htaccess\", \"./\"), \".htaccess\");\n- t.is(TemplatePath.stripPathFromDir(\".htaccess\", \".\"), \".htaccess\");\n+ t.is(TemplatePath.stripLeadingSubPath(\".htaccess\", \"./\"), \".htaccess\");\n+ t.is(TemplatePath.stripLeadingSubPath(\".htaccess\", \".\"), \".htaccess\");\n});\ntest(\"Convert to glob\", t => {\n@@ -242,12 +243,3 @@ test(\"Remove extension\", t => {\n\"./test/stubs\"\n);\n});\n-\n-test(\"stripLeadingDots\", t => {\n- t.is(TemplatePath.stripLeadingDots(\".11ty.js\"), \"11ty.js\");\n- t.is(TemplatePath.stripLeadingDots(\".htaccess\"), \"htaccess\");\n-\n- t.is(TemplatePath.stripLeadingDots(\"./dist\"), \"/dist\");\n- t.is(TemplatePath.stripLeadingDots(\"../dist\"), \"/dist\");\n- t.is(TemplatePath.stripLeadingDots(\"dist\"), \"dist\");\n-});\n" } ]
JavaScript
MIT License
11ty/eleventy
TemplatePath: stripLeadingSubPath
669
11.01.2019 17:45:07
-3,600
1469a133bd53e556d19b41b51af6f9ce7e50f8c6
TemplatePath: isDirectorySync
[ { "change_type": "MODIFY", "old_path": "src/TemplatePath.js", "new_path": "src/TemplatePath.js", "diff": "@@ -248,6 +248,10 @@ TemplatePath.stripLeadingSubPath = function(path, subPath) {\nreturn path;\n};\n+/**\n+ * @param {String} path A path\n+ * @returns {Boolean} whether `path` points to an existing directory.\n+ */\nTemplatePath.isDirectorySync = function(path) {\nreturn fs.existsSync(path) && fs.statSync(path).isDirectory();\n};\n" } ]
JavaScript
MIT License
11ty/eleventy
TemplatePath: isDirectorySync
669
11.01.2019 17:45:56
-3,600
c775a6ac89726595f6c3c4c25c08b04efcd8a13e
TemplatePath: convertToRecursiveGlob
[ { "change_type": "MODIFY", "old_path": "src/EleventyExtensionMap.js", "new_path": "src/EleventyExtensionMap.js", "diff": "@@ -54,7 +54,7 @@ class EleventyExtensionMap {\n}\n_getGlobs(formatKeys, inputDir) {\n- let dir = TemplatePath.convertToGlob(inputDir);\n+ let dir = TemplatePath.convertToRecursiveGlob(inputDir);\nlet globs = [];\nformatKeys.forEach(\nfunction(key) {\n" }, { "change_type": "MODIFY", "old_path": "src/TemplatePassthroughManager.js", "new_path": "src/TemplatePassthroughManager.js", "diff": "@@ -53,7 +53,7 @@ class TemplatePassthroughManager {\ngetConfigPathGlobs() {\nreturn this.getConfigPaths().map(path => {\n- return TemplatePath.convertToGlob(path);\n+ return TemplatePath.convertToRecursiveGlob(path);\n});\n}\n" }, { "change_type": "MODIFY", "old_path": "src/TemplatePath.js", "new_path": "src/TemplatePath.js", "diff": "@@ -256,8 +256,16 @@ TemplatePath.isDirectorySync = function(path) {\nreturn fs.existsSync(path) && fs.statSync(path).isDirectory();\n};\n-TemplatePath.convertToGlob = function(path) {\n- if (!path) {\n+/**\n+ * Appends a recursive wildcard glob pattern to `path`\n+ * unless `path` is not a directory; then, `path` is assumed to be a file path\n+ * and is left unchaged.\n+ *\n+ * @param {String} path\n+ * @returns {String}\n+ */\n+TemplatePath.convertToRecursiveGlob = function(path) {\n+ if (path === \"\") {\nreturn \"./**\";\n}\n" }, { "change_type": "MODIFY", "old_path": "test/EleventyExtensionMapTest.js", "new_path": "test/EleventyExtensionMapTest.js", "diff": "@@ -3,16 +3,16 @@ import EleventyExtensionMap from \"../src/EleventyExtensionMap\";\ntest(\"Empty formats\", t => {\nlet map = new EleventyExtensionMap([]);\n- t.deepEqual(map.getGlobs(), []);\n+ t.deepEqual(map.getGlobs(\".\"), []);\n});\ntest(\"Single format\", t => {\nlet map = new EleventyExtensionMap([\"pug\"]);\n- t.deepEqual(map.getGlobs(), [\"./**/*.pug\"]);\n+ t.deepEqual(map.getGlobs(\".\"), [\"./**/*.pug\"]);\nt.deepEqual(map.getGlobs(\"src\"), [\"./src/**/*.pug\"]);\n});\ntest(\"Multiple formats\", t => {\nlet map = new EleventyExtensionMap([\"njk\", \"pug\"]);\n- t.deepEqual(map.getGlobs(), [\"./**/*.njk\", \"./**/*.pug\"]);\n+ t.deepEqual(map.getGlobs(\".\"), [\"./**/*.njk\", \"./**/*.pug\"]);\nt.deepEqual(map.getGlobs(\"src\"), [\"./src/**/*.njk\", \"./src/**/*.pug\"]);\n});\n@@ -21,7 +21,7 @@ test(\"Invalid keys are filtered (no passthrough copy)\", t => {\nmap.config = {\npassthroughFileCopy: false\n};\n- t.deepEqual(map.getGlobs(), []);\n+ t.deepEqual(map.getGlobs(\".\"), []);\n});\ntest(\"Invalid keys are filtered (using passthrough copy)\", t => {\n@@ -29,17 +29,17 @@ test(\"Invalid keys are filtered (using passthrough copy)\", t => {\nmap.config = {\npassthroughFileCopy: true\n};\n- t.deepEqual(map.getGlobs(), [\"./**/*.lksdjfjlsk\"]);\n+ t.deepEqual(map.getGlobs(\".\"), [\"./**/*.lksdjfjlsk\"]);\n});\ntest(\"Keys are mapped to lower case\", t => {\nlet map = new EleventyExtensionMap([\"PUG\", \"NJK\"]);\n- t.deepEqual(map.getGlobs(), [\"./**/*.pug\", \"./**/*.njk\"]);\n+ t.deepEqual(map.getGlobs(\".\"), [\"./**/*.pug\", \"./**/*.njk\"]);\n});\ntest(\"Pruned globs\", t => {\nlet map = new EleventyExtensionMap([\"pug\", \"njk\", \"png\"]);\n- t.deepEqual(map.getPrunedGlobs(), [\"./**/*.png\"]);\n+ t.deepEqual(map.getPrunedGlobs(\".\"), [\"./**/*.png\"]);\n});\ntest(\"Empty path for fileList\", t => {\n@@ -120,7 +120,7 @@ test(\"Extension aliasing (one format key)\", t => {\nt.deepEqual(map.getExtensionsFromKey(\"njk\"), [\"njk\", \"nunjucks\"]);\n// should filter out N/A aliases\n- t.deepEqual(map.getGlobs(), [\"./**/*.md\", \"./**/*.markdown\"]);\n+ t.deepEqual(map.getGlobs(\".\"), [\"./**/*.md\", \"./**/*.markdown\"]);\n});\ntest(\"Extension aliasing (two format keys)\", t => {\n@@ -134,7 +134,7 @@ test(\"Extension aliasing (two format keys)\", t => {\nt.deepEqual(map.getExtensionsFromKey(\"md\"), [\"md\", \"markdown\"]);\nt.deepEqual(map.getExtensionsFromKey(\"njk\"), [\"njk\", \"nunjucks\"]);\n- t.deepEqual(map.getGlobs(), [\n+ t.deepEqual(map.getGlobs(\".\"), [\n\"./**/*.md\",\n\"./**/*.markdown\",\n\"./**/*.njk\",\n" }, { "change_type": "MODIFY", "old_path": "test/TemplatePathTest.js", "new_path": "test/TemplatePathTest.js", "diff": "@@ -198,11 +198,17 @@ test(\"stripLeadingSubPath\", t => {\nt.is(TemplatePath.stripLeadingSubPath(\".htaccess\", \".\"), \".htaccess\");\n});\n-test(\"Convert to glob\", t => {\n- t.is(TemplatePath.convertToGlob(\"\"), \"./**\");\n- t.is(TemplatePath.convertToGlob(\"test/stubs\"), \"./test/stubs/**\");\n- t.is(TemplatePath.convertToGlob(\"test/stubs/\"), \"./test/stubs/**\");\n- t.is(TemplatePath.convertToGlob(\"./test/stubs/\"), \"./test/stubs/**\");\n+test(\"convertToRecursiveGlob\", t => {\n+ t.is(TemplatePath.convertToRecursiveGlob(\"\"), \"./**\");\n+ t.is(TemplatePath.convertToRecursiveGlob(\".\"), \"./**\");\n+ t.is(TemplatePath.convertToRecursiveGlob(\"./\"), \"./**\");\n+ t.is(TemplatePath.convertToRecursiveGlob(\"test/stubs\"), \"./test/stubs/**\");\n+ t.is(TemplatePath.convertToRecursiveGlob(\"test/stubs/\"), \"./test/stubs/**\");\n+ t.is(TemplatePath.convertToRecursiveGlob(\"./test/stubs/\"), \"./test/stubs/**\");\n+ t.is(\n+ TemplatePath.convertToRecursiveGlob(\"./test/stubs/config.js\"),\n+ \"./test/stubs/config.js\"\n+ );\n});\ntest(\"Get extension\", t => {\n" } ]
JavaScript
MIT License
11ty/eleventy
TemplatePath: convertToRecursiveGlob
669
11.01.2019 17:46:40
-3,600
ebaf14772acb8347abbab2f0a7be09da4761a3ad
TemplatePath: getExtension
[ { "change_type": "MODIFY", "old_path": "test/TemplatePathTest.js", "new_path": "test/TemplatePathTest.js", "diff": "@@ -211,7 +211,7 @@ test(\"convertToRecursiveGlob\", t => {\n);\n});\n-test(\"Get extension\", t => {\n+test(\"getExtension\", t => {\nt.is(TemplatePath.getExtension(\"\"), \"\");\nt.is(TemplatePath.getExtension(\"test/stubs\"), \"\");\nt.is(TemplatePath.getExtension(\"test/stubs.njk\"), \"njk\");\n" } ]
JavaScript
MIT License
11ty/eleventy
TemplatePath: getExtension
669
11.01.2019 17:47:05
-3,600
adb44cb557fdc16f270512a9448e81fb5410306e
TemplatePath: removeExtension
[ { "change_type": "MODIFY", "old_path": "src/TemplatePath.js", "new_path": "src/TemplatePath.js", "diff": "@@ -290,16 +290,21 @@ TemplatePath.getExtension = function(thePath) {\nreturn path.extname(thePath).replace(/^\\./, \"\");\n};\n-TemplatePath.removeExtension = function(path, extension) {\n- let split = path.split(\".\");\n-\n- // only remove extension if extension is passed in and an extension is found\n- if (extension && split.length > 1) {\n- let ext = split.pop();\n- if (extension.charAt(0) === \".\") {\n- extension = extension.substr(1);\n+/**\n+ * Removes the extension from a path.\n+ *\n+ * @param {String} path\n+ * @param {String} extension\n+ * @returns {String}\n+ */\n+TemplatePath.removeExtension = function(path, extension = undefined) {\n+ if (extension === undefined) {\n+ return path;\n}\n- return split.join(\".\") + (!extension || ext === extension ? \"\" : \".\" + ext);\n+\n+ const pathExtension = TemplatePath.getExtension(path);\n+ if (pathExtension !== \"\" && extension.endsWith(pathExtension)) {\n+ return path.substring(0, path.lastIndexOf(pathExtension) - 1);\n}\nreturn path;\n" }, { "change_type": "MODIFY", "old_path": "test/TemplatePathTest.js", "new_path": "test/TemplatePathTest.js", "diff": "@@ -218,7 +218,7 @@ test(\"getExtension\", t => {\nt.is(TemplatePath.getExtension(\"test/stubs.hbs\"), \"hbs\");\n});\n-test(\"Remove extension\", t => {\n+test(\"removeExtension\", t => {\nt.is(TemplatePath.removeExtension(\"\"), \"\");\nt.is(TemplatePath.removeExtension(\"\", \"hbs\"), \"\");\n" } ]
JavaScript
MIT License
11ty/eleventy
TemplatePath: removeExtension
669
13.01.2019 13:13:05
-3,600
2c96b701012fe3186bf079d8395e8941072450a6
Refactor normalizeUrlPath, remove hasTrailingSlash
[ { "change_type": "MODIFY", "old_path": "src/TemplatePath.js", "new_path": "src/TemplatePath.js", "diff": "@@ -111,46 +111,17 @@ TemplatePath.join = function(...paths) {\nreturn normalize(path.join(...paths));\n};\n-/**\n- * Determines whether a path ends in a path separating character.\n- *\n- * @param {String|undefined} path\n- * @param {Boolean} pathIsNormalized\n- * @returns {Boolean} whether `path` ends with a path separating character.\n- */\n-TemplatePath.hasTrailingSlash = function(path, pathIsNormalized = false) {\n- if (path === undefined || path.length === 0) {\n- return false;\n- }\n-\n- let pathSeparator = \"/\";\n- // Handle Windows path separators\n- if (pathIsNormalized && process.platform === \"win32\") {\n- pathSeparator = \"\\\\\";\n- }\n-\n- return path.endsWith(pathSeparator);\n-};\n-\n/**\n* Joins the given URL path segments and normalizes the resulting path.\n- * Maintains traling path separators.\n+ * Maintains traling a single trailing slash if the last URL path argument\n+ * had atleast one.\n*\n* @param {String[]} urlPaths\n* @returns {String} a normalized URL path described by the given URL path segments.\n*/\nTemplatePath.normalizeUrlPath = function(...urlPaths) {\nconst urlPath = path.join(...urlPaths);\n- const hasTrailingSlashBefore = TemplatePath.hasTrailingSlash(urlPath, true);\n- const normalizedUrlPath = normalize(urlPath);\n- const hasTrailingSlashAfter = TemplatePath.hasTrailingSlash(\n- normalizedUrlPath\n- );\n-\n- return (\n- normalizedUrlPath +\n- (hasTrailingSlashBefore && !hasTrailingSlashAfter ? \"/\" : \"\")\n- );\n+ return urlPath.replace(/\\/+$/, \"/\");\n};\n/**\n@@ -272,7 +243,7 @@ TemplatePath.convertToRecursiveGlob = function(path) {\npath = TemplatePath.addLeadingDotSlash(path);\nif (TemplatePath.isDirectorySync(path)) {\n- return path + (!TemplatePath.hasTrailingSlash(path) ? \"/\" : \"\") + \"**\";\n+ return path + (!path.endsWith(\"/\") ? \"/\" : \"\") + \"**\";\n}\nreturn path;\n" }, { "change_type": "MODIFY", "old_path": "test/TemplatePathTest.js", "new_path": "test/TemplatePathTest.js", "diff": "@@ -78,14 +78,21 @@ test(\"join\", async t => {\nt.is(TemplatePath.join(\"src\", \"test\", \"..\", \"_includes\"), \"src/_includes\");\n});\n-test(\"hasTrailingSlash\", t => {\n- t.is(TemplatePath.hasTrailingSlash(undefined), false);\n- t.is(TemplatePath.hasTrailingSlash(\"\"), false);\n- t.is(TemplatePath.hasTrailingSlash(\"dist\"), false);\n- t.is(TemplatePath.hasTrailingSlash(\"./test/stubs\"), false);\n- t.is(TemplatePath.hasTrailingSlash(\"/\"), true);\n- t.is(TemplatePath.hasTrailingSlash(\"dist/\"), true);\n- t.is(TemplatePath.hasTrailingSlash(\"./test/stubs/\"), true);\n+test(\"normalizeUrlPath\", t => {\n+ t.is(TemplatePath.normalizeUrlPath(\"\"), \".\");\n+ t.is(TemplatePath.normalizeUrlPath(\".\"), \".\");\n+ t.is(TemplatePath.normalizeUrlPath(\"./\"), \"./\");\n+ t.is(TemplatePath.normalizeUrlPath(\"..\"), \"..\");\n+ t.is(TemplatePath.normalizeUrlPath(\"../\"), \"../\");\n+\n+ t.is(TemplatePath.normalizeUrlPath(\"/\"), \"/\");\n+ t.is(TemplatePath.normalizeUrlPath(\"//\"), \"/\");\n+ t.is(TemplatePath.normalizeUrlPath(\"/../\"), \"/\");\n+ t.is(TemplatePath.normalizeUrlPath(\"/test\"), \"/test\");\n+ t.is(TemplatePath.normalizeUrlPath(\"/test/\"), \"/test/\");\n+ t.is(TemplatePath.normalizeUrlPath(\"/test//\"), \"/test/\");\n+ t.is(TemplatePath.normalizeUrlPath(\"/test/../\"), \"/\");\n+ t.is(TemplatePath.normalizeUrlPath(\"/test/../../\"), \"/\");\n});\ntest(\"absolutePath\", t => {\n" } ]
JavaScript
MIT License
11ty/eleventy
Refactor normalizeUrlPath, remove hasTrailingSlash
699
08.02.2019 10:10:14
21,600
c9dab7b3abaf5d5135b05a4cab49e5a009328455
Start of refactor for
[ { "change_type": "MODIFY", "old_path": "src/TemplateCollection.js", "new_path": "src/TemplateCollection.js", "diff": "@@ -9,8 +9,9 @@ class TemplateCollection extends Sortable {\n// right now this is only used by the tests\nasync _testAddTemplate(template) {\n- let templateMap = await template.getMapped();\n- this.add(templateMap);\n+ for (let map of await template.getMappedTemplates()) {\n+ this.add(map);\n+ }\n}\ngetAll() {\n" }, { "change_type": "MODIFY", "old_path": "test/PaginationTest.js", "new_path": "test/PaginationTest.js", "diff": "@@ -29,6 +29,7 @@ test(\"No pagination\", async t => {\npaging.setTemplate(tmpl);\nt.falsy(data.pagination);\n+ t.is(paging.getPageCount(), 0);\nt.is(paging.getPagedItems().length, 0);\nt.is((await paging.getPageTemplates()).length, 0);\n});\n@@ -49,6 +50,7 @@ test(\"Pagination enabled in frontmatter\", async t => {\nt.truthy(data.pagination);\nt.is(data.pagination.data, \"testdata.sub\");\n+ t.is(paging.getPageCount(), 2);\nt.is(data.pagination.size, 4);\n});\n@@ -63,6 +65,7 @@ test(\"Resolve paged data in frontmatter\", async t => {\nlet paging = new Pagination(data);\npaging.setTemplate(tmpl);\nt.is(paging._resolveItems().length, 8);\n+ t.is(paging.getPageCount(), 2);\nt.is(paging.getPagedItems().length, 2);\n});\n@@ -76,6 +79,7 @@ test(\"Paginate data in frontmatter\", async t => {\nlet data = await tmpl.getData();\nlet paging = new Pagination(data);\npaging.setTemplate(tmpl);\n+ t.is(paging.getPageCount(), 2);\nlet pages = await paging.getPageTemplates();\nt.is(pages.length, 2);\n@@ -116,6 +120,7 @@ test(\"Paginate external data file\", async t => {\nlet paging = new Pagination(data);\npaging.setTemplate(tmpl);\n+ t.is(paging.getPageCount(), 2);\nlet pages = await paging.getPageTemplates();\nt.is(pages.length, 2);\n@@ -149,6 +154,7 @@ test(\"Permalink with pagination variables\", async t => {\nlet data = await tmpl.getData();\nlet paging = new Pagination(data);\npaging.setTemplate(tmpl);\n+ t.is(paging.getPageCount(), 2);\nlet pages = await paging.getPageTemplates();\nt.is(\n@@ -171,6 +177,7 @@ test(\"Permalink with pagination variables (numeric)\", async t => {\nlet data = await tmpl.getData();\nlet paging = new Pagination(data);\npaging.setTemplate(tmpl);\n+ t.is(paging.getPageCount(), 2);\nlet pages = await paging.getPageTemplates();\nlet page0Data = await pages[0].getData();\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateMapTest.js", "new_path": "test/TemplateMapTest.js", "diff": "@@ -584,6 +584,7 @@ test.skip(\"Issue #253: Paginated template with a tag should put multiple pages i\n);\nawait tm.add(pagedTmpl);\n+ // TODO test user config collections (no actual tests against this collection yet)\ntm.setUserConfigCollections({\nuserCollection: function(collection) {\nlet all = collection.getFilteredByTag(\"dog\");\n@@ -599,3 +600,72 @@ test.skip(\"Issue #253: Paginated template with a tag should put multiple pages i\nt.is(collections.haha[0].url, \"/tagged-pagination-multiples/test/\");\nt.is(collections.haha[1].url, \"/tagged-pagination-multiples/test/1/\");\n});\n+\n+test(\"getUserConfigCollectionNames\", async t => {\n+ let tm = new TemplateMap();\n+\n+ tm.setUserConfigCollections({\n+ userCollection: function(collection) {\n+ return collection.getAll();\n+ },\n+ otherUserCollection: function(collection) {\n+ return collection.getAll();\n+ }\n+ });\n+\n+ t.deepEqual(tm.getUserConfigCollectionNames(), [\n+ \"userCollection\",\n+ \"otherUserCollection\"\n+ ]);\n+});\n+\n+test(\"isPaginationUsingUserConfigCollection\", async t => {\n+ let tm = new TemplateMap();\n+ tm.setUserConfigCollections({\n+ userCollection: function(collection) {\n+ return collection.getAll();\n+ }\n+ });\n+\n+ t.is(\n+ tm.isPaginationUsingUserConfigCollection({\n+ data: {\n+ pagination: {\n+ data: \"collections.dog\"\n+ }\n+ }\n+ }),\n+ false\n+ );\n+\n+ t.is(\n+ tm.isPaginationUsingUserConfigCollection({\n+ data: {\n+ pagination: {\n+ data: \"collections.userCollection\"\n+ }\n+ }\n+ }),\n+ true\n+ );\n+});\n+\n+test(\"isSafe\", async t => {\n+ let tm = new TemplateMap();\n+ tm.setUserConfigCollections({\n+ userCollection: function(collection) {\n+ return collection.getAll();\n+ }\n+ });\n+\n+ t.is(tm.isSafe({ data: { pagination: {} } }), true);\n+ t.is(\n+ tm.isSafe({ data: { pagination: { data: \"collections.unlisted\" } } }),\n+ true\n+ );\n+ t.is(\n+ tm.isSafe({ data: { pagination: { data: \"collections.userCollection\" } } }),\n+ false\n+ );\n+ t.is(tm.isSafe({ data: {} }), true);\n+});\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateWriterTest.js", "new_path": "test/TemplateWriterTest.js", "diff": "@@ -183,7 +183,7 @@ test(\"Pagination with a Collection\", async t => {\nt.is(collectionsData.tag1.length, 3);\nt.is(collectionsData.pagingtag.length, 1);\n- let mapEntry = templateMap.getMapEntryForPath(\n+ let mapEntry = templateMap._testGetMapEntryForPath(\n\"./test/stubs/paged/collection/main.njk\"\n);\nt.truthy(mapEntry);\n@@ -229,7 +229,7 @@ test(\"Use a collection inside of a template\", async t => {\nlet collectionsData = await templateMap.getCollectionsData();\nt.is(collectionsData.dog.length, 1);\n- let mapEntry = templateMap.getMapEntryForPath(\n+ let mapEntry = templateMap._testGetMapEntryForPath(\n\"./test/stubs/collection-template/template.ejs\"\n);\nt.truthy(mapEntry);\n@@ -272,7 +272,7 @@ test(\"Use a collection inside of a layout\", async t => {\nlet collectionsData = await templateMap.getCollectionsData();\nt.is(collectionsData.dog.length, 1);\n- let mapEntry = templateMap.getMapEntryForPath(\n+ let mapEntry = templateMap._testGetMapEntryForPath(\n\"./test/stubs/collection-layout/template.ejs\"\n);\nt.truthy(mapEntry);\n@@ -404,7 +404,7 @@ test(\"fileSlug should exist in a collection\", async t => {\nlet collectionsData = await templateMap.getCollectionsData();\nt.is(collectionsData.dog.length, 1);\n- let mapEntry = templateMap.getMapEntryForPath(\n+ let mapEntry = templateMap._testGetMapEntryForPath(\n\"./test/stubs/collection-slug/template.njk\"\n);\nt.truthy(mapEntry);\n@@ -429,7 +429,7 @@ test.skip(\"renderData should exist and be resolved in a collection (Issue #289)\"\nlet collectionsData = await templateMap.getCollectionsData();\nt.is(collectionsData.dog.length, 1);\n- let mapEntry = templateMap.getMapEntryForPath(\n+ let mapEntry = templateMap._testGetMapEntryForPath(\n\"./test/stubs/collection-renderdata/template.njk\"\n);\nt.truthy(mapEntry);\n" } ]
JavaScript
MIT License
11ty/eleventy
Start of refactor for #253
699
09.02.2019 20:47:32
21,600
66c4771b384eefbf4b6901c0c555d04be6a6768a
Back to working tests with refactored code.
[ { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "},\n\"devDependencies\": {\n\"@11ty/eleventy-plugin-syntaxhighlight\": \"^2.0.1\",\n- \"ava\": \"^1.1.0\",\n+ \"ava\": \"^1.2.1\",\n\"husky\": \"^1.3.1\",\n\"lint-staged\": \"^8.1.0\",\n\"markdown-it-emoji\": \"^1.4.0\",\n\"chalk\": \"^2.4.2\",\n\"chokidar\": \"^2.0.4\",\n\"debug\": \"^4.1.1\",\n+ \"dependency-graph\": \"^0.8.0\",\n\"dependency-tree\": \"^6.3.0\",\n\"ejs\": \"^2.6.1\",\n\"fast-glob\": \"^2.2.6\",\n" }, { "change_type": "MODIFY", "old_path": "src/Plugins/Pagination.js", "new_path": "src/Plugins/Pagination.js", "diff": "const lodashChunk = require(\"lodash/chunk\");\nconst lodashGet = require(\"lodash/get\");\nconst lodashSet = require(\"lodash/set\");\n+const EleventyBaseError = require(\"../EleventyBaseError\");\nconst config = require(\"../Config\");\n+class PaginationError extends EleventyBaseError {}\n+\nclass Pagination {\nconstructor(data) {\nthis.config = config.getConfig();\n@@ -21,6 +24,20 @@ class Pagination {\nreturn Pagination.hasPagination(this.data);\n}\n+ circularReferenceCheck(data) {\n+ let key = data.pagination.data;\n+ let tags = data.tags || [];\n+ for (let tag of tags) {\n+ if (`collections.${tag}` === key) {\n+ throw new PaginationError(\n+ `Pagination circular reference${\n+ this.template ? ` on ${this.template.inputPath}` : \"\"\n+ }, data:\\`${key}\\` iterates over both the \\`${tag}\\` tag and also supplies pages to that tag.`\n+ );\n+ }\n+ }\n+ }\n+\nsetData(data) {\nthis.data = data || {};\nthis.target = [];\n@@ -36,6 +53,7 @@ class Pagination {\n} else if (!(\"size\" in data.pagination)) {\nthrow new Error(\"Missing pagination size in front matter data.\");\n}\n+ this.circularReferenceCheck(data);\nthis.size = data.pagination.size;\nthis.alias = data.pagination.alias;\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateMap.js", "new_path": "src/TemplateMap.js", "diff": "const isPlainObject = require(\"lodash/isPlainObject\");\n+const DependencyGraph = require(\"dependency-graph\").DepGraph;\nconst TemplateCollection = require(\"./TemplateCollection\");\nconst eleventyConfig = require(\"./EleventyConfig\");\nconst debug = require(\"debug\")(\"Eleventy:TemplateMap\");\n@@ -7,7 +8,7 @@ const debugDev = require(\"debug\")(\"Dev:Eleventy:TemplateMap\");\nclass TemplateMap {\nconstructor() {\nthis.map = [];\n- this.collection = new TemplateCollection();\n+ this.graph = new DependencyGraph();\nthis.collectionsData = null;\nthis.cached = false;\nthis.configCollections = null;\n@@ -16,7 +17,6 @@ class TemplateMap {\nasync add(template) {\nfor (let map of await template.getMappedTemplates()) {\nthis.map.push(map);\n- this.collection.add(map);\n}\n}\n@@ -24,8 +24,56 @@ class TemplateMap {\nreturn this.map;\n}\n- getCollection() {\n- return this.collection;\n+ get collection() {\n+ if (!this._collection) {\n+ this._collection = new TemplateCollection();\n+ }\n+ return this._collection;\n+ }\n+\n+ getMappedDependencies() {\n+ let graph = new DependencyGraph();\n+ let tagPrefix = \"___TAG___\";\n+\n+ graph.addNode(tagPrefix + \"all\");\n+\n+ // Add tags in data\n+ for (let entry of this.map) {\n+ graph.addNode(entry.inputPath);\n+ if (entry.data.tags) {\n+ for (let tag of entry.data.tags) {\n+ graph.addNode(tagPrefix + tag);\n+ }\n+ }\n+ }\n+\n+ // Add tags from named user config collections\n+ for (let tag of this.getUserConfigCollectionNames()) {\n+ graph.addNode(tagPrefix + tag);\n+ }\n+\n+ for (let entry of this.map) {\n+ // collections.all\n+ graph.addDependency(tagPrefix + \"all\", entry.inputPath);\n+\n+ // collections.tagName\n+ if (entry.data.tags) {\n+ for (let tag of entry.data.tags) {\n+ graph.addDependency(tagPrefix + tag, entry.inputPath);\n+ }\n+ }\n+\n+ // Pagination data\n+ // TODO add support for declarative dependencies in front matter (similar to pagination above)\n+ if (entry.data.pagination && entry.data.pagination.data) {\n+ if (entry.data.pagination.data.startsWith(\"collections.\")) {\n+ let tag = entry.data.pagination.data.substr(\"collections.\".length);\n+ graph.addDependency(entry.inputPath, tagPrefix + tag);\n+ }\n+ }\n+ }\n+\n+ return graph.overallOrder();\n}\nasync cache() {\n@@ -36,35 +84,44 @@ class TemplateMap {\nentry.data.collections = this.collectionsData;\n}\n- this.taggedCollectionsData = await this.getTaggedCollectionsData();\n- Object.assign(this.collectionsData, this.taggedCollectionsData);\n-\n- // see .isSafe for definition of safe versus unsafe\n- await this.getSafeTemplatePages();\n- await this.populateUrlDataInMapSafe();\n- // TODO all tests pass when this is commented out (repeated below)\n- // Is this missing a test? Making a user config collection using `outputPath` or `url`?\n- await this.populateCollectionsWithOutputPaths(this.collectionsData);\n-\n- this.userConfigCollectionsData = await this.getUserConfigCollectionsData();\n- Object.assign(this.collectionsData, this.userConfigCollectionsData);\n+ // console.log( \">>> START\" );\n+ let dependencyMap = this.getMappedDependencies();\n+ let tagPrefix = \"___TAG___\";\n+ for (let depEntry of dependencyMap) {\n+ if (depEntry.startsWith(tagPrefix)) {\n+ let tagName = depEntry.substr(tagPrefix.length);\n+ if (this.isUserConfigCollectionName(tagName)) {\n+ // async\n+ // console.log( \"user config collection for\", tagName );\n+ this.collectionsData[tagName] = await this.getUserConfigCollection(\n+ tagName\n+ );\n+ } else {\n+ // console.log( \"tagged collection for \", tagName );\n+ this.collectionsData[tagName] = this.getTaggedCollection(tagName);\n+ }\n+ } else {\n+ // console.log( depEntry, \"Input file\" );\n+ this.collection.add(this._getMapEntryForInputPath(depEntry));\n+ await this._getTemplatePagesForInputPath(depEntry);\n+ await this._populateUrlDataInMapForInputPath(depEntry);\n+ }\n+ }\n- await this.getUnsafeTemplatePages();\n- await this.populateUrlDataInMapUnsafe();\n+ // TODO running this once at the end might be a problem\n+ // if user config collections needs outputPaths\nawait this.populateCollectionsWithOutputPaths(this.collectionsData);\n+ // console.log( \">>> END\" );\nawait this.populateContentDataInMap();\nthis.populateCollectionsWithContent();\nthis.cached = true;\n}\n- _testGetMapEntryForPath(inputPath, pageIndex = 0) {\n+ _testGetMapEntryForPath(inputPath) {\nfor (let j = 0, k = this.map.length; j < k; j++) {\n// inputPath should be unique (even with pagination?)\n- if (\n- this.map[j].inputPath === inputPath &&\n- this.map[j].pageIndex === pageIndex\n- ) {\n+ if (this.map[j].inputPath === inputPath) {\nreturn this.map[j];\n}\n}\n@@ -72,13 +129,9 @@ class TemplateMap {\ngetMapTemplateIndex(item) {\nlet inputPath = item.inputPath;\n- let pageIndex = item.pageIndex || 0;\nfor (let j = 0, k = this.map.length; j < k; j++) {\n// inputPath should be unique (even with pagination?)\n- if (\n- this.map[j].inputPath === inputPath &&\n- this.map[j].pageIndex === pageIndex\n- ) {\n+ if (this.map[j].inputPath === inputPath) {\nreturn j;\n}\n}\n@@ -86,55 +139,25 @@ class TemplateMap {\nreturn -1;\n}\n- isPaginationUsingUserConfigCollection(entry) {\n- if (!(\"pagination\" in entry.data) || !(\"data\" in entry.data.pagination)) {\n- return false;\n- }\n-\n- let target = entry.data.pagination.data;\n- let collectionNames = this.getUserConfigCollectionNames();\n- for (let name of collectionNames) {\n- if (`collections.${name}` === target.trim()) {\n- return true;\n- }\n- }\n- return false;\n- }\n-\n- // safe templates are paginated templates targeting a user configured collection\n- isSafe(entry) {\n- if (!(\"pagination\" in entry.data)) {\n- return true;\n+ _getMapEntryForInputPath(inputPath) {\n+ for (let map of this.map) {\n+ if (map.inputPath === inputPath) {\n+ return map;\n}\n- if (!this.isPaginationUsingUserConfigCollection(entry)) {\n- return true;\n}\n- return false;\n}\n- async getSafeTemplatePages() {\n- return this._getTemplatePages(true);\n- }\n- async getUnsafeTemplatePages() {\n- return this._getTemplatePages(false);\n- }\n- async _getTemplatePages(safeTemplatesOnly) {\n+ async _getTemplatePagesForInputPath(inputPath) {\nfor (let map of this.map) {\n- if (!safeTemplatesOnly || this.isSafe(map)) {\n+ if (map.inputPath === inputPath) {\nmap._pages = await map.template.getTemplates(map.data);\n}\n}\n}\n- async populateUrlDataInMapSafe() {\n- return this._populateUrlDataInMap(true);\n- }\n- async populateUrlDataInMapUnsafe() {\n- return this._populateUrlDataInMap(false);\n- }\n- async _populateUrlDataInMap(safeTemplatesOnly) {\n+ async _populateUrlDataInMapForInputPath(inputPath) {\nfor (let map of this.map) {\n- if ((!safeTemplatesOnly || this.isSafe(map)) && map._pages) {\n+ if (map.inputPath === inputPath && map._pages) {\nObject.assign(\nmap,\nawait map.template.getSecondaryMapEntry(map._pages[0])\n@@ -173,7 +196,19 @@ class TemplateMap {\nreturn Object.keys(allTags);\n}\n- async getTaggedCollectionsData() {\n+ getTaggedCollection(tag) {\n+ let result;\n+ if (!tag || tag === \"all\") {\n+ result = this.collection.getAllSorted();\n+ } else {\n+ result = this.collection.getFilteredByTag(tag);\n+ }\n+ debug(`Collection: collections.${tag || \"all\"} size: ${result.length}`);\n+\n+ return result;\n+ }\n+\n+ async _testGetTaggedCollectionsData() {\nlet collections = {};\ncollections.all = this.collection.getAllSorted();\ndebug(`Collection: collections.all size: ${collections.all.length}`);\n@@ -190,13 +225,28 @@ class TemplateMap {\nreturn (this.configCollections = configCollections);\n}\n+ isUserConfigCollectionName(name) {\n+ let collections = this.configCollections || eleventyConfig.getCollections();\n+ return !!collections[name];\n+ }\n+\ngetUserConfigCollectionNames() {\nreturn Object.keys(\nthis.configCollections || eleventyConfig.getCollections()\n);\n}\n- async getUserConfigCollectionsData() {\n+ async getUserConfigCollection(name) {\n+ let configCollections =\n+ this.configCollections || eleventyConfig.getCollections();\n+ // CHANGE this works with async now\n+ let result = await configCollections[name](this.collection);\n+\n+ debug(`Collection: collections.${name} size: ${result.length}`);\n+ return result;\n+ }\n+\n+ async _testGetUserConfigCollectionsData() {\nlet collections = {};\nlet configCollections =\nthis.configCollections || eleventyConfig.getCollections();\n@@ -214,10 +264,10 @@ class TemplateMap {\nasync _testGetAllCollectionsData() {\nlet collections = {};\n- let taggedCollections = await this.getTaggedCollectionsData();\n+ let taggedCollections = await this._testGetTaggedCollectionsData();\nObject.assign(collections, taggedCollections);\n- let userConfigCollections = await this.getUserConfigCollectionsData();\n+ let userConfigCollections = await this._testGetUserConfigCollectionsData();\nObject.assign(collections, userConfigCollections);\nreturn collections;\n" }, { "change_type": "MODIFY", "old_path": "test/PaginationTest.js", "new_path": "test/PaginationTest.js", "diff": "@@ -624,3 +624,34 @@ test(\"Paginate data in frontmatter (reversed)\", async t => {\n\"<ol><li>item4</li><li>item3</li><li>item2</li><li>item1</li></ol>\"\n);\n});\n+\n+test(\"No circular dependency (does not throw)\", t => {\n+ new Pagination({\n+ collections: {\n+ tag1: []\n+ },\n+ pagination: {\n+ data: \"collections.tag1\",\n+ size: 1\n+ },\n+ tags: [\"tag2\"]\n+ });\n+\n+ t.true(true);\n+});\n+\n+test(\"Circular dependency (pagination iterates over tag1 but also supplies pages to tag1)\", t => {\n+ t.throws(() => {\n+ new Pagination({\n+ collections: {\n+ tag1: [],\n+ tag2: []\n+ },\n+ pagination: {\n+ data: \"collections.tag1\",\n+ size: 1\n+ },\n+ tags: [\"tag1\"]\n+ });\n+ });\n+});\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateMapTest.js", "new_path": "test/TemplateMapTest.js", "diff": "@@ -24,9 +24,10 @@ test(\"TemplateMap has collections added\", async t => {\nlet tm = new TemplateMap();\nawait tm.add(tmpl1);\nawait tm.add(tmpl2);\n+ await tm.cache();\nt.is(tm.getMap().length, 2);\n- t.is(tm.getCollection().getAll().length, 2);\n+ t.is(tm.collection.getAll().length, 2);\n});\ntest(\"TemplateMap compared to Collection API\", async t => {\n@@ -619,7 +620,7 @@ test(\"getUserConfigCollectionNames\", async t => {\n]);\n});\n-test(\"isPaginationUsingUserConfigCollection\", async t => {\n+test(\"isUserConfigCollectionName\", t => {\nlet tm = new TemplateMap();\ntm.setUserConfigCollections({\nuserCollection: function(collection) {\n@@ -627,45 +628,6 @@ test(\"isPaginationUsingUserConfigCollection\", async t => {\n}\n});\n- t.is(\n- tm.isPaginationUsingUserConfigCollection({\n- data: {\n- pagination: {\n- data: \"collections.dog\"\n- }\n- }\n- }),\n- false\n- );\n-\n- t.is(\n- tm.isPaginationUsingUserConfigCollection({\n- data: {\n- pagination: {\n- data: \"collections.userCollection\"\n- }\n- }\n- }),\n- true\n- );\n-});\n-\n-test(\"isSafe\", async t => {\n- let tm = new TemplateMap();\n- tm.setUserConfigCollections({\n- userCollection: function(collection) {\n- return collection.getAll();\n- }\n- });\n-\n- t.is(tm.isSafe({ data: { pagination: {} } }), true);\n- t.is(\n- tm.isSafe({ data: { pagination: { data: \"collections.unlisted\" } } }),\n- true\n- );\n- t.is(\n- tm.isSafe({ data: { pagination: { data: \"collections.userCollection\" } } }),\n- false\n- );\n- t.is(tm.isSafe({ data: {} }), true);\n+ t.is(tm.isUserConfigCollectionName(\"userCollection\"), true);\n+ t.is(tm.isUserConfigCollectionName(\"userCollection2\"), false);\n});\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateWriterTest.js", "new_path": "test/TemplateWriterTest.js", "diff": "@@ -177,7 +177,6 @@ test(\"Pagination with a Collection\", async t => {\nlet paths = await tw._getAllPaths();\nlet templateMap = await tw._createTemplateMap(paths);\n- await templateMap.cache();\nlet collectionsData = await templateMap.getCollectionsData();\nt.is(collectionsData.tag1.length, 3);\n@@ -224,7 +223,6 @@ test(\"Use a collection inside of a template\", async t => {\nlet paths = await tw._getAllPaths();\nlet templateMap = await tw._createTemplateMap(paths);\n- await templateMap.cache();\nlet collectionsData = await templateMap.getCollectionsData();\nt.is(collectionsData.dog.length, 1);\n@@ -267,7 +265,6 @@ test(\"Use a collection inside of a layout\", async t => {\nlet paths = await tw._getAllPaths();\nlet templateMap = await tw._createTemplateMap(paths);\n- await templateMap.cache();\nlet collectionsData = await templateMap.getCollectionsData();\nt.is(collectionsData.dog.length, 1);\n@@ -399,7 +396,6 @@ test(\"fileSlug should exist in a collection\", async t => {\nlet paths = await tw._getAllPaths();\nlet templateMap = await tw._createTemplateMap(paths);\n- await templateMap.cache();\nlet collectionsData = await templateMap.getCollectionsData();\nt.is(collectionsData.dog.length, 1);\n@@ -424,7 +420,6 @@ test.skip(\"renderData should exist and be resolved in a collection (Issue #289)\"\nlet paths = await tw._getAllPaths();\nlet templateMap = await tw._createTemplateMap(paths);\n- await templateMap.cache();\nlet collectionsData = await templateMap.getCollectionsData();\nt.is(collectionsData.dog.length, 1);\n" } ]
JavaScript
MIT License
11ty/eleventy
Back to working tests with refactored code.
699
10.02.2019 11:16:59
21,600
20eabbd633617e68459b65a2a2d891b473366d94
Fixes but needs opt-in
[ { "change_type": "MODIFY", "old_path": "src/Template.js", "new_path": "src/Template.js", "diff": "@@ -596,6 +596,7 @@ class Template extends TemplateContent {\n}\n}\n+ // TODO get rid of this or simplify it, this is a placeholder for getTemplates() entries\nasync getInitialMapEntries() {\nlet data = await this.getData();\nlet entries = [];\n@@ -610,12 +611,12 @@ class Template extends TemplateContent {\nreturn entries;\n}\n- async getSecondaryMapEntry(page) {\n- return {\n- url: page.url,\n- outputPath: page.outputPath\n- };\n- }\n+ // async getSecondaryMapEntry(page) {\n+ // return {\n+ // url: page.url,\n+ // outputPath: page.outputPath\n+ // };\n+ // }\nasync getTertiaryMapEntry(page) {\nthis.setWrapWithLayouts(false);\n@@ -630,6 +631,7 @@ class Template extends TemplateContent {\nreturn mapEntry;\n}\n+ // TODO get rid of this\nasync getMappedTemplates() {\ndebugDev(\"%o getMapped()\", this.inputPath);\nreturn await this.getInitialMapEntries();\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateMap.js", "new_path": "src/TemplateMap.js", "diff": "@@ -102,15 +102,26 @@ class TemplateMap {\n}\n} else {\n// console.log( depEntry, \"Input file\" );\n- this.collection.add(this._getMapEntryForInputPath(depEntry));\n- await this._getTemplatePagesForInputPath(depEntry);\n- await this._populateUrlDataInMapForInputPath(depEntry);\n+ let map = this._getMapEntryForInputPath(depEntry);\n+ map._pages = await map.template.getTemplates(map.data);\n+\n+ for (let page of map._pages) {\n+ // do we need these in map entries?\n+ if (!map.outputPath) {\n+ map.outputPath = page.outputPath;\n+ }\n+ if (!map.url) {\n+ map.url = page.url;\n+ }\n+\n+ this.collection.add(page);\n+ }\n}\n}\n// TODO running this once at the end might be a problem\n// if user config collections needs outputPaths\n- await this.populateCollectionsWithOutputPaths(this.collectionsData);\n+ // await this.populateCollectionsWithOutputPaths(this.collectionsData);\n// console.log( \">>> END\" );\nawait this.populateContentDataInMap();\n@@ -128,10 +139,10 @@ class TemplateMap {\n}\ngetMapTemplateIndex(item) {\n- let inputPath = item.inputPath;\nfor (let j = 0, k = this.map.length; j < k; j++) {\n// inputPath should be unique (even with pagination?)\n- if (this.map[j].inputPath === inputPath) {\n+ //&& (item.pageNumber === undefined || this.map[j].pageNumber === item.pageNumber)\n+ if (this.map[j].inputPath === item.inputPath) {\nreturn j;\n}\n}\n@@ -147,25 +158,6 @@ class TemplateMap {\n}\n}\n- async _getTemplatePagesForInputPath(inputPath) {\n- for (let map of this.map) {\n- if (map.inputPath === inputPath) {\n- map._pages = await map.template.getTemplates(map.data);\n- }\n- }\n- }\n-\n- async _populateUrlDataInMapForInputPath(inputPath) {\n- for (let map of this.map) {\n- if (map.inputPath === inputPath && map._pages) {\n- Object.assign(\n- map,\n- await map.template.getSecondaryMapEntry(map._pages[0])\n- );\n- }\n- }\n- }\n-\nasync populateContentDataInMap() {\nfor (let map of this.map) {\nif (map._pages) {\n@@ -273,25 +265,25 @@ class TemplateMap {\nreturn collections;\n}\n- populateCollectionsWithOutputPaths(collections) {\n- for (let collectionName in collections) {\n- if (!Array.isArray(this.collectionsData[collectionName])) {\n- continue;\n- }\n-\n- for (let item of collections[collectionName]) {\n- if (!isPlainObject(item) || !(\"inputPath\" in item)) {\n- continue;\n- }\n-\n- let index = this.getMapTemplateIndex(item);\n- if (index !== -1) {\n- item.outputPath = this.map[index].outputPath;\n- item.url = this.map[index].url;\n- }\n- }\n- }\n- }\n+ // populateCollectionsWithOutputPaths(collections) {\n+ // for (let collectionName in collections) {\n+ // if (!Array.isArray(this.collectionsData[collectionName])) {\n+ // continue;\n+ // }\n+\n+ // for (let item of collections[collectionName]) {\n+ // if (!isPlainObject(item) || !(\"inputPath\" in item)) {\n+ // continue;\n+ // }\n+\n+ // let index = this.getMapTemplateIndex(item);\n+ // if (index !== -1) {\n+ // item.outputPath = this.map[index].outputPath;\n+ // item.url = this.map[index].url;\n+ // }\n+ // }\n+ // }\n+ // }\npopulateCollectionsWithContent() {\nfor (let collectionName in this.collectionsData) {\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateWriterTest.js", "new_path": "test/TemplateWriterTest.js", "diff": "@@ -180,7 +180,7 @@ test(\"Pagination with a Collection\", async t => {\nlet collectionsData = await templateMap.getCollectionsData();\nt.is(collectionsData.tag1.length, 3);\n- t.is(collectionsData.pagingtag.length, 1);\n+ t.is(collectionsData.pagingtag.length, 2);\nlet mapEntry = templateMap._testGetMapEntryForPath(\n\"./test/stubs/paged/collection/main.njk\"\n" }, { "change_type": "MODIFY", "old_path": "test/stubs/templateMapCollection/paged-tag-dogs-templateContent.md", "new_path": "test/stubs/templateMapCollection/paged-tag-dogs-templateContent.md", "diff": "@@ -6,7 +6,7 @@ pagination:\n---\nBefore\n-{% for dog in collections.dog %}\n+{% for dog in pagination.items %}\n{{ dog.templateContent }}\n{% endfor %}\nAfter\n" } ]
JavaScript
MIT License
11ty/eleventy
Fixes #253 but needs opt-in
699
10.02.2019 22:07:54
21,600
704d0cb7077eb662a3d475ffbe8793d7a748b90b
Adds opt-in for
[ { "change_type": "MODIFY", "old_path": "src/TemplateMap.js", "new_path": "src/TemplateMap.js", "diff": "@@ -104,7 +104,7 @@ class TemplateMap {\n// console.log( depEntry, \"Input file\" );\nlet map = this._getMapEntryForInputPath(depEntry);\nmap._pages = await map.template.getTemplates(map.data);\n-\n+ let counter = 0;\nfor (let page of map._pages) {\n// do we need these in map entries?\nif (!map.outputPath) {\n@@ -113,9 +113,15 @@ class TemplateMap {\nif (!map.url) {\nmap.url = page.url;\n}\n-\n+ if (\n+ counter === 0 ||\n+ (map.data.pagination &&\n+ map.data.pagination.addAllPagesToCollections)\n+ ) {\nthis.collection.add(page);\n}\n+ counter++;\n+ }\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateMapTest.js", "new_path": "test/TemplateMapTest.js", "diff": "@@ -467,9 +467,43 @@ test(\"Should be able to paginate a user config collection (paged template is als\nt.is(collections.dog.length, 2);\nt.truthy(collections.haha);\n- t.is(collections.haha.length, 2);\n+ t.is(collections.haha.length, 1);\nt.is(collections.haha[0].url, \"/templateMapCollection/paged-cfg-tagged/\");\n- t.is(collections.haha[1].url, \"/templateMapCollection/paged-cfg-tagged/1/\");\n+});\n+\n+test(\"Should be able to paginate a user config collection (paged template is also tagged, add all pages to collections)\", async t => {\n+ let tm = new TemplateMap();\n+ await tm.add(tmpl1); // has dog tag\n+ await tm.add(tmpl2); // does not have dog tag\n+ await tm.add(tmpl4); // has dog tag\n+\n+ let pagedTmpl = new Template(\n+ \"./test/stubs/templateMapCollection/paged-cfg-tagged-apply-to-all.md\",\n+ \"./test/stubs/\",\n+ \"./test/stubs/_site\"\n+ );\n+ await tm.add(pagedTmpl);\n+\n+ tm.setUserConfigCollections({\n+ userCollection: function(collection) {\n+ let all = collection.getFilteredByTag(\"dog\");\n+ return all;\n+ }\n+ });\n+\n+ let collections = await tm.getCollectionsData();\n+ t.is(collections.dog.length, 2);\n+\n+ t.truthy(collections.haha);\n+ t.is(collections.haha.length, 2);\n+ t.is(\n+ collections.haha[0].url,\n+ \"/templateMapCollection/paged-cfg-tagged-apply-to-all/\"\n+ );\n+ t.is(\n+ collections.haha[1].url,\n+ \"/templateMapCollection/paged-cfg-tagged-apply-to-all/1/\"\n+ );\n});\ntest(\"Should be able to paginate a user config collection (paged template is also tagged, uses custom rendered permalink)\", async t => {\n@@ -492,6 +526,32 @@ test(\"Should be able to paginate a user config collection (paged template is als\n}\n});\n+ let collections = await tm.getCollectionsData();\n+ t.truthy(collections.haha);\n+ t.is(collections.haha.length, 1);\n+ t.is(collections.haha[0].url, \"/test-title/goodbye/\");\n+});\n+\n+test(\"Should be able to paginate a user config collection (paged template is also tagged, uses custom rendered permalink, add all pages to collections)\", async t => {\n+ let tm = new TemplateMap();\n+ await tm.add(tmpl1); // has dog tag\n+ await tm.add(tmpl2); // does not have dog tag\n+ await tm.add(tmpl4); // has dog tag\n+\n+ let pagedTmpl = new Template(\n+ \"./test/stubs/templateMapCollection/paged-cfg-tagged-permalink-apply-to-all.md\",\n+ \"./test/stubs/\",\n+ \"./test/stubs/_site\"\n+ );\n+ await tm.add(pagedTmpl);\n+\n+ tm.setUserConfigCollections({\n+ userCollection: function(collection) {\n+ let all = collection.getFilteredByTag(\"dog\");\n+ return all;\n+ }\n+ });\n+\nlet collections = await tm.getCollectionsData();\nt.truthy(collections.haha);\nt.is(collections.haha.length, 2);\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateWriterTest.js", "new_path": "test/TemplateWriterTest.js", "diff": "@@ -180,7 +180,7 @@ test(\"Pagination with a Collection\", async t => {\nlet collectionsData = await templateMap.getCollectionsData();\nt.is(collectionsData.tag1.length, 3);\n- t.is(collectionsData.pagingtag.length, 2);\n+ t.is(collectionsData.pagingtag.length, 1);\nlet mapEntry = templateMap._testGetMapEntryForPath(\n\"./test/stubs/paged/collection/main.njk\"\n@@ -214,6 +214,57 @@ test(\"Pagination with a Collection\", async t => {\nt.is(templates[1].templateContent.trim(), \"<ol><li>/test3/</li></ol>\");\n});\n+test(\"Pagination with a Collection (apply all pages to collections)\", async t => {\n+ let tw = new TemplateWriter(\n+ \"./test/stubs/paged/collection-apply-to-all\",\n+ \"./test/stubs/_site\",\n+ [\"njk\"]\n+ );\n+\n+ let paths = await tw._getAllPaths();\n+ let templateMap = await tw._createTemplateMap(paths);\n+\n+ let collectionsData = await templateMap.getCollectionsData();\n+ t.is(collectionsData.tag1.length, 3);\n+ t.is(collectionsData.pagingtag.length, 2);\n+\n+ let mapEntry = templateMap._testGetMapEntryForPath(\n+ \"./test/stubs/paged/collection-apply-to-all/main.njk\"\n+ );\n+ t.truthy(mapEntry);\n+ t.is(\n+ mapEntry.inputPath,\n+ \"./test/stubs/paged/collection-apply-to-all/main.njk\"\n+ );\n+\n+ let mainTmpl = tw._createTemplate(\n+ \"./test/stubs/paged/collection-apply-to-all/main.njk\"\n+ );\n+ let outputPath = await mainTmpl.getOutputPath();\n+ t.is(outputPath, \"./test/stubs/_site/main/index.html\");\n+ t.is(mapEntry.outputPath, \"./test/stubs/_site/main/index.html\");\n+\n+ let templates = await mapEntry.template.getRenderedTemplates(mapEntry.data);\n+ t.is(templates.length, 2);\n+ t.is(\n+ await templates[0].template.getOutputPath(),\n+ \"./test/stubs/_site/main/index.html\"\n+ );\n+ t.is(templates[0].outputPath, \"./test/stubs/_site/main/index.html\");\n+ t.is(\n+ await templates[1].template.getOutputPath(),\n+ \"./test/stubs/_site/main/1/index.html\"\n+ );\n+ t.is(templates[1].outputPath, \"./test/stubs/_site/main/1/index.html\");\n+\n+ // test content\n+ t.is(\n+ templates[0].templateContent.trim(),\n+ \"<ol><li>/test1/</li><li>/test2/</li></ol>\"\n+ );\n+ t.is(templates[1].templateContent.trim(), \"<ol><li>/test3/</li></ol>\");\n+});\n+\ntest(\"Use a collection inside of a template\", async t => {\nlet tw = new TemplateWriter(\n\"./test/stubs/collection-template\",\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/paged/collection-apply-to-all/consumer.njk", "diff": "+{% for item in collections.pagingtag %}{{ item.templateContent | safe }}{% endfor %}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/paged/collection-apply-to-all/main.njk", "diff": "+---\n+pagination:\n+ data: collections.tag1\n+ size: 2\n+ addAllPagesToCollections: true\n+tags:\n+ - pagingtag\n+---\n+<ol>{% for item in pagination.items %}<li>{{ item.url }}</li>{% endfor %}</ol>\n\\ No newline at end of file\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/paged/collection-apply-to-all/test1.njk", "diff": "+---\n+title: Testing 1\n+tags:\n+ - tag1\n+---\n+{{ title }}\n\\ No newline at end of file\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/paged/collection-apply-to-all/test2.njk", "diff": "+---\n+title: Testing 2\n+tags:\n+ - tag1\n+---\n+{{ title }}\n\\ No newline at end of file\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/paged/collection-apply-to-all/test3.njk", "diff": "+---\n+title: Testing 3\n+tags:\n+ - tag1\n+---\n+{{ title }}\n\\ No newline at end of file\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/templateMapCollection/paged-cfg-tagged-apply-to-all.md", "diff": "+---\n+title: Paged Test\n+tags:\n+ - haha\n+pagination:\n+ data: collections.userCollection\n+ size: 1\n+ alias: item\n+ addAllPagesToCollections: true\n+---\n+\n+# {{ title }}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/templateMapCollection/paged-cfg-tagged-permalink-apply-to-all.md", "diff": "+---\n+title: Paged Test\n+tags:\n+ - haha\n+pagination:\n+ data: collections.userCollection\n+ size: 1\n+ alias: item\n+ addAllPagesToCollections: true\n+permalink: /{{ item.data.title | slug}}/goodbye/\n+---\n+\n+# {{ title }}\n" } ]
JavaScript
MIT License
11ty/eleventy
Adds opt-in for #253.
699
10.02.2019 22:37:24
21,600
0d060e4b8f753ef39f0dd07920b7b363f4851e6a
Fix for string tags
[ { "change_type": "MODIFY", "old_path": "src/TemplateMap.js", "new_path": "src/TemplateMap.js", "diff": "@@ -41,7 +41,11 @@ class TemplateMap {\nfor (let entry of this.map) {\ngraph.addNode(entry.inputPath);\nif (entry.data.tags) {\n- for (let tag of entry.data.tags) {\n+ let tags = entry.data.tags;\n+ if (typeof entry.data.tags === \"string\") {\n+ tags = [entry.data.tags];\n+ }\n+ for (let tag of tags) {\ngraph.addNode(tagPrefix + tag);\n}\n}\n@@ -58,7 +62,11 @@ class TemplateMap {\n// collections.tagName\nif (entry.data.tags) {\n- for (let tag of entry.data.tags) {\n+ let tags = entry.data.tags;\n+ if (typeof entry.data.tags === \"string\") {\n+ tags = [entry.data.tags];\n+ }\n+ for (let tag of tags) {\ngraph.addDependency(tagPrefix + tag, entry.inputPath);\n}\n}\n" } ]
JavaScript
MIT License
11ty/eleventy
Fix for string tags #253
699
11.02.2019 09:05:13
21,600
a2cc3b9cd6b27ce13e00a08301fc6e8f165be5df
Unskip a test.
[ { "change_type": "MODIFY", "old_path": "test/TemplateMapTest.js", "new_path": "test/TemplateMapTest.js", "diff": "@@ -19,6 +19,11 @@ let tmpl4 = new Template(\n\"./test/stubs/\",\n\"./test/stubs/_site\"\n);\n+let tmpl5 = new Template(\n+ \"./test/stubs/templateMapCollection/test5.md\",\n+ \"./test/stubs/\",\n+ \"./test/stubs/_site\"\n+);\ntest(\"TemplateMap has collections added\", async t => {\nlet tm = new TemplateMap();\n@@ -649,7 +654,7 @@ test(\"Should be able to paginate a tag generated collection when aliased (and it\n);\n});\n-test.skip(\"Issue #253: Paginated template with a tag should put multiple pages into a collection\", async t => {\n+test(\"Issue #253: Paginated template with a tag should put multiple pages into a collection\", async t => {\nlet tm = new TemplateMap();\nawait tm.add(tmpl1);\nawait tm.add(tmpl2);\n@@ -708,3 +713,14 @@ test(\"isUserConfigCollectionName\", t => {\nt.is(tm.isUserConfigCollectionName(\"userCollection\"), true);\nt.is(tm.isUserConfigCollectionName(\"userCollection2\"), false);\n});\n+\n+test(\"Mapped Dependencies should have nodes that have no dependencies and no dependents\", async t => {\n+ let tm = new TemplateMap();\n+ await tm.add(tmpl1);\n+ await tm.add(tmpl5);\n+\n+ await tm.cache();\n+\n+ let deps = await tm.getMappedDependencies();\n+ t.true(deps.filter(dep => dep.indexOf(\"test5.md\") > -1).length > 0);\n+});\n" }, { "change_type": "MODIFY", "old_path": "test/stubs/tagged-pagination-multiples/test.njk", "new_path": "test/stubs/tagged-pagination-multiples/test.njk", "diff": "@@ -6,6 +6,7 @@ pagination:\ndata: collections.userCollection\nsize: 1\nalias: item\n+ addAllPagesToCollections: true\n---\n{{ title }}\n\\ No newline at end of file\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/templateMapCollection/test5.md", "diff": "+---\n+title: Test Title 5\n+---\n+\n+# Test 5\n" } ]
JavaScript
MIT License
11ty/eleventy
Unskip a test.
699
11.02.2019 21:45:57
21,600
fd869025b544df53ae8f97d5d31659df6ccfe4f6
Better for normalizes "string" tags to array in more places. Fixes `templateContent` missing in a few places.
[ { "change_type": "MODIFY", "old_path": "src/Template.js", "new_path": "src/Template.js", "diff": "@@ -409,6 +409,7 @@ class Template extends TemplateContent {\nthis.paging = new Pagination(data);\nthis.paging.setTemplate(this);\nlet templates = await this.paging.getPageTemplates();\n+ let pageNumber = 0;\nfor (let page of templates) {\nlet pageData = await page.getRenderedData();\n@@ -425,6 +426,7 @@ class Template extends TemplateContent {\nfileSlug: this.fileSlugStr,\ndata: pageData,\ndate: data.page.date,\n+ pageNumber: pageNumber++,\noutputPath: await page.getOutputPath(pageData),\nurl: await page.getOutputHref(pageData)\n});\n@@ -611,24 +613,12 @@ class Template extends TemplateContent {\nreturn entries;\n}\n- // async getSecondaryMapEntry(page) {\n- // return {\n- // url: page.url,\n- // outputPath: page.outputPath\n- // };\n- // }\n-\n- async getTertiaryMapEntry(page) {\n+ async getTemplateMapContent(page) {\nthis.setWrapWithLayouts(false);\n- let mapEntry = {\n- templateContent: await page.template._getContent(\n- page.outputPath,\n- page.data\n- )\n- };\n+ let content = await page.template._getContent(page.outputPath, page.data);\nthis.setWrapWithLayouts(true);\n- return mapEntry;\n+ return content;\n}\n// TODO get rid of this\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateCollection.js", "new_path": "src/TemplateCollection.js", "diff": "@@ -59,7 +59,7 @@ class TemplateCollection extends Sortable {\nmatch = true;\n}\n});\n- // This branch should no longer be necessary per TemplateContent.cleanupFrontMatterData\n+ // This branch should no longer be necessary per TemplateData.cleanupData\n} else if (typeof item.data.tags === \"string\") {\nmatch = item.data.tags === tagName;\n}\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateContent.js", "new_path": "src/TemplateContent.js", "diff": "@@ -101,14 +101,6 @@ class TemplateContent {\nreturn this.frontMatter.content;\n}\n- cleanupFrontMatterData(data) {\n- if (\"tags\" in data && typeof data.tags === \"string\") {\n- data.tags = [data.tags];\n- }\n-\n- return data;\n- }\n-\nasync getFrontMatterData() {\nif (!this.frontMatter) {\nawait this.read();\n@@ -116,7 +108,7 @@ class TemplateContent {\nlet extraData = await this.engine.getExtraDataFromFile(this.inputPath);\nlet data = TemplateData.mergeDeep({}, this.frontMatter.data, extraData);\n- return this.cleanupFrontMatterData(data);\n+ return TemplateData.cleanupData(data);\n}\nasync getEngineOverride() {\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateData.js", "new_path": "src/TemplateData.js", "diff": "@@ -32,6 +32,7 @@ class TemplateData {\n/* Used by tests */\n_setConfig(config) {\nthis.config = config;\n+ this.dataTemplateEngine = this.config.dataTemplateEngine;\n}\nsetInputDir(inputDir) {\n@@ -197,8 +198,10 @@ class TemplateData {\nlocalDataPaths = [localDataPaths];\n}\nfor (let path of localDataPaths) {\n+ // clean up data for template/directory data files only.\nlet dataForPath = await this.getDataValue(path, null, true);\n- TemplateData.mergeDeep(this.config, localData, dataForPath);\n+ let cleanedDataForPath = TemplateData.cleanupData(dataForPath);\n+ TemplateData.mergeDeep(this.config, localData, cleanedDataForPath);\n// debug(\"`combineLocalData` (iterating) for %o: %O\", path, localData);\n}\nreturn localData;\n@@ -333,6 +336,14 @@ class TemplateData {\nstatic merge(target, ...source) {\nreturn merge(target, ...source);\n}\n+\n+ static cleanupData(data) {\n+ if (\"tags\" in data && typeof data.tags === \"string\") {\n+ data.tags = [data.tags];\n+ }\n+\n+ return data;\n+ }\n}\nmodule.exports = TemplateData;\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateMap.js", "new_path": "src/TemplateMap.js", "diff": "@@ -42,9 +42,6 @@ class TemplateMap {\ngraph.addNode(entry.inputPath);\nif (entry.data.tags) {\nlet tags = entry.data.tags;\n- if (typeof entry.data.tags === \"string\") {\n- tags = [entry.data.tags];\n- }\nfor (let tag of tags) {\ngraph.addNode(tagPrefix + tag);\n}\n@@ -63,9 +60,6 @@ class TemplateMap {\n// collections.tagName\nif (entry.data.tags) {\nlet tags = entry.data.tags;\n- if (typeof entry.data.tags === \"string\") {\n- tags = [entry.data.tags];\n- }\nfor (let tag of tags) {\ngraph.addDependency(tagPrefix + tag, entry.inputPath);\n}\n@@ -114,7 +108,7 @@ class TemplateMap {\nmap._pages = await map.template.getTemplates(map.data);\nlet counter = 0;\nfor (let page of map._pages) {\n- // do we need these in map entries?\n+ // TODO do we need these in map entries?\nif (!map.outputPath) {\nmap.outputPath = page.outputPath;\n}\n@@ -152,18 +146,6 @@ class TemplateMap {\n}\n}\n- getMapTemplateIndex(item) {\n- for (let j = 0, k = this.map.length; j < k; j++) {\n- // inputPath should be unique (even with pagination?)\n- //&& (item.pageNumber === undefined || this.map[j].pageNumber === item.pageNumber)\n- if (this.map[j].inputPath === item.inputPath) {\n- return j;\n- }\n- }\n-\n- return -1;\n- }\n-\n_getMapEntryForInputPath(inputPath) {\nfor (let map of this.map) {\nif (map.inputPath === inputPath) {\n@@ -174,19 +156,22 @@ class TemplateMap {\nasync populateContentDataInMap() {\nfor (let map of this.map) {\n- if (map._pages) {\n- Object.assign(\n- map,\n- await map.template.getTertiaryMapEntry(map._pages[0])\n- );\n+ for (let page of map._pages) {\n+ let content = await map.template.getTemplateMapContent(page);\n+ page.templateContent = content;\n+\n+ // TODO Do we need this?\n+ if (!map.templateContent) {\n+ map.templateContent = content;\n+ }\n+ }\ndebugDev(\n\"Added this.map[...].templateContent, outputPath, et al for one map entry\"\n);\n}\n}\n- }\n- getAllTags() {\n+ _testGetAllTags() {\nlet allTags = {};\nfor (let map of this.map) {\nlet tags = map.data.tags;\n@@ -194,7 +179,7 @@ class TemplateMap {\nfor (let tag of tags) {\nallTags[tag] = true;\n}\n- // This branch should no longer be necessary per TemplateContent.cleanupFrontMatterData\n+ // This branch should no longer be necessary per TemplateData.cleanupData\n} else if (tags) {\nallTags[tags] = true;\n}\n@@ -219,7 +204,7 @@ class TemplateMap {\ncollections.all = this.collection.getAllSorted();\ndebug(`Collection: collections.all size: ${collections.all.length}`);\n- let tags = this.getAllTags();\n+ let tags = this._testGetAllTags();\nfor (let tag of tags) {\ncollections[tag] = this.collection.getFilteredByTag(tag);\ndebug(`Collection: collections.${tag} size: ${collections[tag].length}`);\n@@ -279,25 +264,13 @@ class TemplateMap {\nreturn collections;\n}\n- // populateCollectionsWithOutputPaths(collections) {\n- // for (let collectionName in collections) {\n- // if (!Array.isArray(this.collectionsData[collectionName])) {\n- // continue;\n- // }\n-\n- // for (let item of collections[collectionName]) {\n- // if (!isPlainObject(item) || !(\"inputPath\" in item)) {\n- // continue;\n- // }\n-\n- // let index = this.getMapTemplateIndex(item);\n- // if (index !== -1) {\n- // item.outputPath = this.map[index].outputPath;\n- // item.url = this.map[index].url;\n- // }\n- // }\n- // }\n- // }\n+ getMapEntryFromInputPath(inputPath) {\n+ for (let entry of this.map) {\n+ if (entry.inputPath === inputPath) {\n+ return entry;\n+ }\n+ }\n+ }\npopulateCollectionsWithContent() {\nfor (let collectionName in this.collectionsData) {\n@@ -310,10 +283,9 @@ class TemplateMap {\ncontinue;\n}\n- let index = this.getMapTemplateIndex(item);\n- if (index !== -1) {\n- item.templateContent = this.map[index].templateContent;\n- }\n+ let entry = this.getMapEntryFromInputPath(item.inputPath);\n+ let index = entry.pageNumber || 0;\n+ item.templateContent = entry._pages[index].templateContent;\n}\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateTest.js", "new_path": "test/TemplateTest.js", "diff": "@@ -1335,3 +1335,38 @@ test(\"Data Cascade Tag Merge (Shallow merge)\", async t => {\nlet data = await tmpl.getData();\nt.deepEqual(data.tags.sort(), [\"tagA\", \"tagB\"]);\n});\n+\n+test('Local data inherits tags string ([tags] vs \"tags\") Shallow Merge', async t => {\n+ let dataObj = new TemplateData(\"./test/stubs/\");\n+ await dataObj.cacheData();\n+\n+ let tmpl = new Template(\n+ \"./test/stubs/local-data-tags/component.njk\",\n+ \"./test/stubs/\",\n+ \"./dist\",\n+ dataObj\n+ );\n+\n+ let data = await tmpl.getData();\n+ t.deepEqual(data.tags.sort(), [\"tag1\", \"tag2\"]);\n+});\n+\n+test('Local data inherits tags string ([tags] vs \"tags\") Deep Merge', async t => {\n+ let newConfig = Object.assign({}, config);\n+ newConfig.dataDeepMerge = true;\n+\n+ let dataObj = new TemplateData(\"./test/stubs/\");\n+ dataObj._setConfig(newConfig);\n+ await dataObj.cacheData();\n+\n+ let tmpl = new Template(\n+ \"./test/stubs/local-data-tags/component.njk\",\n+ \"./test/stubs/\",\n+ \"./dist\",\n+ dataObj\n+ );\n+ tmpl.config = newConfig;\n+\n+ let data = await tmpl.getData();\n+ t.deepEqual(data.tags.sort(), [\"tag1\", \"tag2\", \"tag3\"]);\n+});\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateWriterTest.js", "new_path": "test/TemplateWriterTest.js", "diff": "@@ -78,14 +78,15 @@ test(\"getCollectionsData\", async t => {\nt.is(collectionsData.dog.length, 1);\n});\n-test(\"_getAllTags\", async t => {\n+// TODO remove this (used by other test things)\n+test(\"_testGetAllTags\", async t => {\nlet tw = new TemplateWriter(\"./test/stubs/collection\", \"./test/stubs/_site\", [\n\"md\"\n]);\nlet paths = await tw._getAllPaths();\nlet templateMap = await tw._createTemplateMap(paths);\n- let tags = templateMap.getAllTags();\n+ let tags = templateMap._testGetAllTags();\nt.deepEqual(tags.sort(), [\"cat\", \"dog\", \"post\"].sort());\n});\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/local-data-tags/component.11tydata.js", "diff": "+module.exports = {\n+ tags: \"tag3\"\n+};\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/local-data-tags/component.njk", "diff": "+---\n+tags:\n+ - tag1\n+ - tag2\n+---\n+{{localdatakey1}}\n\\ No newline at end of file\n" } ]
JavaScript
MIT License
11ty/eleventy
Better for #253, normalizes "string" tags to array in more places. Fixes `templateContent` missing in a few places.
699
13.02.2019 22:01:35
21,600
ff2a4337759645c0cde599cc5e428d3a7b372fbf
Better template maps with user collections, uses two-pass to work around circular graphs
[ { "change_type": "MODIFY", "old_path": "src/TemplateData.js", "new_path": "src/TemplateData.js", "diff": "@@ -339,7 +339,7 @@ class TemplateData {\nstatic cleanupData(data) {\nif (\"tags\" in data && typeof data.tags === \"string\") {\n- data.tags = [data.tags];\n+ data.tags = data.tags ? [data.tags] : [];\n}\nreturn data;\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateMap.js", "new_path": "src/TemplateMap.js", "diff": "@@ -31,63 +31,100 @@ class TemplateMap {\nreturn this._collection;\n}\n+ _getPaginationTagTarget(entry) {\n+ if (\n+ entry.data.pagination &&\n+ entry.data.pagination.data &&\n+ entry.data.pagination.data.startsWith(\"collections.\")\n+ ) {\n+ return entry.data.pagination.data.substr(\"collections.\".length);\n+ }\n+ }\n+\ngetMappedDependencies() {\nlet graph = new DependencyGraph();\nlet tagPrefix = \"___TAG___\";\ngraph.addNode(tagPrefix + \"all\");\n- // Add tags in data\nfor (let entry of this.map) {\n+ let paginationTagTarget = this._getPaginationTagTarget(entry);\n+ if (paginationTagTarget) {\n+ if (this.isUserConfigCollectionName(paginationTagTarget)) {\n+ continue;\n+ } else {\n+ // using pagination but over a tagged collection\n+ graph.addNode(entry.inputPath);\n+ if (!graph.hasNode(tagPrefix + paginationTagTarget)) {\n+ graph.addNode(tagPrefix + paginationTagTarget);\n+ }\n+ graph.addDependency(entry.inputPath, tagPrefix + paginationTagTarget);\n+ }\n+ } else {\n+ // not using pagination\ngraph.addNode(entry.inputPath);\n+ }\n+\n+ // collections.all\n+ graph.addDependency(tagPrefix + \"all\", entry.inputPath);\n+\nif (entry.data.tags) {\n- let tags = entry.data.tags;\n- for (let tag of tags) {\n+ for (let tag of entry.data.tags) {\n+ if (!graph.hasNode(tagPrefix + tag)) {\ngraph.addNode(tagPrefix + tag);\n}\n+ // collections.tagName\n+ // console.log( \"Dependency from\", tagPrefix + tag, \"to\", entry.inputPath );\n+ graph.addDependency(tagPrefix + tag, entry.inputPath);\n+ }\n}\n}\n+ return graph.overallOrder();\n+ }\n+\n+ getDelayedMappedDependencies() {\n+ let graph = new DependencyGraph();\n+ let tagPrefix = \"___TAG___\";\n+\n+ graph.addNode(tagPrefix + \"all\");\n+\n+ let userConfigCollections = this.getUserConfigCollectionNames();\n// Add tags from named user config collections\n- for (let tag of this.getUserConfigCollectionNames()) {\n+ for (let tag of userConfigCollections) {\ngraph.addNode(tagPrefix + tag);\n+ // graph.addDependency( tagPrefix + tag, tagPrefix + \"all\" );\n}\nfor (let entry of this.map) {\n+ let paginationTagTarget = this._getPaginationTagTarget(entry);\n+ if (\n+ paginationTagTarget &&\n+ this.isUserConfigCollectionName(paginationTagTarget)\n+ ) {\n+ graph.addNode(entry.inputPath);\n+ graph.addDependency(entry.inputPath, tagPrefix + paginationTagTarget);\n+\n// collections.all\ngraph.addDependency(tagPrefix + \"all\", entry.inputPath);\n- // collections.tagName\nif (entry.data.tags) {\n- let tags = entry.data.tags;\n- for (let tag of tags) {\n- graph.addDependency(tagPrefix + tag, entry.inputPath);\n+ for (let tag of entry.data.tags) {\n+ if (!graph.hasNode(tagPrefix + tag)) {\n+ graph.addNode(tagPrefix + tag);\n}\n+ // collections.tagName\n+ // console.log( \"Dependency from\", tagPrefix + tag, \"to\", entry.inputPath );\n+ graph.addDependency(tagPrefix + tag, entry.inputPath);\n}\n-\n- // Pagination data\n- // TODO add support for declarative dependencies in front matter (similar to pagination above)\n- if (entry.data.pagination && entry.data.pagination.data) {\n- if (entry.data.pagination.data.startsWith(\"collections.\")) {\n- let tag = entry.data.pagination.data.substr(\"collections.\".length);\n- graph.addDependency(entry.inputPath, tagPrefix + tag);\n}\n}\n}\n-\nreturn graph.overallOrder();\n}\n- async cache() {\n- debug(\"Caching collections objects.\");\n- this.collectionsData = {};\n-\n- for (let entry of this.map) {\n- entry.data.collections = this.collectionsData;\n- }\n-\n- // console.log( \">>> START\" );\n- let dependencyMap = this.getMappedDependencies();\n+ async initDependencyMap(dependencyMap) {\n+ // console.log( \"initializing\", dependencyMap );\nlet tagPrefix = \"___TAG___\";\nfor (let depEntry of dependencyMap) {\nif (depEntry.startsWith(tagPrefix)) {\n@@ -99,19 +136,21 @@ class TemplateMap {\ntagName\n);\n} else {\n- // console.log( \"tagged collection for \", tagName );\n+ // console.log( \"data tagged collection for \", tagName );\nthis.collectionsData[tagName] = this.getTaggedCollection(tagName);\n}\n} else {\n// console.log( depEntry, \"Input file\" );\nlet map = this._getMapEntryForInputPath(depEntry);\nmap._pages = await map.template.getTemplates(map.data);\n+ // console.log( \">>> PAGES LENGTH\", map._pages.length );\nlet counter = 0;\nfor (let page of map._pages) {\n- // TODO do we need these in map entries?\n+ // TODO do we need this in map entries?\nif (!map.outputPath) {\nmap.outputPath = page.outputPath;\n}\n+ // TODO do we need this in map entries?\nif (!map.url) {\nmap.url = page.url;\n}\n@@ -120,17 +159,32 @@ class TemplateMap {\n(map.data.pagination &&\nmap.data.pagination.addAllPagesToCollections)\n) {\n+ // console.log( \"Adding page to collection.\" );\nthis.collection.add(page);\n}\ncounter++;\n}\n}\n}\n+ }\n+\n+ async cache() {\n+ debug(\"Caching collections objects.\");\n+ this.collectionsData = {};\n+\n+ for (let entry of this.map) {\n+ entry.data.collections = this.collectionsData;\n+ }\n+\n+ // console.log( \">>> START\" );\n+ let dependencyMap = this.getMappedDependencies();\n+ // console.log( \"dependency map:\", dependencyMap );\n+ await this.initDependencyMap(dependencyMap);\n- // TODO running this once at the end might be a problem\n- // if user config collections needs outputPaths\n- // await this.populateCollectionsWithOutputPaths(this.collectionsData);\n- // console.log( \">>> END\" );\n+ // TODO we can make this better (delta additions to collections that have updated)\n+ let delayedDependencyMap = this.getDelayedMappedDependencies();\n+ // console.log( \"delayed dependency map:\", delayedDependencyMap );\n+ await this.initDependencyMap(delayedDependencyMap);\nawait this.populateContentDataInMap();\nthis.populateCollectionsWithContent();\n@@ -156,6 +210,9 @@ class TemplateMap {\nasync populateContentDataInMap() {\nfor (let map of this.map) {\n+ if (!map._pages) {\n+ throw new Error(`Content pages not found for ${map.inputPath}`);\n+ }\nfor (let page of map._pages) {\nlet content = await map.template.getTemplateMapContent(page);\npage.templateContent = content;\n@@ -218,7 +275,7 @@ class TemplateMap {\nisUserConfigCollectionName(name) {\nlet collections = this.configCollections || eleventyConfig.getCollections();\n- return !!collections[name];\n+ return name && !!collections[name];\n}\ngetUserConfigCollectionNames() {\n@@ -230,7 +287,8 @@ class TemplateMap {\nasync getUserConfigCollection(name) {\nlet configCollections =\nthis.configCollections || eleventyConfig.getCollections();\n- // CHANGE this works with async now\n+\n+ // This works with async now\nlet result = await configCollections[name](this.collection);\ndebug(`Collection: collections.${name} size: ${result.length}`);\n@@ -284,7 +342,7 @@ class TemplateMap {\n}\nlet entry = this.getMapEntryFromInputPath(item.inputPath);\n- let index = entry.pageNumber || 0;\n+ let index = item.pageNumber || 0;\nitem.templateContent = entry._pages[index].templateContent;\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateDataTest.js", "new_path": "test/TemplateDataTest.js", "diff": "@@ -291,3 +291,13 @@ test(\"TemplateData.merge\", t => {\n{ tags: [1, 2, 3, 4, 5, 6] }\n);\n});\n+\n+test(\"TemplateData.cleanupData\", t => {\n+ t.deepEqual(TemplateData.cleanupData({}), {});\n+ t.deepEqual(TemplateData.cleanupData({ tags: \"\" }), { tags: [] });\n+ t.deepEqual(TemplateData.cleanupData({ tags: [] }), { tags: [] });\n+ t.deepEqual(TemplateData.cleanupData({ tags: \"test\" }), { tags: [\"test\"] });\n+ t.deepEqual(TemplateData.cleanupData({ tags: [\"test1\", \"test2\"] }), {\n+ tags: [\"test1\", \"test2\"]\n+ });\n+});\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateMapTest.js", "new_path": "test/TemplateMapTest.js", "diff": "@@ -714,7 +714,7 @@ test(\"isUserConfigCollectionName\", t => {\nt.is(tm.isUserConfigCollectionName(\"userCollection2\"), false);\n});\n-test(\"Mapped Dependencies should have nodes that have no dependencies and no dependents\", async t => {\n+test(\"Dependency Map should have nodes that have no dependencies and no dependents\", async t => {\nlet tm = new TemplateMap();\nawait tm.add(tmpl1);\nawait tm.add(tmpl5);\n@@ -723,4 +723,55 @@ test(\"Mapped Dependencies should have nodes that have no dependencies and no dep\nlet deps = await tm.getMappedDependencies();\nt.true(deps.filter(dep => dep.indexOf(\"test5.md\") > -1).length > 0);\n+\n+ let collections = await tm.getCollectionsData();\n+ t.is(collections.all.length, 2);\n+});\n+\n+test(\"Dependency Map should have include orphan user config collections (in the correct order)\", async t => {\n+ let tm = new TemplateMap();\n+ await tm.add(tmpl1);\n+ await tm.add(tmpl5);\n+\n+ tm.setUserConfigCollections({\n+ userCollection: function(collection) {\n+ return collection.getAll();\n+ }\n+ });\n+\n+ await tm.cache();\n+\n+ let deps = await tm.getMappedDependencies();\n+ t.true(deps.filter(dep => dep.indexOf(\"userCollection\") > -1).length === 0);\n+\n+ let delayedDeps = await tm.getDelayedMappedDependencies();\n+ t.true(\n+ delayedDeps.filter(dep => dep.indexOf(\"userCollection\") > -1).length > 0\n+ );\n+\n+ let collections = await tm.getCollectionsData();\n+ t.is(collections.all.length, 2);\n+ t.is(collections.userCollection.length, 2);\n+});\n+\n+test(\"Dependency graph assumptions\", async t => {\n+ const DependencyGraph = require(\"dependency-graph\").DepGraph;\n+ let graph = new DependencyGraph();\n+\n+ graph.addNode(\"all\");\n+ graph.addNode(\"template-a\");\n+ graph.addNode(\"template-b\");\n+ graph.addNode(\"template-c\");\n+ graph.addNode(\"userCollection\");\n+ graph.addDependency(\"all\", \"template-a\");\n+ graph.addDependency(\"all\", \"template-b\");\n+ graph.addDependency(\"all\", \"template-c\");\n+ graph.addDependency(\"userCollection\", \"all\");\n+ t.deepEqual(graph.overallOrder(), [\n+ \"template-a\",\n+ \"template-b\",\n+ \"template-c\",\n+ \"all\",\n+ \"userCollection\"\n+ ]);\n});\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateWriterTest.js", "new_path": "test/TemplateWriterTest.js", "diff": "@@ -215,6 +215,39 @@ test(\"Pagination with a Collection\", async t => {\nt.is(templates[1].templateContent.trim(), \"<ol><li>/test3/</li></ol>\");\n});\n+test(\"Pagination with a Collection from another Paged Template\", async t => {\n+ let tw = new TemplateWriter(\n+ \"./test/stubs/paged/cfg-collection-tag-cfg-collection\",\n+ \"./test/stubs/_site\",\n+ [\"njk\"]\n+ );\n+\n+ let paths = await tw._getAllPaths();\n+ let templateMap = await tw._createTemplateMap(paths);\n+\n+ let collectionsData = await templateMap.getCollectionsData();\n+ t.is(collectionsData.tag1.length, 3);\n+ t.is(collectionsData.pagingtag.length, 2);\n+\n+ let map1 = templateMap._testGetMapEntryForPath(\n+ \"./test/stubs/paged/cfg-collection-tag-cfg-collection/paged-main.njk\"\n+ );\n+ t.is(\n+ map1._pages[0].templateContent.trim(),\n+ \"<ol><li>/test1/</li><li>/test2/</li></ol>\"\n+ );\n+ t.is(map1._pages[1].templateContent.trim(), \"<ol><li>/test3/</li></ol>\");\n+\n+ let map2 = templateMap._testGetMapEntryForPath(\n+ \"./test/stubs/paged/cfg-collection-tag-cfg-collection/paged-downstream.njk\"\n+ );\n+ t.is(map2._pages[0].templateContent.trim(), \"<ol><li>/paged-main/</li></ol>\");\n+ t.is(\n+ map2._pages[1].templateContent.trim(),\n+ \"<ol><li>/paged-main/1/</li></ol>\"\n+ );\n+});\n+\ntest(\"Pagination with a Collection (apply all pages to collections)\", async t => {\nlet tw = new TemplateWriter(\n\"./test/stubs/paged/collection-apply-to-all\",\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/paged/cfg-collection-tag-cfg-collection/consumer.njk", "diff": "+{% for item in collections.pagingtag %}{{ item.templateContent | safe }}{% endfor %}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/paged/cfg-collection-tag-cfg-collection/paged-downstream.njk", "diff": "+---\n+pagination:\n+ data: collections.pagingtag\n+ size: 1\n+---\n+<ol>{% for item in pagination.items %}<li>{{ item.url }}</li>{% endfor %}</ol>\n\\ No newline at end of file\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/paged/cfg-collection-tag-cfg-collection/paged-main.njk", "diff": "+---\n+pagination:\n+ data: collections.tag1\n+ size: 2\n+ addAllPagesToCollections: true\n+tags:\n+ - pagingtag\n+---\n+<ol>{% for item in pagination.items %}<li>{{ item.url }}</li>{% endfor %}</ol>\n\\ No newline at end of file\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/paged/cfg-collection-tag-cfg-collection/test1.njk", "diff": "+---\n+title: Testing 1\n+tags:\n+ - tag1\n+---\n+{{ title }}\n\\ No newline at end of file\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/paged/cfg-collection-tag-cfg-collection/test2.njk", "diff": "+---\n+title: Testing 2\n+tags:\n+ - tag1\n+---\n+{{ title }}\n\\ No newline at end of file\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/paged/cfg-collection-tag-cfg-collection/test3.njk", "diff": "+---\n+title: Testing 3\n+tags:\n+ - tag1\n+---\n+{{ title }}\n\\ No newline at end of file\n" } ]
JavaScript
MIT License
11ty/eleventy
Better template maps with user collections, uses two-pass to work around circular graphs
699
13.02.2019 22:37:26
21,600
bde5d9502241b987ba9c3118a17bfed66235122b
Simplified duplicate template map methods
[ { "change_type": "MODIFY", "old_path": "src/TemplateMap.js", "new_path": "src/TemplateMap.js", "diff": "@@ -124,7 +124,6 @@ class TemplateMap {\n}\nasync initDependencyMap(dependencyMap) {\n- // console.log( \"initializing\", dependencyMap );\nlet tagPrefix = \"___TAG___\";\nfor (let depEntry of dependencyMap) {\nif (depEntry.startsWith(tagPrefix)) {\n@@ -141,9 +140,9 @@ class TemplateMap {\n}\n} else {\n// console.log( depEntry, \"Input file\" );\n- let map = this._getMapEntryForInputPath(depEntry);\n+ let map = this.getMapEntryForInputPath(depEntry);\nmap._pages = await map.template.getTemplates(map.data);\n- // console.log( \">>> PAGES LENGTH\", map._pages.length );\n+\nlet counter = 0;\nfor (let page of map._pages) {\n// TODO do we need this in map entries?\n@@ -176,12 +175,10 @@ class TemplateMap {\nentry.data.collections = this.collectionsData;\n}\n- // console.log( \">>> START\" );\nlet dependencyMap = this.getMappedDependencies();\n// console.log( \"dependency map:\", dependencyMap );\nawait this.initDependencyMap(dependencyMap);\n- // TODO we can make this better (delta additions to collections that have updated)\nlet delayedDependencyMap = this.getDelayedMappedDependencies();\n// console.log( \"delayed dependency map:\", delayedDependencyMap );\nawait this.initDependencyMap(delayedDependencyMap);\n@@ -191,16 +188,7 @@ class TemplateMap {\nthis.cached = true;\n}\n- _testGetMapEntryForPath(inputPath) {\n- for (let j = 0, k = this.map.length; j < k; j++) {\n- // inputPath should be unique (even with pagination?)\n- if (this.map[j].inputPath === inputPath) {\n- return this.map[j];\n- }\n- }\n- }\n-\n- _getMapEntryForInputPath(inputPath) {\n+ getMapEntryForInputPath(inputPath) {\nfor (let map of this.map) {\nif (map.inputPath === inputPath) {\nreturn map;\n@@ -322,14 +310,6 @@ class TemplateMap {\nreturn collections;\n}\n- getMapEntryFromInputPath(inputPath) {\n- for (let entry of this.map) {\n- if (entry.inputPath === inputPath) {\n- return entry;\n- }\n- }\n- }\n-\npopulateCollectionsWithContent() {\nfor (let collectionName in this.collectionsData) {\nif (!Array.isArray(this.collectionsData[collectionName])) {\n@@ -341,7 +321,7 @@ class TemplateMap {\ncontinue;\n}\n- let entry = this.getMapEntryFromInputPath(item.inputPath);\n+ let entry = this.getMapEntryForInputPath(item.inputPath);\nlet index = item.pageNumber || 0;\nitem.templateContent = entry._pages[index].templateContent;\n}\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateMapTest.js", "new_path": "test/TemplateMapTest.js", "diff": "@@ -595,7 +595,7 @@ test(\"Should be able to paginate a tag generated collection (and it has template\nawait tm.cache();\n- let pagedMapEntry = tm._testGetMapEntryForPath(\n+ let pagedMapEntry = tm.getMapEntryForInputPath(\n\"./test/stubs/templateMapCollection/paged-tag-dogs-templateContent.md\"\n);\n@@ -635,7 +635,7 @@ test(\"Should be able to paginate a tag generated collection when aliased (and it\nawait tm.cache();\n- let pagedMapEntry = tm._testGetMapEntryForPath(\n+ let pagedMapEntry = tm.getMapEntryForInputPath(\n\"./test/stubs/templateMapCollection/paged-tag-dogs-templateContent-alias.md\"\n);\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateWriterTest.js", "new_path": "test/TemplateWriterTest.js", "diff": "@@ -183,7 +183,7 @@ test(\"Pagination with a Collection\", async t => {\nt.is(collectionsData.tag1.length, 3);\nt.is(collectionsData.pagingtag.length, 1);\n- let mapEntry = templateMap._testGetMapEntryForPath(\n+ let mapEntry = templateMap.getMapEntryForInputPath(\n\"./test/stubs/paged/collection/main.njk\"\n);\nt.truthy(mapEntry);\n@@ -229,7 +229,7 @@ test(\"Pagination with a Collection from another Paged Template\", async t => {\nt.is(collectionsData.tag1.length, 3);\nt.is(collectionsData.pagingtag.length, 2);\n- let map1 = templateMap._testGetMapEntryForPath(\n+ let map1 = templateMap.getMapEntryForInputPath(\n\"./test/stubs/paged/cfg-collection-tag-cfg-collection/paged-main.njk\"\n);\nt.is(\n@@ -238,7 +238,7 @@ test(\"Pagination with a Collection from another Paged Template\", async t => {\n);\nt.is(map1._pages[1].templateContent.trim(), \"<ol><li>/test3/</li></ol>\");\n- let map2 = templateMap._testGetMapEntryForPath(\n+ let map2 = templateMap.getMapEntryForInputPath(\n\"./test/stubs/paged/cfg-collection-tag-cfg-collection/paged-downstream.njk\"\n);\nt.is(map2._pages[0].templateContent.trim(), \"<ol><li>/paged-main/</li></ol>\");\n@@ -262,7 +262,7 @@ test(\"Pagination with a Collection (apply all pages to collections)\", async t =>\nt.is(collectionsData.tag1.length, 3);\nt.is(collectionsData.pagingtag.length, 2);\n- let mapEntry = templateMap._testGetMapEntryForPath(\n+ let mapEntry = templateMap.getMapEntryForInputPath(\n\"./test/stubs/paged/collection-apply-to-all/main.njk\"\n);\nt.truthy(mapEntry);\n@@ -312,7 +312,7 @@ test(\"Use a collection inside of a template\", async t => {\nlet collectionsData = await templateMap.getCollectionsData();\nt.is(collectionsData.dog.length, 1);\n- let mapEntry = templateMap._testGetMapEntryForPath(\n+ let mapEntry = templateMap.getMapEntryForInputPath(\n\"./test/stubs/collection-template/template.ejs\"\n);\nt.truthy(mapEntry);\n@@ -354,7 +354,7 @@ test(\"Use a collection inside of a layout\", async t => {\nlet collectionsData = await templateMap.getCollectionsData();\nt.is(collectionsData.dog.length, 1);\n- let mapEntry = templateMap._testGetMapEntryForPath(\n+ let mapEntry = templateMap.getMapEntryForInputPath(\n\"./test/stubs/collection-layout/template.ejs\"\n);\nt.truthy(mapEntry);\n@@ -485,7 +485,7 @@ test(\"fileSlug should exist in a collection\", async t => {\nlet collectionsData = await templateMap.getCollectionsData();\nt.is(collectionsData.dog.length, 1);\n- let mapEntry = templateMap._testGetMapEntryForPath(\n+ let mapEntry = templateMap.getMapEntryForInputPath(\n\"./test/stubs/collection-slug/template.njk\"\n);\nt.truthy(mapEntry);\n@@ -509,7 +509,7 @@ test.skip(\"renderData should exist and be resolved in a collection (Issue #289)\"\nlet collectionsData = await templateMap.getCollectionsData();\nt.is(collectionsData.dog.length, 1);\n- let mapEntry = templateMap._testGetMapEntryForPath(\n+ let mapEntry = templateMap.getMapEntryForInputPath(\n\"./test/stubs/collection-renderdata/template.njk\"\n);\nt.truthy(mapEntry);\n" } ]
JavaScript
MIT License
11ty/eleventy
Simplified duplicate template map methods
699
14.02.2019 20:33:41
21,600
0d3ba6c9f59b42bb0306aac75531f40b0c400e0a
Go deep on template local data dirs
[ { "change_type": "MODIFY", "old_path": "test/TemplateDataTest.js", "new_path": "test/TemplateDataTest.js", "diff": "@@ -210,6 +210,25 @@ test(\"getLocalDataPaths\", async t => {\n]);\n});\n+test(\"Deeper getLocalDataPaths\", async t => {\n+ let dataObj = new TemplateData(\"./\");\n+ let paths = await dataObj.getLocalDataPaths(\n+ \"./test/stubs/component/component.liquid\"\n+ );\n+\n+ t.deepEqual(paths, [\n+ \"./test/test.json\",\n+ \"./test/test.11tydata.json\",\n+ \"./test/test.11tydata.js\",\n+ \"./test/stubs/stubs.json\",\n+ \"./test/stubs/stubs.11tydata.json\",\n+ \"./test/stubs/stubs.11tydata.js\",\n+ \"./test/stubs/component/component.json\",\n+ \"./test/stubs/component/component.11tydata.json\",\n+ \"./test/stubs/component/component.11tydata.js\"\n+ ]);\n+});\n+\ntest(\"getLocalDataPaths with an 11ty js template\", async t => {\nlet dataObj = new TemplateData(\"./test/stubs/\");\nlet paths = await dataObj.getLocalDataPaths(\n" } ]
JavaScript
MIT License
11ty/eleventy
Go deep on template local data dirs
669
15.02.2019 08:56:45
-3,600
cf2d5bd51bcba231520e717b6e26c0665c929efb
Undo test result re-ordering
[ { "change_type": "MODIFY", "old_path": "test/TemplatePathTest.js", "new_path": "test/TemplatePathTest.js", "diff": "@@ -31,13 +31,13 @@ test(\"getAllDirs\", t => {\nt.deepEqual(TemplatePath.getAllDirs(\"testing/\"), [\"testing\"]);\nt.deepEqual(TemplatePath.getAllDirs(\"testing\"), [\"testing\"]);\nt.deepEqual(TemplatePath.getAllDirs(\"./testing/hello\"), [\n- \"./testing\",\n- \"./testing/hello\"\n+ \"./testing/hello\",\n+ \"./testing\"\n]);\nt.deepEqual(TemplatePath.getAllDirs(\"./src/collections/posts\"), [\n- \"./src\",\n+ \"./src/collections/posts\",\n\"./src/collections\",\n- \"./src/collections/posts\"\n+ \"./src\"\n]);\n});\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateTest.js", "new_path": "test/TemplateTest.js", "diff": "@@ -447,12 +447,12 @@ test(\"Local template data file import (two subdirectories deep)\", async t => {\n);\nt.deepEqual(await dataObj.getLocalDataPaths(tmpl.getInputPath()), [\n- \"./test/stubs/firstdir/seconddir/seconddir.json\",\n- \"./test/stubs/firstdir/seconddir/seconddir.11tydata.json\",\n- \"./test/stubs/firstdir/seconddir/seconddir.11tydata.js\",\n\"./test/stubs/firstdir/firstdir.json\",\n\"./test/stubs/firstdir/firstdir.11tydata.json\",\n\"./test/stubs/firstdir/firstdir.11tydata.js\",\n+ \"./test/stubs/firstdir/seconddir/seconddir.json\",\n+ \"./test/stubs/firstdir/seconddir/seconddir.11tydata.json\",\n+ \"./test/stubs/firstdir/seconddir/seconddir.11tydata.js\",\n\"./test/stubs/firstdir/seconddir/component.json\",\n\"./test/stubs/firstdir/seconddir/component.11tydata.json\",\n\"./test/stubs/firstdir/seconddir/component.11tydata.js\"\n" } ]
JavaScript
MIT License
11ty/eleventy
Undo test result re-ordering
669
15.02.2019 08:57:14
-3,600
c1ff9c0a5917a3ef1321ba63fb210c5a3684bd6c
TemplatePath.getAllDirs: Reverse result array to match previous implementation
[ { "change_type": "MODIFY", "old_path": "src/TemplatePath.js", "new_path": "src/TemplatePath.js", "diff": "@@ -79,7 +79,8 @@ TemplatePath.getAllDirs = function(path) {\nreturn path\n.split(\"/\")\n.map(segment => path.substring(0, path.indexOf(segment) + segment.length))\n- .filter(path => path !== \".\");\n+ .filter(path => path !== \".\")\n+ .reverse();\n};\n/**\n" } ]
JavaScript
MIT License
11ty/eleventy
TemplatePath.getAllDirs: Reverse result array to match previous implementation
699
17.02.2019 23:23:10
21,600
5364334200139f9d29c230827f058eaca677a984
eleventyExcludeFromCollections data option will exclude template from any collections (including collections.all)
[ { "change_type": "MODIFY", "old_path": "src/TemplateMap.js", "new_path": "src/TemplateMap.js", "diff": "@@ -157,8 +157,10 @@ class TemplateMap {\n(map.data.pagination &&\nmap.data.pagination.addAllPagesToCollections)\n) {\n+ if (!map.data.eleventyExcludeFromCollections) {\nthis.collection.add(page);\n}\n+ }\ncounter++;\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateMapTest.js", "new_path": "test/TemplateMapTest.js", "diff": "@@ -810,3 +810,24 @@ test(\"Paginated template pages should not have layouts when added to collections\nt.is(collections.all[1].templateContent, \"two\");\nt.is(collections.all[2].templateContent, \"three\");\n});\n+\n+test(\"eleventyExcludeFromCollections\", async t => {\n+ let tm = new TemplateMap();\n+ await tm.add(tmpl1);\n+\n+ let excludedTmpl = new Template(\n+ \"./test/stubs/eleventyExcludeFromCollections.njk\",\n+ \"./test/stubs/\",\n+ \"./test/stubs/_site\"\n+ );\n+ await tm.add(excludedTmpl);\n+\n+ await tm.cache();\n+\n+ t.is(tm.getMap().length, 2);\n+\n+ let collections = await tm.getCollectionsData();\n+ t.is(collections.all.length, 1);\n+ t.is(collections.post.length, 1);\n+ t.is(collections.dog.length, 1);\n+});\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/eleventyExcludeFromCollections.njk", "diff": "+---\n+title: Paged Test\n+eleventyExcludeFromCollections: true\n+tags:\n+ - post\n+ - dog\n+---\n+{{ title }}\n\\ No newline at end of file\n" } ]
JavaScript
MIT License
11ty/eleventy
eleventyExcludeFromCollections data option will exclude template from any collections (including collections.all)
699
20.02.2019 21:13:15
21,600
f2de24821b47dfbeef1fff9716d4f442bb93060a
PERFORMANCE BOOST: Reuses template content without layouts from template map instead of separate renders for collections and full template files. (Will attempt to re-render if encounters a templateContent that is not yet available) Will now throw an error when encountering circular templateContent references (instead of just failing silently).
[ { "change_type": "ADD", "old_path": null, "new_path": "src/EleventyErrorUtil.js", "diff": "+const TemplateContentPrematureUseError = require(\"./Errors/TemplateContentPrematureUseError\");\n+\n+class EleventyErrorUtil {\n+ static isPrematureTemplateContentError(e) {\n+ // TODO the rest of the template engines\n+ return (\n+ e instanceof TemplateContentPrematureUseError ||\n+ (e.originalError &&\n+ e.originalError.name === \"RenderError\" &&\n+ e.originalError.originalError instanceof\n+ TemplateContentPrematureUseError) || // Liquid\n+ e.message.indexOf(\"TemplateContentPrematureUseError\") > -1\n+ ); // Nunjucks\n+ }\n+}\n+\n+module.exports = EleventyErrorUtil;\n" }, { "change_type": "ADD", "old_path": null, "new_path": "src/Errors/TemplateContentPrematureUseError.js", "diff": "+const EleventyBaseError = require(\"../EleventyBaseError\");\n+class TemplateContentPrematureUseError extends EleventyBaseError {}\n+\n+module.exports = TemplateContentPrematureUseError;\n" }, { "change_type": "ADD", "old_path": null, "new_path": "src/Errors/UsingCircularTemplateContentReferenceError.js", "diff": "+const EleventyBaseError = require(\"../EleventyBaseError\");\n+\n+class UsingCircularTemplateContentReferenceError extends EleventyBaseError {}\n+\n+module.exports = UsingCircularTemplateContentReferenceError;\n" }, { "change_type": "MODIFY", "old_path": "src/Template.js", "new_path": "src/Template.js", "diff": "@@ -13,6 +13,7 @@ const TemplatePermalinkNoWrite = require(\"./TemplatePermalinkNoWrite\");\nconst TemplateLayout = require(\"./TemplateLayout\");\nconst TemplateFileSlug = require(\"./TemplateFileSlug\");\nconst Pagination = require(\"./Plugins/Pagination\");\n+const TemplateContentPrematureUseError = require(\"./Errors/TemplateContentPrematureUseError\");\nconst debug = require(\"debug\")(\"Eleventy:Template\");\nconst debugDev = require(\"debug\")(\"Dev:Eleventy:Template\");\n@@ -397,11 +398,23 @@ class Template extends TemplateContent {\nresults.push({\ntemplate: this,\ninputPath: this.inputPath,\n+ fileSlug: this.fileSlugStr,\ndata: data,\ndate: data.page.date,\noutputPath: data.page.outputPath,\nurl: data.page.url,\n- fileSlug: this.fileSlugStr\n+ set templateContent(content) {\n+ this._templateContent = content;\n+ },\n+ get templateContent() {\n+ if (this._templateContent === undefined) {\n+ // should at least warn here\n+ throw new TemplateContentPrematureUseError(\n+ `Tried to use templateContent too early (${this.inputPath})`\n+ );\n+ }\n+ return this._templateContent;\n+ }\n});\n} else {\n// needs collections for pagination items\n@@ -419,15 +432,31 @@ class Template extends TemplateContent {\npageData.collections = data.collections;\n}\n+ pageData.page.url = await page.getOutputHref(pageData);\n+ pageData.page.outputPath = await page.getOutputPath(pageData);\n+\nresults.push({\ntemplate: page,\ninputPath: this.inputPath,\nfileSlug: this.fileSlugStr,\ndata: pageData,\n- date: data.page.date,\n+ date: pageData.page.date,\npageNumber: pageNumber++,\n- outputPath: await page.getOutputPath(pageData),\n- url: await page.getOutputHref(pageData)\n+ outputPath: pageData.page.outputPath,\n+ url: pageData.page.url,\n+ set templateContent(content) {\n+ this._templateContent = content;\n+ },\n+ get templateContent() {\n+ if (!this._templateContent) {\n+ throw new TemplateContentPrematureUseError(\n+ `Tried to use templateContent too early (${\n+ this.inputPath\n+ } page ${this.pageNumber})`\n+ );\n+ }\n+ return this._templateContent;\n+ }\n});\n}\n}\n@@ -483,7 +512,6 @@ class Template extends TemplateContent {\n} else {\ndebug(`${lang.start} %o from %o.`, outputPath, this.inputPath);\n}\n-\nif (!this.isDryRun) {\nreturn fs.outputFile(outputPath, finalContent).then(() => {\ndebug(`${outputPath} ${lang.finished}.`);\n@@ -491,8 +519,30 @@ class Template extends TemplateContent {\n}\n}\n- async writeContent(outputPath, templateContent) {\n- return this._write(outputPath, templateContent);\n+ async writeMapEntry(mapEntry) {\n+ let promises = [];\n+ for (let page of mapEntry._pages) {\n+ let layoutKey = mapEntry.data[this.config.keys.layout];\n+ if (layoutKey) {\n+ let layout = TemplateLayout.getTemplate(\n+ layoutKey,\n+ this.getInputDir(),\n+ this.config\n+ );\n+ let content = await layout.render(page.data, page.templateContent);\n+ await this.runLinters(content, page.inputPath, page.outputPath);\n+ promises.push(this._write(page.outputPath, content));\n+ } else {\n+ await this.runLinters(\n+ page.templateContent,\n+ page.inputPath,\n+ page.outputPath\n+ );\n+ promises.push(this._write(page.outputPath, page.templateContent));\n+ }\n+ }\n+\n+ return Promise.all(promises);\n}\nasync write(outputPath, data) {\n@@ -597,10 +647,13 @@ class Template extends TemplateContent {\n}\n}\n- async getTemplateMapContent(page) {\n- page.template.setWrapWithLayouts(false);\n- let content = await page.template._getContent(page.outputPath, page.data);\n- page.template.setWrapWithLayouts(true);\n+ async getTemplateMapContent(pageMapEntry) {\n+ pageMapEntry.template.setWrapWithLayouts(false);\n+ let content = await pageMapEntry.template._getContent(\n+ pageMapEntry.outputPath,\n+ pageMapEntry.data\n+ );\n+ pageMapEntry.template.setWrapWithLayouts(true);\nreturn content;\n}\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateContent.js", "new_path": "src/TemplateContent.js", "diff": "@@ -5,6 +5,7 @@ const matter = require(\"gray-matter\");\nconst TemplateData = require(\"./TemplateData\");\nconst TemplateRender = require(\"./TemplateRender\");\nconst EleventyBaseError = require(\"./EleventyBaseError\");\n+const EleventyErrorUtil = require(\"./EleventyErrorUtil\");\nconst config = require(\"./Config\");\nconst debug = require(\"debug\")(\"Eleventy:TemplateContent\");\nconst debugDev = require(\"debug\")(\"Dev:Eleventy:TemplateContent\");\n@@ -163,6 +164,9 @@ class TemplateContent {\n);\nreturn rendered;\n} catch (e) {\n+ if (EleventyErrorUtil.isPrematureTemplateContentError(e)) {\n+ throw e;\n+ } else {\nlet engine = this.templateRender.getEnginesStr();\ndebug(\n`Having trouble rendering ${engine} template ${this.inputPath}: %O`,\n@@ -175,5 +179,6 @@ class TemplateContent {\n}\n}\n}\n+}\nmodule.exports = TemplateContent;\n" }, { "change_type": "MODIFY", "old_path": "src/TemplateMap.js", "new_path": "src/TemplateMap.js", "diff": "const isPlainObject = require(\"lodash/isPlainObject\");\nconst DependencyGraph = require(\"dependency-graph\").DepGraph;\nconst TemplateCollection = require(\"./TemplateCollection\");\n+const EleventyErrorUtil = require(\"./EleventyErrorUtil\");\n+const UsingCircularTemplateContentReferenceError = require(\"./Errors/UsingCircularTemplateContentReferenceError\");\nconst eleventyConfig = require(\"./EleventyConfig\");\nconst debug = require(\"debug\")(\"Eleventy:TemplateMap\");\nconst debugDev = require(\"debug\")(\"Dev:Eleventy:TemplateMap\");\n@@ -14,6 +16,10 @@ class TemplateMap {\nthis.configCollections = null;\n}\n+ get tagPrefix() {\n+ return \"___TAG___\";\n+ }\n+\nasync add(template) {\nfor (let map of await template.getTemplateMapEntries()) {\nthis.map.push(map);\n@@ -45,7 +51,7 @@ class TemplateMap {\ngetMappedDependencies() {\nlet graph = new DependencyGraph();\n- let tagPrefix = \"___TAG___\";\n+ let tagPrefix = this.tagPrefix;\ngraph.addNode(tagPrefix + \"all\");\n@@ -53,6 +59,7 @@ class TemplateMap {\nlet paginationTagTarget = this.getPaginationTagTarget(entry);\nif (paginationTagTarget) {\nif (this.isUserConfigCollectionName(paginationTagTarget)) {\n+ // delay this one to the second stage\ncontinue;\n} else {\n// using pagination but over a tagged collection\n@@ -75,8 +82,9 @@ class TemplateMap {\nif (!graph.hasNode(tagPrefix + tag)) {\ngraph.addNode(tagPrefix + tag);\n}\n+\n// collections.tagName\n- // console.log( \"Dependency from\", tagPrefix + tag, \"to\", entry.inputPath );\n+ // Dependency from tag to inputPath\ngraph.addDependency(tagPrefix + tag, entry.inputPath);\n}\n}\n@@ -87,7 +95,7 @@ class TemplateMap {\ngetDelayedMappedDependencies() {\nlet graph = new DependencyGraph();\n- let tagPrefix = \"___TAG___\";\n+ let tagPrefix = this.tagPrefix;\ngraph.addNode(tagPrefix + \"all\");\n@@ -118,7 +126,7 @@ class TemplateMap {\ngraph.addNode(tagPrefix + tag);\n}\n// collections.tagName\n- // console.log( \"Dependency from\", tagPrefix + tag, \"to\", entry.inputPath );\n+ // Dependency from tag to inputPath\ngraph.addDependency(tagPrefix + tag, entry.inputPath);\n}\n}\n@@ -128,18 +136,16 @@ class TemplateMap {\n}\nasync initDependencyMap(dependencyMap) {\n- let tagPrefix = \"___TAG___\";\n+ let tagPrefix = this.tagPrefix;\nfor (let depEntry of dependencyMap) {\nif (depEntry.startsWith(tagPrefix)) {\nlet tagName = depEntry.substr(tagPrefix.length);\nif (this.isUserConfigCollectionName(tagName)) {\n// async\n- // console.log( \"user config collection for\", tagName );\nthis.collectionsData[tagName] = await this.getUserConfigCollection(\ntagName\n);\n} else {\n- // console.log( \"data tagged collection for \", tagName );\nthis.collectionsData[tagName] = this.getTaggedCollection(tagName);\n}\n} else {\n@@ -158,6 +164,7 @@ class TemplateMap {\nmap.data.pagination.addAllPagesToCollections)\n) {\nif (!map.data.eleventyExcludeFromCollections) {\n+ // TODO do we need .template in collection entries?\nthis.collection.add(page);\n}\n}\n@@ -176,14 +183,23 @@ class TemplateMap {\n}\nlet dependencyMap = this.getMappedDependencies();\n- // console.log( \"dependency map:\", dependencyMap );\nawait this.initDependencyMap(dependencyMap);\nlet delayedDependencyMap = this.getDelayedMappedDependencies();\n- // console.log( \"delayed dependency map:\", delayedDependencyMap );\nawait this.initDependencyMap(delayedDependencyMap);\n- await this.populateContentDataInMap();\n+ let orderedPaths = this.getOrderedInputPaths(\n+ dependencyMap,\n+ delayedDependencyMap\n+ );\n+ let orderedMap = orderedPaths.map(\n+ function(inputPath) {\n+ return this.getMapEntryForInputPath(inputPath);\n+ }.bind(this)\n+ );\n+\n+ await this.populateContentDataInMap(orderedMap);\n+\nthis.populateCollectionsWithContent();\nthis.cached = true;\n}\n@@ -196,24 +212,67 @@ class TemplateMap {\n}\n}\n- async populateContentDataInMap() {\n- for (let map of this.map) {\n+ getOrderedInputPaths(dependencyMap, delayedDependencyMap) {\n+ let orderedMap = [];\n+ let tagPrefix = this.tagPrefix;\n+\n+ for (let dep of dependencyMap) {\n+ if (!dep.startsWith(tagPrefix)) {\n+ orderedMap.push(dep);\n+ }\n+ }\n+ for (let dep of delayedDependencyMap) {\n+ if (!dep.startsWith(tagPrefix)) {\n+ orderedMap.push(dep);\n+ }\n+ }\n+ return orderedMap;\n+ }\n+\n+ async populateContentDataInMap(orderedMap) {\n+ let usedTemplateContentTooEarlyMap = [];\n+ for (let map of orderedMap) {\nif (!map._pages) {\nthrow new Error(`Content pages not found for ${map.inputPath}`);\n}\n- for (let page of map._pages) {\n- let content = await map.template.getTemplateMapContent(page);\n- page.templateContent = content;\n-\n- // TODO is this necessary in map entries\n- if (!map.templateContent) {\n- map.templateContent = content;\n+ try {\n+ for (let pageEntry of map._pages) {\n+ pageEntry.templateContent = await map.template.getTemplateMapContent(\n+ pageEntry\n+ );\n+ }\n+ } catch (e) {\n+ if (EleventyErrorUtil.isPrematureTemplateContentError(e)) {\n+ usedTemplateContentTooEarlyMap.push(map);\n+ } else {\n+ throw e;\n}\n}\ndebugDev(\n\"Added this.map[...].templateContent, outputPath, et al for one map entry\"\n);\n}\n+\n+ for (let map of usedTemplateContentTooEarlyMap) {\n+ try {\n+ for (let pageEntry of map._pages) {\n+ pageEntry.templateContent = await map.template.getTemplateMapContent(\n+ pageEntry\n+ );\n+ }\n+ } catch (e) {\n+ if (EleventyErrorUtil.isPrematureTemplateContentError(e)) {\n+ throw new UsingCircularTemplateContentReferenceError(\n+ `${\n+ map.inputPath\n+ } contains a circular reference (using collections) to its own templateContent.`\n+ );\n+ } else {\n+ // rethrow?\n+ throw e;\n+ }\n+ }\n+ }\n}\n_testGetAllTags() {\n@@ -320,7 +379,7 @@ class TemplateMap {\nlet entry = this.getMapEntryForInputPath(item.inputPath);\nlet index = item.pageNumber || 0;\n- item.templateContent = entry._pages[index].templateContent;\n+ item.templateContent = entry._pages[index]._templateContent;\n}\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateMapTest.js", "new_path": "test/TemplateMapTest.js", "diff": "@@ -2,6 +2,7 @@ import test from \"ava\";\nimport Template from \"../src/Template\";\nimport TemplateMap from \"../src/TemplateMap\";\nimport TemplateCollection from \"../src/TemplateCollection\";\n+import UsingCircularTemplateContentReferenceError from \"../src/Errors/UsingCircularTemplateContentReferenceError\";\nimport normalizeNewLines from \"./Util/normalizeNewLines\";\nlet tmpl1 = new Template(\n@@ -74,14 +75,13 @@ test(\"TemplateMap adds collections data and has templateContent values\", async t\nawait tm.add(tmpl2);\nlet map = tm.getMap();\n- t.falsy(map[0].templateContent);\n- t.falsy(map[1].templateContent);\nt.falsy(map[0].data.collections);\nt.falsy(map[1].data.collections);\nawait tm.cache();\n- t.truthy(map[0].templateContent);\n- t.truthy(map[1].templateContent);\n+\n+ t.truthy(map[0]._pages[0].templateContent);\n+ t.truthy(map[1]._pages[0].templateContent);\nt.truthy(map[0].data.collections);\nt.truthy(map[1].data.collections);\nt.is(map[0].data.collections.post.length, 1);\n@@ -91,11 +91,11 @@ test(\"TemplateMap adds collections data and has templateContent values\", async t\nt.is(\nawait map[0].template._testRenderWithoutLayouts(map[0].data),\n- map[0].templateContent\n+ map[0]._pages[0].templateContent\n);\nt.is(\nawait map[1].template._testRenderWithoutLayouts(map[1].data),\n- map[1].templateContent\n+ map[1]._pages[0].templateContent\n);\n});\n@@ -110,17 +110,16 @@ test(\"TemplateMap circular references (map without templateContent)\", async t =>\n);\nlet map = tm.getMap();\n- t.falsy(map[0].templateContent);\nt.falsy(map[0].data.collections);\nawait tm.cache();\n- t.truthy(map[0].templateContent);\n+ t.truthy(map[0]._pages[0].templateContent);\nt.truthy(map[0].data.collections);\nt.is(map[0].data.collections.all.length, 1);\nt.is(\nawait map[0].template._testRenderWithoutLayouts(map[0].data),\n- map[0].templateContent\n+ map[0]._pages[0].templateContent\n);\n});\n@@ -135,21 +134,15 @@ test(\"TemplateMap circular references (map.templateContent)\", async t => {\n);\nlet map = tm.getMap();\n- t.falsy(map[0].templateContent);\nt.falsy(map[0].data.collections);\n+ await t.throwsAsync(\n+ async () => {\nawait tm.cache();\n- t.truthy(map[0].templateContent);\n- t.truthy(map[0].data.collections);\n- t.is(map[0].data.collections.all.length, 1);\n-\n- // templateContent references are not available inside of templateContent strings\n- t.is(map[0].templateContent.trim(), \"<h1>Test</h1>\");\n-\n- // first cached templateContent is available to future render calls (but will not loop in any way).\n- t.is(\n- (await map[0].template._testRenderWithoutLayouts(map[0].data)).trim(),\n- \"<h1>Test</h1>\\n<h1>Test</h1>\"\n+ },\n+ {\n+ instanceOf: UsingCircularTemplateContentReferenceError\n+ }\n);\n});\n@@ -578,7 +571,7 @@ test(\"TemplateMap render and templateContent are the same (templateContent doesn\nlet map = tm.getMap();\nawait tm.cache();\n- t.is(map[0].templateContent.trim(), \"<p>Inherited</p>\");\n+ t.is(map[0]._pages[0].templateContent.trim(), \"<p>Inherited</p>\");\nt.is((await map[0].template.render(map[0].data)).trim(), \"<p>Inherited</p>\");\n});\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateWriterTest.js", "new_path": "test/TemplateWriterTest.js", "diff": "@@ -188,31 +188,15 @@ test(\"Pagination with a Collection\", async t => {\n);\nt.truthy(mapEntry);\nt.is(mapEntry.inputPath, \"./test/stubs/paged/collection/main.njk\");\n+ t.is(mapEntry._pages.length, 2);\n+ t.is(mapEntry._pages[0].outputPath, \"./test/stubs/_site/main/index.html\");\n+ t.is(mapEntry._pages[1].outputPath, \"./test/stubs/_site/main/1/index.html\");\n- let mainTmpl = tw._createTemplate(\"./test/stubs/paged/collection/main.njk\");\n- let outputPath = await mainTmpl.getOutputPath();\n- t.is(outputPath, \"./test/stubs/_site/main/index.html\");\n- t.is(mapEntry.outputPath, \"./test/stubs/_site/main/index.html\");\n-\n- let templates = await mapEntry.template.getRenderedTemplates(mapEntry.data);\n- t.is(templates.length, 2);\n- t.is(\n- await templates[0].template.getOutputPath(),\n- \"./test/stubs/_site/main/index.html\"\n- );\n- t.is(templates[0].outputPath, \"./test/stubs/_site/main/index.html\");\n- t.is(\n- await templates[1].template.getOutputPath(),\n- \"./test/stubs/_site/main/1/index.html\"\n- );\n- t.is(templates[1].outputPath, \"./test/stubs/_site/main/1/index.html\");\n-\n- // test content\nt.is(\n- templates[0].templateContent.trim(),\n+ mapEntry._pages[0].templateContent.trim(),\n\"<ol><li>/test1/</li><li>/test2/</li></ol>\"\n);\n- t.is(templates[1].templateContent.trim(), \"<ol><li>/test3/</li></ol>\");\n+ t.is(mapEntry._pages[1].templateContent.trim(), \"<ol><li>/test3/</li></ol>\");\n});\ntest(\"Pagination with a Collection from another Paged Template\", async t => {\n" } ]
JavaScript
MIT License
11ty/eleventy
PERFORMANCE BOOST: Reuses template content without layouts from template map instead of separate renders for collections and full template files. (Will attempt to re-render if encounters a templateContent that is not yet available) Will now throw an error when encountering circular templateContent references (instead of just failing silently).
699
21.02.2019 21:24:21
21,600
fc7221666711cf1e65f2e6eca86a57d4883db73e
More tests for premature template content errors.
[ { "change_type": "MODIFY", "old_path": "src/Template.js", "new_path": "src/Template.js", "diff": "@@ -519,9 +519,7 @@ class Template extends TemplateContent {\n}\n}\n- async writeMapEntry(mapEntry) {\n- let promises = [];\n- for (let page of mapEntry._pages) {\n+ async renderPageEntry(mapEntry, page) {\nlet layoutKey = mapEntry.data[this.config.keys.layout];\nif (layoutKey) {\nlet layout = TemplateLayout.getTemplate(\n@@ -531,15 +529,22 @@ class Template extends TemplateContent {\n);\nlet content = await layout.render(page.data, page.templateContent);\nawait this.runLinters(content, page.inputPath, page.outputPath);\n- promises.push(this._write(page.outputPath, content));\n+ return content;\n} else {\nawait this.runLinters(\npage.templateContent,\npage.inputPath,\npage.outputPath\n);\n- promises.push(this._write(page.outputPath, page.templateContent));\n+ return page.templateContent;\n+ }\n}\n+\n+ async writeMapEntry(mapEntry) {\n+ let promises = [];\n+ for (let page of mapEntry._pages) {\n+ let content = await this.renderPageEntry(mapEntry, page);\n+ promises.push(this._write(page.outputPath, content));\n}\nreturn Promise.all(promises);\n" }, { "change_type": "MODIFY", "old_path": "test/TemplateTest.js", "new_path": "test/TemplateTest.js", "diff": "@@ -3,6 +3,8 @@ import fs from \"fs-extra\";\nimport pretty from \"pretty\";\nimport TemplateData from \"../src/TemplateData\";\nimport Template from \"../src/Template\";\n+import EleventyErrorUtil from \"../src/EleventyErrorUtil\";\n+import TemplateContentPrematureUseError from \"../src/Errors/TemplateContentPrematureUseError\";\nimport templateConfig from \"../src/Config\";\nimport normalizeNewLines from \"./Util/normalizeNewLines\";\n@@ -1237,7 +1239,7 @@ test(\"Front matter date with quotes (njk), issue #258\", async t => {\nt.is(data.mydate.toISOString(), \"2009-04-15T00:34:34.000Z\");\nlet pages = await tmpl.getRenderedTemplates(data);\n- t.is(pages[0].templateContent.trim(), `2009-04-15T00:34:34.000Z`);\n+ t.is(pages[0].templateContent.trim(), \"2009-04-15T00:34:34.000Z\");\n});\ntest(\"Data Cascade (Deep merge)\", async t => {\n@@ -1370,3 +1372,235 @@ test('Local data inherits tags string ([tags] vs \"tags\") Deep Merge', async t =>\nlet data = await tmpl.getData();\nt.deepEqual(data.tags.sort(), [\"tag1\", \"tag2\", \"tag3\"]);\n});\n+\n+test(\"Throws a Premature Template Content Error (njk)\", async t => {\n+ let tmpl = new Template(\n+ \"./test/stubs/prematureTemplateContent/test.njk\",\n+ \"./test/stubs/\",\n+ \"./test/stubs/_site\"\n+ );\n+\n+ let data = await tmpl.getData();\n+ let mapEntries = await tmpl.getTemplates(data);\n+ let error = t.throws(() => {\n+ mapEntries[0].templateContent;\n+ });\n+ t.is(EleventyErrorUtil.isPrematureTemplateContentError(error), true);\n+});\n+\n+test(\"Throws a Premature Template Content Error from rendering (njk)\", async t => {\n+ let tmpl = new Template(\n+ \"./test/stubs/prematureTemplateContent/test.njk\",\n+ \"./test/stubs/\",\n+ \"./test/stubs/_site\"\n+ );\n+\n+ let mapEntries = await tmpl.getTemplateMapEntries();\n+ let pageEntries = await tmpl.getTemplates({\n+ page: {},\n+ sample: {\n+ get templateContent() {\n+ throw new TemplateContentPrematureUseError(\n+ \"Tried to use templateContent too early (test.njk)\"\n+ );\n+ }\n+ }\n+ });\n+ let error = await t.throwsAsync(async () => {\n+ await tmpl.renderPageEntry(mapEntries[0], pageEntries[0]);\n+ });\n+ console.log(error);\n+ t.is(EleventyErrorUtil.isPrematureTemplateContentError(error), true);\n+});\n+\n+test(\"Throws a Premature Template Content Error (liquid)\", async t => {\n+ let tmpl = new Template(\n+ \"./test/stubs/prematureTemplateContent/test.liquid\",\n+ \"./test/stubs/\",\n+ \"./test/stubs/_site\"\n+ );\n+\n+ let data = await tmpl.getData();\n+ let mapEntries = await tmpl.getTemplates(data);\n+ let error = t.throws(() => {\n+ mapEntries[0].templateContent;\n+ });\n+ t.is(EleventyErrorUtil.isPrematureTemplateContentError(error), true);\n+});\n+\n+test(\"Throws a Premature Template Content Error (11ty.js)\", async t => {\n+ let tmpl = new Template(\n+ \"./test/stubs/prematureTemplateContent/test.11ty.js\",\n+ \"./test/stubs/\",\n+ \"./test/stubs/_site\"\n+ );\n+\n+ let data = await tmpl.getData();\n+ let mapEntries = await tmpl.getTemplates(data);\n+ let error = t.throws(() => {\n+ mapEntries[0].templateContent;\n+ });\n+ t.is(EleventyErrorUtil.isPrematureTemplateContentError(error), true);\n+});\n+\n+test(\"Throws a Premature Template Content Error (pug)\", async t => {\n+ let tmpl = new Template(\n+ \"./test/stubs/prematureTemplateContent/test.pug\",\n+ \"./test/stubs/\",\n+ \"./test/stubs/_site\"\n+ );\n+\n+ let data = await tmpl.getData();\n+ let mapEntries = await tmpl.getTemplates(data);\n+ let error = t.throws(() => {\n+ mapEntries[0].templateContent;\n+ });\n+ t.is(EleventyErrorUtil.isPrematureTemplateContentError(error), true);\n+});\n+\n+test(\"Throws a Premature Template Content Error from rendering (pug)\", async t => {\n+ let tmpl = new Template(\n+ \"./test/stubs/prematureTemplateContent/test.pug\",\n+ \"./test/stubs/\",\n+ \"./test/stubs/_site\"\n+ );\n+\n+ let mapEntries = await tmpl.getTemplateMapEntries();\n+ let pageEntries = await tmpl.getTemplates({\n+ page: {},\n+ sample: {\n+ get templateContent() {\n+ throw new TemplateContentPrematureUseError(\n+ \"Tried to use templateContent too early (test.pug)\"\n+ );\n+ }\n+ }\n+ });\n+ let error = await t.throwsAsync(async () => {\n+ await tmpl.renderPageEntry(mapEntries[0], pageEntries[0]);\n+ });\n+ t.is(EleventyErrorUtil.isPrematureTemplateContentError(error), true);\n+});\n+\n+test(\"Throws a Premature Template Content Error (md)\", async t => {\n+ let tmpl = new Template(\n+ \"./test/stubs/prematureTemplateContent/test.md\",\n+ \"./test/stubs/\",\n+ \"./test/stubs/_site\"\n+ );\n+\n+ let data = await tmpl.getData();\n+ let mapEntries = await tmpl.getTemplates(data);\n+ let error = t.throws(() => {\n+ mapEntries[0].templateContent;\n+ });\n+ t.is(EleventyErrorUtil.isPrematureTemplateContentError(error), true);\n+});\n+\n+test(\"Throws a Premature Template Content Error from rendering (md)\", async t => {\n+ let tmpl = new Template(\n+ \"./test/stubs/prematureTemplateContent/test.md\",\n+ \"./test/stubs/\",\n+ \"./test/stubs/_site\"\n+ );\n+\n+ let mapEntries = await tmpl.getTemplateMapEntries();\n+ let pageEntries = await tmpl.getTemplates({\n+ page: {},\n+ sample: {\n+ get templateContent() {\n+ throw new TemplateContentPrematureUseError(\n+ \"Tried to use templateContent too early (test.md)\"\n+ );\n+ }\n+ }\n+ });\n+ let error = await t.throwsAsync(async () => {\n+ await tmpl.renderPageEntry(mapEntries[0], pageEntries[0]);\n+ });\n+ t.is(EleventyErrorUtil.isPrematureTemplateContentError(error), true);\n+});\n+\n+test(\"Throws a Premature Template Content Error (hbs)\", async t => {\n+ let tmpl = new Template(\n+ \"./test/stubs/prematureTemplateContent/test.hbs\",\n+ \"./test/stubs/\",\n+ \"./test/stubs/_site\"\n+ );\n+\n+ let data = await tmpl.getData();\n+ let mapEntries = await tmpl.getTemplates(data);\n+ let error = t.throws(() => {\n+ mapEntries[0].templateContent;\n+ });\n+ t.is(EleventyErrorUtil.isPrematureTemplateContentError(error), true);\n+});\n+\n+test(\"Throws a Premature Template Content Error from rendering (hbs)\", async t => {\n+ let tmpl = new Template(\n+ \"./test/stubs/prematureTemplateContent/test.hbs\",\n+ \"./test/stubs/\",\n+ \"./test/stubs/_site\"\n+ );\n+\n+ let mapEntries = await tmpl.getTemplateMapEntries();\n+ let pageEntries = await tmpl.getTemplates({\n+ page: {},\n+ sample: {\n+ get templateContent() {\n+ throw new TemplateContentPrematureUseError(\n+ \"Tried to use templateContent too early (test.hbs)\"\n+ );\n+ }\n+ }\n+ });\n+ let error = await t.throwsAsync(async () => {\n+ await tmpl.renderPageEntry(mapEntries[0], pageEntries[0]);\n+ });\n+ t.is(EleventyErrorUtil.isPrematureTemplateContentError(error), true);\n+});\n+\n+test(\"Throws a Premature Template Content Error (mustache)\", async t => {\n+ let tmpl = new Template(\n+ \"./test/stubs/prematureTemplateContent/test.mustache\",\n+ \"./test/stubs/\",\n+ \"./test/stubs/_site\"\n+ );\n+\n+ let data = await tmpl.getData();\n+ let mapEntries = await tmpl.getTemplates(data);\n+ let error = t.throws(() => {\n+ mapEntries[0].templateContent;\n+ });\n+ t.is(EleventyErrorUtil.isPrematureTemplateContentError(error), true);\n+});\n+\n+test(\"Throws a Premature Template Content Error (ejs)\", async t => {\n+ let tmpl = new Template(\n+ \"./test/stubs/prematureTemplateContent/test.ejs\",\n+ \"./test/stubs/\",\n+ \"./test/stubs/_site\"\n+ );\n+\n+ let data = await tmpl.getData();\n+ let mapEntries = await tmpl.getTemplates(data);\n+ let error = t.throws(() => {\n+ mapEntries[0].templateContent;\n+ });\n+ t.is(EleventyErrorUtil.isPrematureTemplateContentError(error), true);\n+});\n+\n+test(\"Throws a Premature Template Content Error (haml)\", async t => {\n+ let tmpl = new Template(\n+ \"./test/stubs/prematureTemplateContent/test.haml\",\n+ \"./test/stubs/\",\n+ \"./test/stubs/_site\"\n+ );\n+\n+ let data = await tmpl.getData();\n+ let mapEntries = await tmpl.getTemplates(data);\n+ let error = t.throws(() => {\n+ mapEntries[0].templateContent;\n+ });\n+ t.is(EleventyErrorUtil.isPrematureTemplateContentError(error), true);\n+});\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/prematureTemplateContent/test.11ty.js", "diff": "+module.exports = function(data) {\n+ return data.collections.all[0].templateContent;\n+};\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/prematureTemplateContent/test.ejs", "diff": "+<%= collections.all[0].templateContent %>\n\\ No newline at end of file\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/prematureTemplateContent/test.haml", "diff": "+%p= collections.all[0].templateContent\n\\ No newline at end of file\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/prematureTemplateContent/test.hbs", "diff": "+{{ sample.templateContent }}\n\\ No newline at end of file\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/prematureTemplateContent/test.liquid", "diff": "+{{ collections.all[0].templateContent }}\n\\ No newline at end of file\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/prematureTemplateContent/test.md", "diff": "+{{ sample.templateContent }}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/prematureTemplateContent/test.mustache", "diff": "+{{ collections.all[0].templateContent }}\n\\ No newline at end of file\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/prematureTemplateContent/test.njk", "diff": "+{{ sample.templateContent }}\n\\ No newline at end of file\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs/prematureTemplateContent/test.pug", "diff": "+p= sample.templateContent\n\\ No newline at end of file\n" } ]
JavaScript
MIT License
11ty/eleventy
More tests for premature template content errors.
699
22.02.2019 08:29:33
21,600
b7b47419e545887dcfbedc4d72300e972267b62b
Fixes and another npm audit warning for `nyc` too. One low vuln exists for browser-sync but we are on the latest version
[ { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "\"husky\": \"^1.3.1\",\n\"lint-staged\": \"^8.1.0\",\n\"markdown-it-emoji\": \"^1.4.0\",\n- \"nyc\": \"^13.1.0\",\n+ \"nyc\": \"^13.3.0\",\n\"prettier\": \"^1.15.3\",\n\"viperhtml\": \"^2.17.0\",\n\"vue\": \"^2.5.22\",\n\"fs-extra\": \"^7.0.1\",\n\"gray-matter\": \"^4.0.1\",\n\"hamljs\": \"^0.6.2\",\n- \"handlebars\": \"^4.0.12\",\n+ \"handlebars\": \"^4.0.13\",\n\"javascript-stringify\": \"^1.6.0\",\n\"liquidjs\": \"^6.2.0\",\n\"lodash\": \"^4.17.11\",\n" } ]
JavaScript
MIT License
11ty/eleventy
Fixes #424 and another npm audit warning for `nyc` too. One low vuln exists for browser-sync but we are on the latest version
699
07.03.2019 21:52:21
21,600
0812197b614432668f66ce9b62a524af49aef581
Adds working tests for
[ { "change_type": "MODIFY", "old_path": "test/TemplateRenderHandlebarsTest.js", "new_path": "test/TemplateRenderHandlebarsTest.js", "diff": "@@ -174,3 +174,38 @@ test(\"Handlebars Render Paired Shortcode with a Nested Single Shortcode\", async\n\"<p>This is a CHILD CONTENTHOWDYZACH.</p>\"\n);\n});\n+\n+test(\"Handlebars Render Raw Output (Issue #436)\", async t => {\n+ let tr = new TemplateRender(\"hbs\");\n+ tr.engine.addHelpers({\n+ \"raw-helper\": function(options) {\n+ return options.fn();\n+ }\n+ });\n+\n+ let fn = await tr.getCompiledTemplate(\n+ \"{{{{raw-helper}}}}{{bar}}{{{{/raw-helper}}}}\"\n+ );\n+ t.is(await fn({ name: \"Zach\" }), \"{{bar}}\");\n+});\n+\n+test(\"Handlebars Render Raw Output (Issue #436 with if statement)\", async t => {\n+ let tr = new TemplateRender(\"hbs\");\n+ tr.engine.addHelpers({\n+ \"raw-helper\": function(options) {\n+ return options.fn();\n+ }\n+ });\n+\n+ let fn = await tr.getCompiledTemplate(\n+ `{{{{raw-helper}}}}{{#if ready}}\n+<p>Ready</p>\n+{{/if}}{{{{/raw-helper}}}}`\n+ );\n+ t.is(\n+ await fn({ name: \"Zach\" }),\n+ `{{#if ready}}\n+<p>Ready</p>\n+{{/if}}`\n+ );\n+});\n" } ]
JavaScript
MIT License
11ty/eleventy
Adds working tests for #436
699
08.03.2019 14:45:06
21,600
f7de5b4844a4d174b1d578a52716f283228036fc
Test confirms is fixed.
[ { "change_type": "MODIFY", "old_path": "test/TemplateDataTest.js", "new_path": "test/TemplateDataTest.js", "diff": "@@ -320,3 +320,23 @@ test(\"TemplateData.cleanupData\", t => {\ntags: [\"test1\", \"test2\"]\n});\n});\n+\n+test(\"Parent directory for data\", async t => {\n+ let dataObj = new TemplateData(\"./test/stubs-337/src/\");\n+ dataObj._setConfig({\n+ dataTemplateEngine: false,\n+ dir: {\n+ input: \"./test/stubs-337/src/\",\n+ data: \"../data/\"\n+ }\n+ });\n+ dataObj.setInputDir(\"./test/stubs-337/src/\");\n+\n+ let data = await dataObj.getData();\n+\n+ t.deepEqual(data, {\n+ xyz: {\n+ hi: \"bye\"\n+ }\n+ });\n+});\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/stubs-337/data/xyz.json", "diff": "+{\n+ \"hi\": \"bye\"\n+}\n\\ No newline at end of file\n" } ]
JavaScript
MIT License
11ty/eleventy
Test confirms #337 is fixed.
699
08.03.2019 21:07:10
21,600
ecf29bd710fbafa3c7fb2372bf529e6c76d1cd0d
Updating handlebars
[ { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "\"fs-extra\": \"^7.0.1\",\n\"gray-matter\": \"^4.0.1\",\n\"hamljs\": \"^0.6.2\",\n- \"handlebars\": \"^4.0.13\",\n+ \"handlebars\": \"^4.1.0\",\n\"javascript-stringify\": \"^1.6.0\",\n\"liquidjs\": \"^6.2.0\",\n\"lodash\": \"^4.17.11\",\n" } ]
JavaScript
MIT License
11ty/eleventy
Updating handlebars
699
10.03.2019 22:11:52
18,000
8610d473deca4e4e7853e0617764f462ec15b179
Regression in config updates, config path from chokidar needed leading dot slash. Might fix Not sure yet.
[ { "change_type": "MODIFY", "old_path": "src/Eleventy.js", "new_path": "src/Eleventy.js", "diff": "@@ -232,10 +232,14 @@ Arguments:\nconfig.reset();\nthis.config = config.getConfig();\n- this.eleventyServe.updateConfig(this.config);\n+ this.eleventyServe.config = this.config;\n}\nasync _watch(path) {\n+ if (path) {\n+ path = TemplatePath.addLeadingDotSlash(path);\n+ }\n+\nif (this.active) {\nthis.queuedToRun = path;\nreturn;\n@@ -262,7 +266,8 @@ Arguments:\nthis.watcher.add(this.watchTargets.getNewTargetsSinceLastReset());\nlet isInclude =\n- path && TemplatePath.startsWithSubPath(path, this.eleventyFiles.getIncludesDir());\n+ path &&\n+ TemplatePath.startsWithSubPath(path, this.eleventyFiles.getIncludesDir());\nthis.eleventyServe.reload(path, isInclude);\nthis.active = false;\n" } ]
JavaScript
MIT License
11ty/eleventy
Regression in config updates, config path from chokidar needed leading dot slash. Might fix #340? Not sure yet.