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 | 05.02.2018 21:58:26 | 18,000 | a833c05d3814b3434bbeeb43de2dd30369ba24c4 | Fixes with local dir and template data files | [
{
"change_type": "MODIFY",
"old_path": "docs/data.md",
"new_path": "docs/data.md",
"diff": "@@ -55,6 +55,20 @@ This data will be available to your templates like so:\n}\n```\n+### Template and Directory Specific Data Files\n+\n+_New in Eleventy v0.2.14_ While it is useful to have globally available data to all of your templates, you may want some of your data to be available locally only to one specific template or to a directory of templates. For that use, we also search for JSON data files in specific places in your directory structure.\n+\n+For example, consider a template located at `posts/my-first-blog-post.md`. Eleventy will look for data in the following places (starting with highest priority, local data keys override global data):\n+\n+1. `posts/my-first-blog-post.json` (data only applied to `posts/my-first-blog-post.json`)\n+1. `posts/posts.json` (data applied to `posts/*`)\n+1. `_data/*` (global data files available to all templates)\n+\n+#### Apply a default layout to multiple templates\n+\n+Try adding `{ \"layout\": \"layouts/post.njk\" }` to `posts/posts.json` to configure a layout for all of the templates inside of `posts/*`.\n+\n### Pre-processing\nAll data files will be pre-processed with the template engine specified under the `dataTemplateEngine` configuration option. Note that `package.json` data is available here under the `pkg` variable.\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Template.js",
"new_path": "src/Template.js",
"diff": "@@ -180,8 +180,23 @@ class Template {\nreturn merged;\n}\n- getLocalDataPath() {\n- return this.parsed.dir + \"/\" + this.parsed.name + \".json\";\n+ getLocalDataPaths() {\n+ let paths = [];\n+\n+ if (this.parsed.dir) {\n+ let lastDir = TemplatePath.getLastDir(this.parsed.dir);\n+ let dirPath = this.parsed.dir + \"/\" + lastDir + \".json\";\n+ let filePath = this.parsed.dir + \"/\" + this.parsed.name + \".json\";\n+\n+ paths.push(dirPath);\n+\n+ // unique\n+ if (filePath !== dirPath) {\n+ paths.push(filePath);\n+ }\n+ }\n+\n+ return paths;\n}\nasync mapDataAsRenderedTemplates(data, templateData) {\n@@ -216,7 +231,7 @@ class Template {\nlet data = {};\nif (this.templateData) {\n- data = await this.templateData.getLocalData(this.getLocalDataPath());\n+ data = await this.templateData.getLocalData(this.getLocalDataPaths());\n}\nlet mergedLocalData = Object.assign({}, localData, this.dataOverrides);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateData.js",
"new_path": "src/TemplateData.js",
"diff": "@@ -3,6 +3,7 @@ const pify = require(\"pify\");\nconst globby = require(\"globby\");\nconst parsePath = require(\"parse-filepath\");\nconst lodashset = require(\"lodash.set\");\n+const lodashMerge = require(\"lodash.merge\");\nconst TemplateRender = require(\"./TemplateRender\");\nconst TemplatePath = require(\"./TemplatePath\");\nconst TemplateGlob = require(\"./TemplateGlob\");\n@@ -107,9 +108,22 @@ TemplateData.prototype.getData = async function() {\nreturn this.globalData;\n};\n-TemplateData.prototype.getLocalData = async function(localDataPath) {\n+TemplateData.prototype.combineLocalData = async function(localDataPaths) {\nlet rawImports = await this.getRawImports();\n- let importedData = await this.getJson(localDataPath, rawImports);\n+ let localData = {};\n+ if (!Array.isArray(localDataPaths)) {\n+ localDataPaths = [localDataPaths];\n+ }\n+\n+ for (let path of localDataPaths) {\n+ let dataForPath = await this.getJson(path, rawImports);\n+ lodashMerge(localData, dataForPath);\n+ }\n+ return localData;\n+};\n+\n+TemplateData.prototype.getLocalData = async function(localDataPaths) {\n+ let importedData = await this.combineLocalData(localDataPaths);\nlet globalData = await this.getData();\nreturn Object.assign({}, globalData, importedData);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplatePath.js",
"new_path": "src/TemplatePath.js",
"diff": "@@ -11,6 +11,20 @@ TemplatePath.getWorkingDir = function() {\nreturn path.resolve(\"./\");\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+ return path;\n+ } else if (slashIndex === path.length - 1) {\n+ // last character is a slash\n+ path = path.substring(0, path.length - 1);\n+ }\n+\n+ return path.substr(path.lastIndexOf(\"/\") + 1);\n+};\n+\n/* Outputs ./SAFE/LOCAL/PATHS/WITHOUT/TRAILING/SLASHES */\nTemplatePath.normalize = function(...paths) {\nreturn normalize(path.join(...paths));\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateWriter.js",
"new_path": "src/TemplateWriter.js",
"diff": "@@ -203,7 +203,7 @@ TemplateWriter.prototype._getTemplate = function(path) {\nreturn tmpl;\n};\n-TemplateWriter.prototype._copyPass = async function(path) {\n+TemplateWriter.prototype._copyPassthroughPath = async function(path) {\nlet pass = new TemplatePassthrough(path, this.outputDir);\ntry {\nawait pass.write();\n@@ -224,13 +224,13 @@ TemplateWriter.prototype._copyPassthroughs = async function(paths) {\ndebug(\"TemplatePassthrough copy started.\");\nfor (let cfgPath in this.config.passthroughCopies) {\ncount++;\n- this._copyPass(cfgPath);\n+ this._copyPassthroughPath(cfgPath);\n}\nfor (let path of paths) {\nif (!TemplateRender.hasEngine(path)) {\ncount++;\n- this._copyPass(path);\n+ this._copyPassthroughPath(path);\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplatePathTest.js",
"new_path": "test/TemplatePathTest.js",
"diff": "@@ -58,3 +58,11 @@ test(\"stripPathFromDir\", t => {\n\"hello/subdir/test\"\n);\n});\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"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateTest.js",
"new_path": "test/TemplateTest.js",
"diff": "@@ -394,11 +394,61 @@ test(\"Local template data file import (without a global data json)\", async t =>\n);\nlet data = await tmpl.getData();\n- t.is(tmpl.getLocalDataPath(), \"./test/stubs/component/component.json\");\n+ t.deepEqual(tmpl.getLocalDataPaths(), [\n+ \"./test/stubs/component/component.json\"\n+ ]);\nt.is(data.localdatakey1, \"localdatavalue1\");\nt.is(await tmpl.render(), \"localdatavalue1\");\n});\n+test(\"Local template data file import (two subdirectories deep)\", async t => {\n+ let dataObj = new TemplateData();\n+ await dataObj.cacheData();\n+\n+ let tmpl = new Template(\n+ \"./test/stubs/firstdir/seconddir/component.njk\",\n+ \"./test/stubs/\",\n+ \"./dist\",\n+ dataObj\n+ );\n+\n+ t.deepEqual(tmpl.getLocalDataPaths(), [\n+ \"./test/stubs/firstdir/seconddir/seconddir.json\",\n+ \"./test/stubs/firstdir/seconddir/component.json\"\n+ ]);\n+});\n+\n+test(\"Posts inherits local JSON, layouts\", async t => {\n+ let dataObj = new TemplateData();\n+ await dataObj.cacheData();\n+\n+ let tmpl = new Template(\n+ \"./test/stubs/posts/post1.njk\",\n+ \"./test/stubs/\",\n+ \"./dist\",\n+ dataObj\n+ );\n+\n+ let localDataPaths = tmpl.getLocalDataPaths();\n+ t.deepEqual(localDataPaths, [\n+ \"./test/stubs/posts/posts.json\",\n+ \"./test/stubs/posts/post1.json\"\n+ ]);\n+\n+ let localData = await dataObj.getLocalData(localDataPaths);\n+ t.is(localData.layout, \"mylocallayout.njk\");\n+ t.truthy(localData.pkg);\n+\n+ let data = await tmpl.getData();\n+ t.is(localData.layout, \"mylocallayout.njk\");\n+\n+ t.is(\n+ (await tmpl.render(data)).trim(),\n+ `<div id=\"locallayout\">Post1\n+</div>`\n+ );\n+});\n+\ntest(\"Clone the template\", async t => {\nlet tmpl = new Template(\n\"./test/stubs/default.ejs\",\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/_includes/mylocallayout.njk",
"diff": "+<div id=\"locallayout\">{{ content | safe }}</div>\n"
},
{
"change_type": "ADD",
"old_path": "test/stubs/firstdir/seconddir/component.njk",
"new_path": "test/stubs/firstdir/seconddir/component.njk",
"diff": ""
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/posts/post1.njk",
"diff": "+Post1\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/posts/posts.json",
"diff": "+{\n+ \"layout\": \"mylocallayout.njk\"\n+}\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Fixes #55 with local dir and template data files |
699 | 09.02.2018 12:24:28 | 0 | 7f8b020b5f853b01b6c168ba49ce14fd604ba5c4 | Adds additional test for uniqueness of template name and directory name automatic data imports. | [
{
"change_type": "MODIFY",
"old_path": "docs/data.md",
"new_path": "docs/data.md",
"diff": "@@ -61,8 +61,8 @@ _New in Eleventy v0.2.14_ While it is useful to have globally available data to\nFor example, consider a template located at `posts/my-first-blog-post.md`. Eleventy will look for data in the following places (starting with highest priority, local data keys override global data):\n-1. `posts/my-first-blog-post.json` (data only applied to `posts/my-first-blog-post.json`)\n-1. `posts/posts.json` (data applied to `posts/*`)\n+1. `posts/my-first-blog-post.json` (data only applied to `posts/my-first-blog-post.md`)\n+1. `posts/posts.json` (data applied to all templates `posts/*`)\n1. `_data/*` (global data files available to all templates)\n#### Apply a default layout to multiple templates\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateTest.js",
"new_path": "test/TemplateTest.js",
"diff": "@@ -449,6 +449,34 @@ test(\"Posts inherits local JSON, layouts\", async t => {\n);\n});\n+test(\"Template and folder name are the same, make sure data imports work ok\", async t => {\n+ let dataObj = new TemplateData();\n+ await dataObj.cacheData();\n+\n+ let tmpl = new Template(\n+ \"./test/stubs/posts/posts.njk\",\n+ \"./test/stubs/\",\n+ \"./dist\",\n+ dataObj\n+ );\n+\n+ let localDataPaths = tmpl.getLocalDataPaths();\n+ t.deepEqual(localDataPaths, [\"./test/stubs/posts/posts.json\"]);\n+\n+ let localData = await dataObj.getLocalData(localDataPaths);\n+ t.is(localData.layout, \"mylocallayout.njk\");\n+ t.truthy(localData.pkg);\n+\n+ let data = await tmpl.getData();\n+ t.is(localData.layout, \"mylocallayout.njk\");\n+\n+ t.is(\n+ (await tmpl.render(data)).trim(),\n+ `<div id=\"locallayout\">Posts\n+</div>`\n+ );\n+});\n+\ntest(\"Clone the template\", async t => {\nlet tmpl = new Template(\n\"./test/stubs/default.ejs\",\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/posts/posts.njk",
"diff": "+Posts\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Adds additional test for uniqueness of template name and directory name automatic data imports. |
699 | 10.02.2018 21:29:31 | 0 | 8548d54243720bae41cbddb82cc9aec78b1be40d | Better code coverage for Liquid.js | [
{
"change_type": "MODIFY",
"old_path": "test/TemplateConfigTest.js",
"new_path": "test/TemplateConfigTest.js",
"diff": "@@ -33,7 +33,7 @@ test(\"Template Config local config overrides base config\", async t => {\n});\ntest(\"Add liquid tag\", t => {\n- eleventyConfig.addLiquidTag(\"myTagName\", function() {}, function() {});\n+ eleventyConfig.addLiquidTag(\"myTagName\", function() {});\nlet templateCfg = new TemplateConfig(\nrequire(\"../config.js\"),\n@@ -44,7 +44,9 @@ test(\"Add liquid tag\", t => {\n});\ntest(\"Add liquid filter\", t => {\n- eleventyConfig.addLiquidFilter(\"myFilterName\", function() {});\n+ eleventyConfig.addLiquidFilter(\"myFilterName\", function(liquidEngine) {\n+ return {};\n+ });\nlet templateCfg = new TemplateConfig(\nrequire(\"../config.js\"),\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateRenderLiquidTest.js",
"new_path": "test/TemplateRenderLiquidTest.js",
"diff": "@@ -116,3 +116,32 @@ test(\"Liquid Custom Tag postfixWithZach\", async t => {\n\"testZach\"\n);\n});\n+\n+test(\"Liquid addTag errors\", async t => {\n+ let tr = new TemplateRender(\"liquid\", \"./test/stubs/\");\n+ t.throws(() => {\n+ tr.engine.addTag(\"badSecondArgument\", {});\n+ });\n+});\n+\n+test(\"Liquid addTags\", async t => {\n+ let tr = new TemplateRender(\"liquid\", \"./test/stubs/\");\n+ tr.engine.addTags({\n+ postfixWithZach: function(liquidEngine) {\n+ return {\n+ parse: function(tagToken, remainTokens) {\n+ this.str = tagToken.args;\n+ },\n+ render: function(scope, hash) {\n+ var str = liquidEngine.evalValue(this.str, scope);\n+ return Promise.resolve(str + \"Zach\");\n+ }\n+ };\n+ }\n+ });\n+\n+ t.is(\n+ await tr.render(\"{% postfixWithZach name %}\", { name: \"test\" }),\n+ \"testZach\"\n+ );\n+});\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Better code coverage for Liquid.js |
699 | 10.02.2018 21:32:00 | 0 | 813d3c43272956fbfc1ddcc50603c238e1f2b678 | New code coverage docs. | [
{
"change_type": "MODIFY",
"old_path": "docs-src/_data/coverage.json",
"new_path": "docs-src/_data/coverage.json",
"diff": "{\n\"total\": {\n- \"lines\": { \"total\": 1164, \"covered\": 1018, \"skipped\": 0, \"pct\": 87.46 },\n+ \"lines\": { \"total\": 1336, \"covered\": 1170, \"skipped\": 0, \"pct\": 87.57 },\n\"statements\": {\n- \"total\": 1164,\n- \"covered\": 1018,\n+ \"total\": 1337,\n+ \"covered\": 1171,\n\"skipped\": 0,\n- \"pct\": 87.46\n+ \"pct\": 87.58\n},\n- \"functions\": { \"total\": 257, \"covered\": 217, \"skipped\": 0, \"pct\": 84.44 },\n- \"branches\": { \"total\": 335, \"covered\": 274, \"skipped\": 0, \"pct\": 81.79 }\n+ \"functions\": { \"total\": 285, \"covered\": 241, \"skipped\": 0, \"pct\": 84.56 },\n+ \"branches\": { \"total\": 409, \"covered\": 337, \"skipped\": 0, \"pct\": 82.4 }\n},\n\"/Users/zachleat/Code/eleventy/config.js\": {\n\"lines\": { \"total\": 6, \"covered\": 6, \"skipped\": 0, \"pct\": 100 },\n\"branches\": { \"total\": 0, \"covered\": 0, \"skipped\": 0, \"pct\": 100 }\n},\n\"/Users/zachleat/Code/eleventy/src/Eleventy.js\": {\n- \"lines\": { \"total\": 124, \"covered\": 76, \"skipped\": 0, \"pct\": 61.29 },\n+ \"lines\": { \"total\": 129, \"covered\": 76, \"skipped\": 0, \"pct\": 58.91 },\n\"functions\": { \"total\": 19, \"covered\": 7, \"skipped\": 0, \"pct\": 36.84 },\n- \"statements\": { \"total\": 124, \"covered\": 76, \"skipped\": 0, \"pct\": 61.29 },\n- \"branches\": { \"total\": 26, \"covered\": 10, \"skipped\": 0, \"pct\": 38.46 }\n+ \"statements\": { \"total\": 129, \"covered\": 76, \"skipped\": 0, \"pct\": 58.91 },\n+ \"branches\": { \"total\": 28, \"covered\": 10, \"skipped\": 0, \"pct\": 35.71 }\n},\n\"/Users/zachleat/Code/eleventy/src/EleventyConfig.js\": {\n- \"lines\": { \"total\": 33, \"covered\": 30, \"skipped\": 0, \"pct\": 90.91 },\n- \"functions\": { \"total\": 13, \"covered\": 11, \"skipped\": 0, \"pct\": 84.62 },\n- \"statements\": { \"total\": 33, \"covered\": 30, \"skipped\": 0, \"pct\": 90.91 },\n- \"branches\": { \"total\": 4, \"covered\": 3, \"skipped\": 0, \"pct\": 75 }\n+ \"lines\": { \"total\": 53, \"covered\": 41, \"skipped\": 0, \"pct\": 77.36 },\n+ \"functions\": { \"total\": 16, \"covered\": 11, \"skipped\": 0, \"pct\": 68.75 },\n+ \"statements\": { \"total\": 53, \"covered\": 41, \"skipped\": 0, \"pct\": 77.36 },\n+ \"branches\": { \"total\": 18, \"covered\": 11, \"skipped\": 0, \"pct\": 61.11 }\n},\n\"/Users/zachleat/Code/eleventy/src/EleventyError.js\": {\n\"lines\": { \"total\": 12, \"covered\": 12, \"skipped\": 0, \"pct\": 100 },\n\"branches\": { \"total\": 2, \"covered\": 2, \"skipped\": 0, \"pct\": 100 }\n},\n\"/Users/zachleat/Code/eleventy/src/Template.js\": {\n- \"lines\": { \"total\": 195, \"covered\": 168, \"skipped\": 0, \"pct\": 86.15 },\n- \"functions\": { \"total\": 41, \"covered\": 34, \"skipped\": 0, \"pct\": 82.93 },\n- \"statements\": { \"total\": 195, \"covered\": 168, \"skipped\": 0, \"pct\": 86.15 },\n- \"branches\": { \"total\": 74, \"covered\": 57, \"skipped\": 0, \"pct\": 77.03 }\n+ \"lines\": { \"total\": 227, \"covered\": 205, \"skipped\": 0, \"pct\": 90.31 },\n+ \"functions\": { \"total\": 39, \"covered\": 34, \"skipped\": 0, \"pct\": 87.18 },\n+ \"statements\": { \"total\": 227, \"covered\": 205, \"skipped\": 0, \"pct\": 90.31 },\n+ \"branches\": { \"total\": 89, \"covered\": 73, \"skipped\": 0, \"pct\": 82.02 }\n},\n- \"/Users/zachleat/Code/eleventy/src/TemplateCollection.js\": {\n- \"lines\": { \"total\": 13, \"covered\": 12, \"skipped\": 0, \"pct\": 92.31 },\n+ \"/Users/zachleat/Code/eleventy/src/TemplateCache.js\": {\n+ \"lines\": { \"total\": 9, \"covered\": 9, \"skipped\": 0, \"pct\": 100 },\n\"functions\": { \"total\": 6, \"covered\": 6, \"skipped\": 0, \"pct\": 100 },\n- \"statements\": { \"total\": 13, \"covered\": 12, \"skipped\": 0, \"pct\": 92.31 },\n- \"branches\": { \"total\": 6, \"covered\": 5, \"skipped\": 0, \"pct\": 83.33 }\n+ \"statements\": { \"total\": 9, \"covered\": 9, \"skipped\": 0, \"pct\": 100 },\n+ \"branches\": { \"total\": 2, \"covered\": 2, \"skipped\": 0, \"pct\": 100 }\n+ },\n+ \"/Users/zachleat/Code/eleventy/src/TemplateCollection.js\": {\n+ \"lines\": { \"total\": 23, \"covered\": 21, \"skipped\": 0, \"pct\": 91.3 },\n+ \"functions\": { \"total\": 10, \"covered\": 9, \"skipped\": 0, \"pct\": 90 },\n+ \"statements\": { \"total\": 24, \"covered\": 22, \"skipped\": 0, \"pct\": 91.67 },\n+ \"branches\": { \"total\": 10, \"covered\": 8, \"skipped\": 0, \"pct\": 80 }\n},\n\"/Users/zachleat/Code/eleventy/src/TemplateConfig.js\": {\n\"lines\": { \"total\": 43, \"covered\": 39, \"skipped\": 0, \"pct\": 90.7 },\n\"branches\": { \"total\": 14, \"covered\": 13, \"skipped\": 0, \"pct\": 92.86 }\n},\n\"/Users/zachleat/Code/eleventy/src/TemplateData.js\": {\n- \"lines\": { \"total\": 70, \"covered\": 69, \"skipped\": 0, \"pct\": 98.57 },\n- \"functions\": { \"total\": 13, \"covered\": 13, \"skipped\": 0, \"pct\": 100 },\n- \"statements\": { \"total\": 70, \"covered\": 69, \"skipped\": 0, \"pct\": 98.57 },\n- \"branches\": { \"total\": 12, \"covered\": 9, \"skipped\": 0, \"pct\": 75 }\n+ \"lines\": { \"total\": 95, \"covered\": 94, \"skipped\": 0, \"pct\": 98.95 },\n+ \"functions\": { \"total\": 16, \"covered\": 16, \"skipped\": 0, \"pct\": 100 },\n+ \"statements\": { \"total\": 95, \"covered\": 94, \"skipped\": 0, \"pct\": 98.95 },\n+ \"branches\": { \"total\": 22, \"covered\": 18, \"skipped\": 0, \"pct\": 81.82 }\n},\n\"/Users/zachleat/Code/eleventy/src/TemplateGlob.js\": {\n\"lines\": { \"total\": 16, \"covered\": 15, \"skipped\": 0, \"pct\": 93.75 },\n\"branches\": { \"total\": 8, \"covered\": 7, \"skipped\": 0, \"pct\": 87.5 }\n},\n\"/Users/zachleat/Code/eleventy/src/TemplateLayout.js\": {\n- \"lines\": { \"total\": 39, \"covered\": 38, \"skipped\": 0, \"pct\": 97.44 },\n+ \"lines\": { \"total\": 38, \"covered\": 37, \"skipped\": 0, \"pct\": 97.37 },\n\"functions\": { \"total\": 7, \"covered\": 7, \"skipped\": 0, \"pct\": 100 },\n- \"statements\": { \"total\": 39, \"covered\": 38, \"skipped\": 0, \"pct\": 97.44 },\n+ \"statements\": { \"total\": 38, \"covered\": 37, \"skipped\": 0, \"pct\": 97.37 },\n\"branches\": { \"total\": 16, \"covered\": 15, \"skipped\": 0, \"pct\": 93.75 }\n},\n\"/Users/zachleat/Code/eleventy/src/TemplateMap.js\": {\n- \"lines\": { \"total\": 66, \"covered\": 64, \"skipped\": 0, \"pct\": 96.97 },\n+ \"lines\": { \"total\": 67, \"covered\": 65, \"skipped\": 0, \"pct\": 97.01 },\n\"functions\": { \"total\": 12, \"covered\": 12, \"skipped\": 0, \"pct\": 100 },\n- \"statements\": { \"total\": 66, \"covered\": 64, \"skipped\": 0, \"pct\": 96.97 },\n+ \"statements\": { \"total\": 67, \"covered\": 65, \"skipped\": 0, \"pct\": 97.01 },\n\"branches\": { \"total\": 10, \"covered\": 8, \"skipped\": 0, \"pct\": 80 }\n},\n\"/Users/zachleat/Code/eleventy/src/TemplatePassthrough.js\": {\n- \"lines\": { \"total\": 9, \"covered\": 7, \"skipped\": 0, \"pct\": 77.78 },\n+ \"lines\": { \"total\": 8, \"covered\": 7, \"skipped\": 0, \"pct\": 87.5 },\n\"functions\": { \"total\": 3, \"covered\": 2, \"skipped\": 0, \"pct\": 66.67 },\n- \"statements\": { \"total\": 9, \"covered\": 7, \"skipped\": 0, \"pct\": 77.78 },\n+ \"statements\": { \"total\": 8, \"covered\": 7, \"skipped\": 0, \"pct\": 87.5 },\n\"branches\": { \"total\": 0, \"covered\": 0, \"skipped\": 0, \"pct\": 100 }\n},\n\"/Users/zachleat/Code/eleventy/src/TemplatePath.js\": {\n- \"lines\": { \"total\": 31, \"covered\": 31, \"skipped\": 0, \"pct\": 100 },\n- \"functions\": { \"total\": 10, \"covered\": 9, \"skipped\": 0, \"pct\": 90 },\n- \"statements\": { \"total\": 31, \"covered\": 31, \"skipped\": 0, \"pct\": 100 },\n- \"branches\": { \"total\": 13, \"covered\": 13, \"skipped\": 0, \"pct\": 100 }\n+ \"lines\": { \"total\": 38, \"covered\": 38, \"skipped\": 0, \"pct\": 100 },\n+ \"functions\": { \"total\": 11, \"covered\": 10, \"skipped\": 0, \"pct\": 90.91 },\n+ \"statements\": { \"total\": 38, \"covered\": 38, \"skipped\": 0, \"pct\": 100 },\n+ \"branches\": { \"total\": 17, \"covered\": 17, \"skipped\": 0, \"pct\": 100 }\n},\n\"/Users/zachleat/Code/eleventy/src/TemplatePermalink.js\": {\n\"lines\": { \"total\": 31, \"covered\": 31, \"skipped\": 0, \"pct\": 100 },\n\"functions\": { \"total\": 7, \"covered\": 7, \"skipped\": 0, \"pct\": 100 },\n\"statements\": { \"total\": 31, \"covered\": 31, \"skipped\": 0, \"pct\": 100 },\n- \"branches\": { \"total\": 18, \"covered\": 18, \"skipped\": 0, \"pct\": 100 }\n+ \"branches\": { \"total\": 20, \"covered\": 20, \"skipped\": 0, \"pct\": 100 }\n},\n\"/Users/zachleat/Code/eleventy/src/TemplateRender.js\": {\n- \"lines\": { \"total\": 37, \"covered\": 36, \"skipped\": 0, \"pct\": 97.3 },\n- \"functions\": { \"total\": 9, \"covered\": 9, \"skipped\": 0, \"pct\": 100 },\n- \"statements\": { \"total\": 37, \"covered\": 36, \"skipped\": 0, \"pct\": 97.3 },\n- \"branches\": { \"total\": 14, \"covered\": 12, \"skipped\": 0, \"pct\": 85.71 }\n+ \"lines\": { \"total\": 79, \"covered\": 78, \"skipped\": 0, \"pct\": 98.73 },\n+ \"functions\": { \"total\": 17, \"covered\": 17, \"skipped\": 0, \"pct\": 100 },\n+ \"statements\": { \"total\": 79, \"covered\": 78, \"skipped\": 0, \"pct\": 98.73 },\n+ \"branches\": { \"total\": 34, \"covered\": 32, \"skipped\": 0, \"pct\": 94.12 }\n},\n\"/Users/zachleat/Code/eleventy/src/TemplateWriter.js\": {\n- \"lines\": { \"total\": 143, \"covered\": 103, \"skipped\": 0, \"pct\": 72.03 },\n- \"functions\": { \"total\": 25, \"covered\": 15, \"skipped\": 0, \"pct\": 60 },\n- \"statements\": { \"total\": 143, \"covered\": 103, \"skipped\": 0, \"pct\": 72.03 },\n- \"branches\": { \"total\": 30, \"covered\": 19, \"skipped\": 0, \"pct\": 63.33 }\n+ \"lines\": { \"total\": 160, \"covered\": 108, \"skipped\": 0, \"pct\": 67.5 },\n+ \"functions\": { \"total\": 27, \"covered\": 15, \"skipped\": 0, \"pct\": 55.56 },\n+ \"statements\": { \"total\": 160, \"covered\": 108, \"skipped\": 0, \"pct\": 67.5 },\n+ \"branches\": { \"total\": 34, \"covered\": 21, \"skipped\": 0, \"pct\": 61.76 }\n},\n\"/Users/zachleat/Code/eleventy/src/Engines/Ejs.js\": {\n\"lines\": { \"total\": 6, \"covered\": 6, \"skipped\": 0, \"pct\": 100 },\n\"branches\": { \"total\": 2, \"covered\": 2, \"skipped\": 0, \"pct\": 100 }\n},\n\"/Users/zachleat/Code/eleventy/src/Engines/Liquid.js\": {\n- \"lines\": { \"total\": 23, \"covered\": 21, \"skipped\": 0, \"pct\": 91.3 },\n+ \"lines\": { \"total\": 23, \"covered\": 23, \"skipped\": 0, \"pct\": 100 },\n\"functions\": { \"total\": 7, \"covered\": 7, \"skipped\": 0, \"pct\": 100 },\n- \"statements\": { \"total\": 23, \"covered\": 21, \"skipped\": 0, \"pct\": 91.3 },\n- \"branches\": { \"total\": 2, \"covered\": 1, \"skipped\": 0, \"pct\": 50 }\n+ \"statements\": { \"total\": 23, \"covered\": 23, \"skipped\": 0, \"pct\": 100 },\n+ \"branches\": { \"total\": 2, \"covered\": 2, \"skipped\": 0, \"pct\": 100 }\n},\n\"/Users/zachleat/Code/eleventy/src/Engines/Markdown.js\": {\n\"lines\": { \"total\": 16, \"covered\": 16, \"skipped\": 0, \"pct\": 100 },\n\"branches\": { \"total\": 0, \"covered\": 0, \"skipped\": 0, \"pct\": 100 }\n},\n\"/Users/zachleat/Code/eleventy/src/Engines/Nunjucks.js\": {\n- \"lines\": { \"total\": 13, \"covered\": 13, \"skipped\": 0, \"pct\": 100 },\n- \"functions\": { \"total\": 4, \"covered\": 4, \"skipped\": 0, \"pct\": 100 },\n- \"statements\": { \"total\": 13, \"covered\": 13, \"skipped\": 0, \"pct\": 100 },\n- \"branches\": { \"total\": 0, \"covered\": 0, \"skipped\": 0, \"pct\": 100 }\n+ \"lines\": { \"total\": 18, \"covered\": 17, \"skipped\": 0, \"pct\": 94.44 },\n+ \"functions\": { \"total\": 6, \"covered\": 6, \"skipped\": 0, \"pct\": 100 },\n+ \"statements\": { \"total\": 18, \"covered\": 17, \"skipped\": 0, \"pct\": 94.44 },\n+ \"branches\": { \"total\": 2, \"covered\": 1, \"skipped\": 0, \"pct\": 50 }\n},\n\"/Users/zachleat/Code/eleventy/src/Engines/Pug.js\": {\n\"lines\": { \"total\": 4, \"covered\": 4, \"skipped\": 0, \"pct\": 100 },\n\"branches\": { \"total\": 0, \"covered\": 0, \"skipped\": 0, \"pct\": 100 }\n},\n\"/Users/zachleat/Code/eleventy/src/Engines/TemplateEngine.js\": {\n- \"lines\": { \"total\": 31, \"covered\": 30, \"skipped\": 0, \"pct\": 96.77 },\n- \"functions\": { \"total\": 9, \"covered\": 8, \"skipped\": 0, \"pct\": 88.89 },\n- \"statements\": { \"total\": 31, \"covered\": 30, \"skipped\": 0, \"pct\": 96.77 },\n+ \"lines\": { \"total\": 31, \"covered\": 31, \"skipped\": 0, \"pct\": 100 },\n+ \"functions\": { \"total\": 9, \"covered\": 9, \"skipped\": 0, \"pct\": 100 },\n+ \"statements\": { \"total\": 31, \"covered\": 31, \"skipped\": 0, \"pct\": 100 },\n\"branches\": { \"total\": 6, \"covered\": 6, \"skipped\": 0, \"pct\": 100 }\n},\n\"/Users/zachleat/Code/eleventy/src/Filters/Slug.js\": {\n\"lines\": { \"total\": 18, \"covered\": 18, \"skipped\": 0, \"pct\": 100 },\n\"functions\": { \"total\": 1, \"covered\": 1, \"skipped\": 0, \"pct\": 100 },\n\"statements\": { \"total\": 18, \"covered\": 18, \"skipped\": 0, \"pct\": 100 },\n- \"branches\": { \"total\": 26, \"covered\": 26, \"skipped\": 0, \"pct\": 100 }\n+ \"branches\": { \"total\": 21, \"covered\": 21, \"skipped\": 0, \"pct\": 100 }\n},\n\"/Users/zachleat/Code/eleventy/src/Plugins/Pagination.js\": {\n\"lines\": { \"total\": 76, \"covered\": 71, \"skipped\": 0, \"pct\": 93.42 },\n\"branches\": { \"total\": 2, \"covered\": 2, \"skipped\": 0, \"pct\": 100 }\n},\n\"/Users/zachleat/Code/eleventy/src/Util/Sortable.js\": {\n- \"lines\": { \"total\": 45, \"covered\": 39, \"skipped\": 0, \"pct\": 86.67 },\n- \"functions\": { \"total\": 21, \"covered\": 16, \"skipped\": 0, \"pct\": 76.19 },\n- \"statements\": { \"total\": 45, \"covered\": 39, \"skipped\": 0, \"pct\": 86.67 },\n+ \"lines\": { \"total\": 46, \"covered\": 39, \"skipped\": 0, \"pct\": 84.78 },\n+ \"functions\": { \"total\": 22, \"covered\": 16, \"skipped\": 0, \"pct\": 72.73 },\n+ \"statements\": { \"total\": 46, \"covered\": 39, \"skipped\": 0, \"pct\": 84.78 },\n\"branches\": { \"total\": 18, \"covered\": 17, \"skipped\": 0, \"pct\": 94.44 }\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "docs/coverage.md",
"new_path": "docs/coverage.md",
"diff": "-# Code Coverage for Eleventy v0.2.11\n+# Code Coverage for Eleventy v0.2.14\n| Filename | % Lines | % Statements | % Functions | % Branches |\n| ------------------------------- | ------- | ------------ | ----------- | ---------- |\n-| `total` | 87.46% | 87.46% | 84.44% | 81.79% |\n+| `total` | 87.57% | 87.58% | 84.56% | 82.4% |\n| `config.js` | 100% | 100% | 100% | 100% |\n| `src/Config.js` | 100% | 100% | 100% | 100% |\n-| `src/Eleventy.js` | 61.29% | 61.29% | 36.84% | 38.46% |\n-| `src/EleventyConfig.js` | 90.91% | 90.91% | 84.62% | 75% |\n+| `src/Eleventy.js` | 58.91% | 58.91% | 36.84% | 35.71% |\n+| `src/EleventyConfig.js` | 77.36% | 77.36% | 68.75% | 61.11% |\n| `src/EleventyError.js` | 100% | 100% | 100% | 100% |\n-| `src/Template.js` | 86.15% | 86.15% | 82.93% | 77.03% |\n-| `src/TemplateCollection.js` | 92.31% | 92.31% | 100% | 83.33% |\n+| `src/Template.js` | 90.31% | 90.31% | 87.18% | 82.02% |\n+| `src/TemplateCache.js` | 100% | 100% | 100% | 100% |\n+| `src/TemplateCollection.js` | 91.3% | 91.67% | 90% | 80% |\n| `src/TemplateConfig.js` | 90.7% | 90.7% | 80% | 92.86% |\n-| `src/TemplateData.js` | 98.57% | 98.57% | 100% | 75% |\n+| `src/TemplateData.js` | 98.95% | 98.95% | 100% | 81.82% |\n| `src/TemplateGlob.js` | 93.75% | 93.75% | 100% | 87.5% |\n-| `src/TemplateLayout.js` | 97.44% | 97.44% | 100% | 93.75% |\n-| `src/TemplateMap.js` | 96.97% | 96.97% | 100% | 80% |\n-| `src/TemplatePassthrough.js` | 77.78% | 77.78% | 66.67% | 100% |\n-| `src/TemplatePath.js` | 100% | 100% | 90% | 100% |\n+| `src/TemplateLayout.js` | 97.37% | 97.37% | 100% | 93.75% |\n+| `src/TemplateMap.js` | 97.01% | 97.01% | 100% | 80% |\n+| `src/TemplatePassthrough.js` | 87.5% | 87.5% | 66.67% | 100% |\n+| `src/TemplatePath.js` | 100% | 100% | 90.91% | 100% |\n| `src/TemplatePermalink.js` | 100% | 100% | 100% | 100% |\n-| `src/TemplateRender.js` | 97.3% | 97.3% | 100% | 85.71% |\n-| `src/TemplateWriter.js` | 72.03% | 72.03% | 60% | 63.33% |\n+| `src/TemplateRender.js` | 98.73% | 98.73% | 100% | 94.12% |\n+| `src/TemplateWriter.js` | 67.5% | 67.5% | 55.56% | 61.76% |\n| `src/Engines/Ejs.js` | 100% | 100% | 100% | 100% |\n| `src/Engines/Haml.js` | 100% | 100% | 100% | 100% |\n| `src/Engines/Handlebars.js` | 100% | 100% | 100% | 100% |\n| `src/Engines/Html.js` | 100% | 100% | 100% | 100% |\n| `src/Engines/JavaScript.js` | 93.33% | 93.33% | 100% | 100% |\n-| `src/Engines/Liquid.js` | 91.3% | 91.3% | 100% | 50% |\n+| `src/Engines/Liquid.js` | 100% | 100% | 100% | 100% |\n| `src/Engines/Markdown.js` | 100% | 100% | 100% | 100% |\n| `src/Engines/Mustache.js` | 100% | 100% | 100% | 100% |\n-| `src/Engines/Nunjucks.js` | 100% | 100% | 100% | 100% |\n+| `src/Engines/Nunjucks.js` | 94.44% | 94.44% | 100% | 50% |\n| `src/Engines/Pug.js` | 100% | 100% | 100% | 100% |\n-| `src/Engines/TemplateEngine.js` | 96.77% | 96.77% | 88.89% | 100% |\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` | 93.42% | 93.42% | 100% | 87.5% |\n| `src/Util/Capitalize.js` | 100% | 100% | 100% | 100% |\n| `src/Util/Pluralize.js` | 100% | 100% | 100% | 100% |\n-| `src/Util/Sortable.js` | 86.67% | 86.67% | 76.19% | 94.44% |\n+| `src/Util/Sortable.js` | 84.78% | 84.78% | 72.73% | 94.44% |\n"
},
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "{\n\"name\": \"@11ty/eleventy\",\n- \"version\": \"0.2.13\",\n+ \"version\": \"0.2.14\",\n\"description\": \"Transform a directory of templates into HTML.\",\n\"main\": \"src/Eleventy.js\",\n\"license\": \"MIT\",\n"
}
] | JavaScript | MIT License | 11ty/eleventy | New code coverage docs. |
699 | 11.02.2018 17:39:51 | 0 | 629492a99b6032bd80be9cbb74469ed01b8fc264 | Adds `setTemplateFormats(string)` and `setTemplateFormats(array)` to configuration API. | [
{
"change_type": "MODIFY",
"old_path": "src/EleventyConfig.js",
"new_path": "src/EleventyConfig.js",
"diff": "@@ -142,19 +142,6 @@ class EleventyConfig {\nthis.collections[name] = callback;\n}\n- getMergingConfigObject() {\n- return {\n- liquidTags: this.liquidTags,\n- liquidFilters: this.liquidFilters,\n- nunjucksFilters: this.nunjucksFilters,\n- nunjucksAsyncFilters: this.nunjucksAsyncFilters,\n- handlebarsHelpers: this.handlebarsHelpers,\n- filters: this.filters,\n- layoutAliases: this.layoutAliases,\n- passthroughCopies: this.passthroughCopies\n- };\n- }\n-\naddPlugin(pluginCallback) {\nif (typeof pluginCallback !== \"function\") {\nthrow new Error(\n@@ -168,6 +155,28 @@ class EleventyConfig {\naddPassthroughCopy(fileOrDir) {\nthis.passthroughCopies[fileOrDir] = true;\n}\n+\n+ setTemplateFormats(templateFormats) {\n+ if (typeof templateFormats === \"string\") {\n+ templateFormats = templateFormats.split(\",\").map(format => format.trim());\n+ }\n+\n+ this.templateFormats = templateFormats;\n+ }\n+\n+ getMergingConfigObject() {\n+ return {\n+ liquidTags: this.liquidTags,\n+ liquidFilters: this.liquidFilters,\n+ nunjucksFilters: this.nunjucksFilters,\n+ nunjucksAsyncFilters: this.nunjucksAsyncFilters,\n+ handlebarsHelpers: this.handlebarsHelpers,\n+ filters: this.filters,\n+ layoutAliases: this.layoutAliases,\n+ passthroughCopies: this.passthroughCopies,\n+ templateFormats: this.templateFormats\n+ };\n+ }\n}\nlet config = new EleventyConfig();\n"
},
{
"change_type": "MODIFY",
"old_path": "test/EleventyConfigTest.js",
"new_path": "test/EleventyConfigTest.js",
"diff": "@@ -28,3 +28,13 @@ test(\"Add Collections throws error on key collision\", t => {\n) {});\n});\n});\n+\n+test(\"Set Template Formats (string)\", t => {\n+ eleventyConfig.setTemplateFormats(\"ejs, njk, liquid\");\n+ t.deepEqual(eleventyConfig.templateFormats, [\"ejs\", \"njk\", \"liquid\"]);\n+});\n+\n+test(\"Set Template Formats (array)\", t => {\n+ eleventyConfig.setTemplateFormats([\"ejs\", \"njk\", \"liquid\"]);\n+ t.deepEqual(eleventyConfig.templateFormats, [\"ejs\", \"njk\", \"liquid\"]);\n+});\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateConfigTest.js",
"new_path": "test/TemplateConfigTest.js",
"diff": "@@ -100,3 +100,47 @@ test(\"Test url universal filter with custom pathPrefix (no slash)\", t => {\nlet cfg = templateCfg.getConfig();\nt.is(cfg.pathPrefix, \"/testdirectory/\");\n});\n+\n+test(\"setTemplateFormats(string)\", t => {\n+ eleventyConfig.setTemplateFormats(\"ejs,njk, liquid\");\n+\n+ let templateCfg = new TemplateConfig(\n+ require(\"../config.js\"),\n+ \"./test/stubs/config.js\"\n+ );\n+ let cfg = templateCfg.getConfig();\n+ t.deepEqual(cfg.templateFormats, [\"ejs\", \"njk\", \"liquid\"]);\n+});\n+\n+test(\"setTemplateFormats(array)\", t => {\n+ eleventyConfig.setTemplateFormats([\"ejs\", \"njk\", \"liquid\"]);\n+\n+ let templateCfg = new TemplateConfig(\n+ require(\"../config.js\"),\n+ \"./test/stubs/config.js\"\n+ );\n+ let cfg = templateCfg.getConfig();\n+ t.deepEqual(cfg.templateFormats, [\"ejs\", \"njk\", \"liquid\"]);\n+});\n+\n+test(\"setTemplateFormats(array, size 1)\", t => {\n+ eleventyConfig.setTemplateFormats([\"liquid\"]);\n+\n+ let templateCfg = new TemplateConfig(\n+ require(\"../config.js\"),\n+ \"./test/stubs/config.js\"\n+ );\n+ let cfg = templateCfg.getConfig();\n+ t.deepEqual(cfg.templateFormats, [\"liquid\"]);\n+});\n+\n+test(\"setTemplateFormats(empty array)\", t => {\n+ eleventyConfig.setTemplateFormats([]);\n+\n+ let templateCfg = new TemplateConfig(\n+ require(\"../config.js\"),\n+ \"./test/stubs/config.js\"\n+ );\n+ let cfg = templateCfg.getConfig();\n+ t.deepEqual(cfg.templateFormats, []);\n+});\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Adds `setTemplateFormats(string)` and `setTemplateFormats(array)` to configuration API. |
699 | 16.02.2018 08:26:40 | 21,600 | 7ff37c2157aef548062268f95bde5323701a0d2c | More tests for engine overrides. | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/_includes/layouts/engineOverridesMd.njk",
"diff": "+---\n+layoutkey: layoutvalue\n+---\n+# Layout header\n+\n+<div id=\"{{layoutkey}}\">{{ content | safe }}</div>\n\\ No newline at end of file\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/overrides/test.md",
"diff": "+---\n+title: My Title\n+layout: layouts/engineOverridesMd.njk\n+---\n+\n+# {{ title }}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/overrides/test2.md",
"diff": "+---\n+title: My Title\n+templateEngineOverride: ejs,md\n+layout: layouts/engineOverridesMd.njk\n+---\n+\n+# <%= title %>\n"
}
] | JavaScript | MIT License | 11ty/eleventy | More tests for engine overrides. |
699 | 16.02.2018 08:58:25 | 21,600 | 6eb6b66722aacefa7e64a09323e7cfa219936dad | Code coverage. | [
{
"change_type": "MODIFY",
"old_path": "docs-src/_data/coverage.json",
"new_path": "docs-src/_data/coverage.json",
"diff": "{\n\"total\": {\n- \"lines\": { \"total\": 1336, \"covered\": 1170, \"skipped\": 0, \"pct\": 87.57 },\n+ \"lines\": { \"total\": 1354, \"covered\": 1177, \"skipped\": 0, \"pct\": 86.93 },\n\"statements\": {\n- \"total\": 1337,\n- \"covered\": 1171,\n+ \"total\": 1356,\n+ \"covered\": 1179,\n\"skipped\": 0,\n- \"pct\": 87.58\n+ \"pct\": 86.95\n},\n- \"functions\": { \"total\": 285, \"covered\": 241, \"skipped\": 0, \"pct\": 84.56 },\n- \"branches\": { \"total\": 409, \"covered\": 337, \"skipped\": 0, \"pct\": 82.4 }\n+ \"functions\": { \"total\": 287, \"covered\": 243, \"skipped\": 0, \"pct\": 84.67 },\n+ \"branches\": { \"total\": 417, \"covered\": 341, \"skipped\": 0, \"pct\": 81.77 }\n},\n\"/Users/zachleat/Code/eleventy/config.js\": {\n\"lines\": { \"total\": 6, \"covered\": 6, \"skipped\": 0, \"pct\": 100 },\n\"branches\": { \"total\": 0, \"covered\": 0, \"skipped\": 0, \"pct\": 100 }\n},\n\"/Users/zachleat/Code/eleventy/src/Eleventy.js\": {\n- \"lines\": { \"total\": 129, \"covered\": 76, \"skipped\": 0, \"pct\": 58.91 },\n+ \"lines\": { \"total\": 140, \"covered\": 76, \"skipped\": 0, \"pct\": 54.29 },\n\"functions\": { \"total\": 19, \"covered\": 7, \"skipped\": 0, \"pct\": 36.84 },\n- \"statements\": { \"total\": 129, \"covered\": 76, \"skipped\": 0, \"pct\": 58.91 },\n- \"branches\": { \"total\": 28, \"covered\": 10, \"skipped\": 0, \"pct\": 35.71 }\n+ \"statements\": { \"total\": 140, \"covered\": 76, \"skipped\": 0, \"pct\": 54.29 },\n+ \"branches\": { \"total\": 32, \"covered\": 10, \"skipped\": 0, \"pct\": 31.25 }\n},\n\"/Users/zachleat/Code/eleventy/src/EleventyConfig.js\": {\n- \"lines\": { \"total\": 53, \"covered\": 41, \"skipped\": 0, \"pct\": 77.36 },\n- \"functions\": { \"total\": 16, \"covered\": 11, \"skipped\": 0, \"pct\": 68.75 },\n- \"statements\": { \"total\": 53, \"covered\": 41, \"skipped\": 0, \"pct\": 77.36 },\n- \"branches\": { \"total\": 18, \"covered\": 11, \"skipped\": 0, \"pct\": 61.11 }\n+ \"lines\": { \"total\": 56, \"covered\": 44, \"skipped\": 0, \"pct\": 78.57 },\n+ \"functions\": { \"total\": 18, \"covered\": 13, \"skipped\": 0, \"pct\": 72.22 },\n+ \"statements\": { \"total\": 57, \"covered\": 45, \"skipped\": 0, \"pct\": 78.95 },\n+ \"branches\": { \"total\": 20, \"covered\": 13, \"skipped\": 0, \"pct\": 65 }\n},\n\"/Users/zachleat/Code/eleventy/src/EleventyError.js\": {\n\"lines\": { \"total\": 12, \"covered\": 12, \"skipped\": 0, \"pct\": 100 },\n\"branches\": { \"total\": 2, \"covered\": 2, \"skipped\": 0, \"pct\": 100 }\n},\n\"/Users/zachleat/Code/eleventy/src/Template.js\": {\n- \"lines\": { \"total\": 227, \"covered\": 205, \"skipped\": 0, \"pct\": 90.31 },\n+ \"lines\": { \"total\": 228, \"covered\": 206, \"skipped\": 0, \"pct\": 90.35 },\n\"functions\": { \"total\": 39, \"covered\": 34, \"skipped\": 0, \"pct\": 87.18 },\n- \"statements\": { \"total\": 227, \"covered\": 205, \"skipped\": 0, \"pct\": 90.31 },\n+ \"statements\": { \"total\": 228, \"covered\": 206, \"skipped\": 0, \"pct\": 90.35 },\n\"branches\": { \"total\": 89, \"covered\": 73, \"skipped\": 0, \"pct\": 82.02 }\n},\n\"/Users/zachleat/Code/eleventy/src/TemplateCache.js\": {\n\"branches\": { \"total\": 10, \"covered\": 8, \"skipped\": 0, \"pct\": 80 }\n},\n\"/Users/zachleat/Code/eleventy/src/TemplateConfig.js\": {\n- \"lines\": { \"total\": 43, \"covered\": 39, \"skipped\": 0, \"pct\": 90.7 },\n+ \"lines\": { \"total\": 46, \"covered\": 42, \"skipped\": 0, \"pct\": 91.3 },\n\"functions\": { \"total\": 5, \"covered\": 4, \"skipped\": 0, \"pct\": 80 },\n- \"statements\": { \"total\": 43, \"covered\": 39, \"skipped\": 0, \"pct\": 90.7 },\n- \"branches\": { \"total\": 14, \"covered\": 13, \"skipped\": 0, \"pct\": 92.86 }\n+ \"statements\": { \"total\": 46, \"covered\": 42, \"skipped\": 0, \"pct\": 91.3 },\n+ \"branches\": { \"total\": 16, \"covered\": 15, \"skipped\": 0, \"pct\": 93.75 }\n},\n\"/Users/zachleat/Code/eleventy/src/TemplateData.js\": {\n\"lines\": { \"total\": 95, \"covered\": 94, \"skipped\": 0, \"pct\": 98.95 },\n"
},
{
"change_type": "MODIFY",
"old_path": "docs/coverage.md",
"new_path": "docs/coverage.md",
"diff": "| Filename | % Lines | % Statements | % Functions | % Branches |\n| ------------------------------- | ------- | ------------ | ----------- | ---------- |\n-| `total` | 87.57% | 87.58% | 84.56% | 82.4% |\n+| `total` | 86.93% | 86.95% | 84.67% | 81.77% |\n| `config.js` | 100% | 100% | 100% | 100% |\n| `src/Config.js` | 100% | 100% | 100% | 100% |\n-| `src/Eleventy.js` | 58.91% | 58.91% | 36.84% | 35.71% |\n-| `src/EleventyConfig.js` | 77.36% | 77.36% | 68.75% | 61.11% |\n+| `src/Eleventy.js` | 54.29% | 54.29% | 36.84% | 31.25% |\n+| `src/EleventyConfig.js` | 78.57% | 78.95% | 72.22% | 65% |\n| `src/EleventyError.js` | 100% | 100% | 100% | 100% |\n-| `src/Template.js` | 90.31% | 90.31% | 87.18% | 82.02% |\n+| `src/Template.js` | 90.35% | 90.35% | 87.18% | 82.02% |\n| `src/TemplateCache.js` | 100% | 100% | 100% | 100% |\n| `src/TemplateCollection.js` | 91.3% | 91.67% | 90% | 80% |\n-| `src/TemplateConfig.js` | 90.7% | 90.7% | 80% | 92.86% |\n+| `src/TemplateConfig.js` | 91.3% | 91.3% | 80% | 93.75% |\n| `src/TemplateData.js` | 98.95% | 98.95% | 100% | 81.82% |\n| `src/TemplateGlob.js` | 93.75% | 93.75% | 100% | 87.5% |\n| `src/TemplateLayout.js` | 97.37% | 97.37% | 100% | 93.75% |\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Code coverage. |
699 | 20.02.2018 09:20:14 | 21,600 | 6b9d97db21df62cf30ad0f2bb6cef5b6e862b943 | Adds `setPugOptions` to configuration API. Also adds default `filename` option to pug compile for relative includes. Fixes | [
{
"change_type": "MODIFY",
"old_path": "src/EleventyConfig.js",
"new_path": "src/EleventyConfig.js",
"diff": "@@ -164,6 +164,10 @@ class EleventyConfig {\nthis.templateFormats = templateFormats;\n}\n+ setPugOptions(options) {\n+ this.pugOptions = options;\n+ }\n+\ngetMergingConfigObject() {\nreturn {\nliquidTags: this.liquidTags,\n@@ -174,7 +178,8 @@ class EleventyConfig {\nfilters: this.filters,\nlayoutAliases: this.layoutAliases,\npassthroughCopies: this.passthroughCopies,\n- templateFormats: this.templateFormats\n+ templateFormats: this.templateFormats,\n+ pugOptions: this.pugOptions\n};\n}\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\");\n+const config = require(\"../Config\");\nclass Pug extends TemplateEngine {\n+ constructor(name, inputDir) {\n+ super(name, inputDir);\n+\n+ this.config = config.getConfig();\n+ this.pugOptions = this.config.pugOptions;\n+ }\n+\n+ setPugOptions(options) {\n+ this.pugOptions = options;\n+ }\n+\n+ getPugOptions() {\n+ let inputDir = super.getInputDir();\n+\n+ return lodashMerge(\n+ {\n+ basedir: inputDir,\n+ filename: inputDir\n+ },\n+ this.pugOptions || {}\n+ );\n+ }\n+\nasync compile(str) {\n- return PugLib.compile(str, {\n- basedir: super.getInputDir()\n- });\n+ let options = this.getPugOptions();\n+\n+ return PugLib.compile(str, options);\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Engines/TemplateEngine.js",
"new_path": "src/Engines/TemplateEngine.js",
"diff": "@@ -15,9 +15,11 @@ class TemplateEngine {\ngetName() {\nreturn this.name;\n}\n+\ngetInputDir() {\nreturn this.inputDir;\n}\n+\ngetPartials() {\nif (!this.partialsHaveBeenCached) {\nthis.partials = this.cachePartialFiles();\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateRenderPugTest.js",
"new_path": "test/TemplateRenderPugTest.js",
"diff": "import test from \"ava\";\nimport TemplateRender from \"../src/TemplateRender\";\nimport path from \"path\";\n+import eleventyConfig from \"../src/EleventyConfig\";\n+import config from \"../src/Config\";\n// Pug\ntest(\"Pug\", t => {\n@@ -12,7 +14,7 @@ test(\"Pug Render\", async t => {\nt.is(await fn({ name: \"Zach\" }), \"<p>Zach</p>\");\n});\n-test(\"Pug Render Include\", async t => {\n+test(\"Pug Render Include (Absolute)\", async t => {\nlet fn = await new TemplateRender(\"pug\", \"./test/stubs/\")\n.getCompiledTemplate(`p\ninclude /included.pug`);\n@@ -42,3 +44,18 @@ block content\nh1= name`);\nt.is(await fn({ name: \"Zach\" }), \"<html><body><h1>Zach</h1></body></html>\");\n});\n+\n+test(\"Pug Render Include (Relative)\", async t => {\n+ let fn = await new TemplateRender(\"pug\", \"./test/stubs/\")\n+ .getCompiledTemplate(`p\n+ include _includes/included.pug`);\n+ t.is(await fn({ name: \"Zach\" }), \"<p><span>This is an include.</span></p>\");\n+});\n+\n+test(\"Pug Options Overrides\", async t => {\n+ let tr = new TemplateRender(\"pug\", \"./test/stubs/\");\n+ tr.engine.setPugOptions({ testoption: \"testoverride\" });\n+\n+ let options = tr.engine.getPugOptions();\n+ t.is(options.testoption, \"testoverride\");\n+});\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Adds `setPugOptions` to configuration API. Also adds default `filename` option to pug compile for relative includes. Fixes #60 |
699 | 03.03.2018 13:49:40 | 21,600 | 4ecde353179e8104e257492e90e9d9a14e517cdd | Short-term workaround for | [
{
"change_type": "MODIFY",
"old_path": "src/EleventyConfig.js",
"new_path": "src/EleventyConfig.js",
"diff": "@@ -10,12 +10,14 @@ class EleventyConfig {\nthis.events = new EventEmitter();\nthis.collections = {};\n+ this.liquidOptions = {};\nthis.liquidTags = {};\nthis.liquidFilters = {};\nthis.nunjucksFilters = {};\nthis.nunjucksAsyncFilters = {};\nthis.handlebarsHelpers = {};\nthis.passthroughCopies = {};\n+ this.pugOptions = {};\nthis.layoutAliases = {};\n@@ -168,8 +170,13 @@ class EleventyConfig {\nthis.pugOptions = options;\n}\n+ setLiquidOptions(options) {\n+ this.liquidOptions = options;\n+ }\n+\ngetMergingConfigObject() {\nreturn {\n+ liquidOptions: this.liquidOptions,\nliquidTags: this.liquidTags,\nliquidFilters: this.liquidFilters,\nnunjucksFilters: this.nunjucksFilters,\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\");\nconst debug = require(\"debug\")(\"Eleventy:Liquid\");\n@@ -8,13 +9,10 @@ class Liquid extends TemplateEngine {\nsuper(name, inputDir);\nthis.config = config.getConfig();\n+ this.liquidOptions = this.config.liquidOptions;\n// warning, the include syntax supported here does not match what jekyll uses.\n- this.liquidEngine = LiquidLib({\n- root: [super.getInputDir()],\n- extname: \".liquid\",\n- dynamicPartials: false\n- });\n+ this.liquidEngine = LiquidLib(this.getLiquidOptions());\nthis.addTags(this.config.liquidTags);\n// debug( \"Adding %o liquid tags\", Object.keys(this.config.liquidTags).length);\n@@ -23,6 +21,22 @@ class Liquid extends TemplateEngine {\n// debug( \"Adding %o liquid filters\", Object.keys(this.config.liquidFilters).length);\n}\n+ setLiquidOptions(options) {\n+ this.liquidOptions = options;\n+\n+ this.liquidEngine = LiquidLib(this.getLiquidOptions());\n+ }\n+\n+ getLiquidOptions() {\n+ let defaults = {\n+ root: [super.getInputDir()],\n+ extname: \".liquid\",\n+ dynamicPartials: false\n+ };\n+\n+ return lodashMerge(defaults, this.liquidOptions || {});\n+ }\n+\naddTags(tags) {\nfor (let name in tags) {\nthis.addTag(name, tags[name]);\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateRenderLiquidTest.js",
"new_path": "test/TemplateRenderLiquidTest.js",
"diff": "@@ -145,3 +145,145 @@ test(\"Liquid addTags\", async t => {\n\"testZach\"\n);\n});\n+\n+/* Skipped tests pending https://github.com/harttle/liquidjs/issues/61 */\n+test.skip(\"Liquid Render Include Subfolder\", async t => {\n+ let fn = await new TemplateRender(\n+ \"liquid\",\n+ \"./test/stubs/\"\n+ ).getCompiledTemplate(`<p>{% include subfolder/included.liquid %}</p>`);\n+ t.is(await fn(), \"<p>This is an include.</p>\");\n+});\n+\n+test.skip(\"Liquid Render Include Subfolder Single quotes\", async t => {\n+ let fn = await new TemplateRender(\n+ \"liquid\",\n+ \"./test/stubs/\"\n+ ).getCompiledTemplate(`<p>{% include 'subfolder/included.liquid' %}</p>`);\n+ t.is(await fn(), \"<p>This is an include.</p>\");\n+});\n+\n+test.skip(\"Liquid Render Include Subfolder Double quotes\", async t => {\n+ let fn = await new TemplateRender(\n+ \"liquid\",\n+ \"./test/stubs/\"\n+ ).getCompiledTemplate(`<p>{% include \"subfolder/included.liquid\" %}</p>`);\n+ t.is(await fn(), \"<p>This is an include.</p>\");\n+});\n+\n+test.skip(\"Liquid Render Include Subfolder HTML\", async t => {\n+ let fn = await new TemplateRender(\n+ \"liquid\",\n+ \"./test/stubs/\"\n+ ).getCompiledTemplate(`<p>{% include subfolder/included.html %}</p>`);\n+ t.is(await fn(), \"<p>This is an include.</p>\");\n+});\n+\n+test.skip(\"Liquid Render Include Subfolder Single quotes HTML\", async t => {\n+ let fn = await new TemplateRender(\n+ \"liquid\",\n+ \"./test/stubs/\"\n+ ).getCompiledTemplate(`<p>{% include 'subfolder/included.html' %}</p>`);\n+ t.is(await fn(), \"<p>This is an include.</p>\");\n+});\n+\n+test.skip(\"Liquid Render Include Subfolder Double quotes HTML\", async t => {\n+ let fn = await new TemplateRender(\n+ \"liquid\",\n+ \"./test/stubs/\"\n+ ).getCompiledTemplate(`<p>{% include \"subfolder/included.html\" %}</p>`);\n+ t.is(await fn(), \"<p>This is an include.</p>\");\n+});\n+\n+test.skip(\"Liquid Render Include Subfolder No file extension\", async t => {\n+ let fn = await new TemplateRender(\n+ \"liquid\",\n+ \"./test/stubs/\"\n+ ).getCompiledTemplate(`<p>{% include subfolder/included %}</p>`);\n+ t.is(await fn(), \"<p>This is an include.</p>\");\n+});\n+\n+test.skip(\"Liquid Render Include Subfolder Single quotes No file extension\", async t => {\n+ let fn = await new TemplateRender(\n+ \"liquid\",\n+ \"./test/stubs/\"\n+ ).getCompiledTemplate(`<p>{% include 'subfolder/included' %}</p>`);\n+ t.is(await fn(), \"<p>This is an include.</p>\");\n+});\n+\n+test.skip(\"Liquid Render Include Subfolder Double quotes No file extension\", async t => {\n+ let fn = await new TemplateRender(\n+ \"liquid\",\n+ \"./test/stubs/\"\n+ ).getCompiledTemplate(`<p>{% include \"subfolder/included\" %}</p>`);\n+ t.is(await fn(), \"<p>This is an include.</p>\");\n+});\n+/* End skipped tests */\n+\n+test(\"Liquid Options Overrides\", async t => {\n+ let tr = new TemplateRender(\"liquid\", \"./test/stubs/\");\n+ tr.engine.setLiquidOptions({ dynamicPartials: true });\n+\n+ let options = tr.engine.getLiquidOptions();\n+ t.is(options.dynamicPartials, true);\n+});\n+\n+test(\"Liquid Render Include Subfolder Single quotes no extension dynamicPartials true\", async t => {\n+ let tr = new TemplateRender(\"liquid\", \"./test/stubs/\");\n+ tr.engine.setLiquidOptions({ dynamicPartials: true });\n+\n+ let fn = await tr.getCompiledTemplate(\n+ `<p>{% include 'subfolder/included' %}</p>`\n+ );\n+ t.is(await fn(), \"<p>This is an include.</p>\");\n+});\n+\n+test(\"Liquid Render Include Subfolder Double quotes no extension dynamicPartials true\", async t => {\n+ let tr = new TemplateRender(\"liquid\", \"./test/stubs/\");\n+ tr.engine.setLiquidOptions({ dynamicPartials: true });\n+\n+ let fn = await tr.getCompiledTemplate(\n+ `<p>{% include \"subfolder/included\" %}</p>`\n+ );\n+ t.is(await fn(), \"<p>This is an include.</p>\");\n+});\n+\n+test(\"Liquid Render Include Subfolder Single quotes dynamicPartials true\", async t => {\n+ let tr = new TemplateRender(\"liquid\", \"./test/stubs/\");\n+ tr.engine.setLiquidOptions({ dynamicPartials: true });\n+\n+ let fn = await tr.getCompiledTemplate(\n+ `<p>{% include 'subfolder/included.liquid' %}</p>`\n+ );\n+ t.is(await fn(), \"<p>This is an include.</p>\");\n+});\n+\n+test(\"Liquid Render Include Subfolder Double quotes dynamicPartials true\", async t => {\n+ let tr = new TemplateRender(\"liquid\", \"./test/stubs/\");\n+ tr.engine.setLiquidOptions({ dynamicPartials: true });\n+\n+ let fn = await tr.getCompiledTemplate(\n+ `<p>{% include \"subfolder/included.liquid\" %}</p>`\n+ );\n+ t.is(await fn(), \"<p>This is an include.</p>\");\n+});\n+\n+test(\"Liquid Render Include Subfolder Single quotes HTML dynamicPartials true\", async t => {\n+ let tr = new TemplateRender(\"liquid\", \"./test/stubs/\");\n+ tr.engine.setLiquidOptions({ dynamicPartials: true });\n+\n+ let fn = await tr.getCompiledTemplate(\n+ `<p>{% include 'subfolder/included.html' %}</p>`\n+ );\n+ t.is(await fn(), \"<p>This is an include.</p>\");\n+});\n+\n+test(\"Liquid Render Include Subfolder Double quotes HTML dynamicPartials true\", async t => {\n+ let tr = new TemplateRender(\"liquid\", \"./test/stubs/\");\n+ tr.engine.setLiquidOptions({ dynamicPartials: true });\n+\n+ let fn = await tr.getCompiledTemplate(\n+ `<p>{% include \"subfolder/included.html\" %}</p>`\n+ );\n+ t.is(await fn(), \"<p>This is an include.</p>\");\n+});\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateRenderNunjucksTest.js",
"new_path": "test/TemplateRenderNunjucksTest.js",
"diff": "@@ -28,6 +28,13 @@ test(\"Nunjucks Render Include\", async t => {\nt.is(await fn(), \"<p>This is an include.</p>\");\n});\n+test(\"Nunjucks Render Include Subfolder\", async t => {\n+ let fn = await new TemplateRender(\"njk\", \"test/stubs\").getCompiledTemplate(\n+ \"<p>{% include 'subfolder/included.html' %}</p>\"\n+ );\n+ t.is(await fn(), \"<p>This is an include.</p>\");\n+});\n+\ntest(\"Nunjucks Render Imports\", async t => {\nlet fn = await new TemplateRender(\"njk\", \"test/stubs\").getCompiledTemplate(\n\"{% import 'imports.njk' as forms %}<div>{{ forms.label('Name') }}</div>\"\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/_includes/subfolder/included.html",
"diff": "+This is an include.\n\\ No newline at end of file\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/_includes/subfolder/included.liquid",
"diff": "+This is an include.\n\\ No newline at end of file\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Short-term workaround for #72. |
699 | 05.03.2018 07:45:50 | 21,600 | 1cae9f8207181873d1b5089380c042a3d180f44d | Use `page.date` to set permalink with date variables. Related to | [
{
"change_type": "MODIFY",
"old_path": "docs/collections.md",
"new_path": "docs/collections.md",
"diff": "@@ -125,7 +125,7 @@ Valid `date` values:\nIf a `date` key is omitted from the file, the date is assumed to be:\n-1. If the file name matches `YYYY-MM-DD`, this date is used.\n+1. If the file name has a `YYYY-MM-DD` format (anywhere), this date is used.\n1. File creation date.\n## Advanced: Custom Filtering and Sorting\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Template.js",
"new_path": "src/Template.js",
"diff": "@@ -84,12 +84,22 @@ class Template {\nlet permalink = this.getFrontMatterData()[this.config.keys.permalink];\nif (permalink) {\nlet data = await this.getData();\n- // debug(\"Rendering permalink for %o\", this.inputPath);\n- let perm = new TemplatePermalink(\n+\n// render variables inside permalink front matter, bypass markdown\n- await this.renderContent(permalink, data, true),\n+ let permalinkValue = await this.renderContent(permalink, data, true);\n+ debug(\n+ \"Rendering permalink for %o: %s becomes %o\",\n+ this.inputPath,\n+ permalink,\n+ permalinkValue\n+ );\n+ debugDev(\"Permalink rendered with data: %o\", data);\n+\n+ let perm = new TemplatePermalink(\n+ permalinkValue,\nthis.extraOutputSubdirectory\n);\n+\nreturn perm;\n}\n@@ -228,6 +238,7 @@ class Template {\n}\nasync getData(localData) {\n+ if (!this.data) {\ndebugDev(\"%o getData()\", this.inputPath);\nlet data = {};\n@@ -235,8 +246,6 @@ class Template {\ndata = await this.templateData.getLocalData(this.getLocalDataPaths());\n}\n- let mergedLocalData = Object.assign({}, localData, this.dataOverrides);\n-\nlet frontMatterData = this.getFrontMatterData();\nlet mergedLayoutData = await this.getAllLayoutFrontMatterData(\n@@ -244,7 +253,29 @@ class Template {\nfrontMatterData\n);\n- return Object.assign({}, data, mergedLayoutData, mergedLocalData);\n+ let mergedData = Object.assign({}, data, mergedLayoutData);\n+ mergedData = await this.addPageDate(mergedData);\n+\n+ this.data = mergedData;\n+ }\n+\n+ return Object.assign({}, this.data, localData, this.dataOverrides);\n+ }\n+\n+ async addPageDate(data) {\n+ if (!(\"page\" in data)) {\n+ data.page = {};\n+ }\n+\n+ if (\"page\" in data && \"date\" in data.page) {\n+ debug(\n+ \"Warning: data.page.date is in use by the application will be overwritten: %o\",\n+ data.page.date\n+ );\n+ }\n+ data.page.date = await this.getMappedDate(data);\n+\n+ return data;\n}\nasync addPageData(data) {\n@@ -258,16 +289,9 @@ class Template {\ndata.page.url\n);\n}\n- if (\"page\" in data && \"date\" in data.page) {\n- debug(\n- \"Warning: data.page.date is in use by the application will be overwritten: %o\",\n- data.page.date\n- );\n- }\n- data.page.url = await this.getOutputHref();\n- data.page.date = await this.getMappedDate(data);\ndata.page.inputPath = this.inputPath;\n+ data.page.url = await this.getOutputHref();\ndata.page.outputPath = await this.getOutputPath();\n}\n@@ -503,6 +527,7 @@ class Template {\n);\nif (data.date instanceof Date) {\n// YAML does its own date parsing\n+ debug(\"getMappedDate: YAML parsed it: %o\", data.date);\nreturn data.date;\n} else {\n// string\n@@ -520,6 +545,12 @@ class Template {\n}`\n);\n}\n+ debug(\n+ \"getMappedDate: Luxon parsed %o: %o and %o\",\n+ data.date,\n+ date,\n+ date.toJSDate()\n+ );\nreturn date.toJSDate();\n}\n@@ -527,12 +558,14 @@ class Template {\n} else {\nlet filenameRegex = this.inputPath.match(/(\\d{4}-\\d{2}-\\d{2})/);\nif (filenameRegex !== null) {\n+ let dateObj = DateTime.fromISO(filenameRegex[1]).toJSDate();\ndebug(\n- \"getMappedDate: using filename regex time for %o of %o\",\n+ \"getMappedDate: using filename regex time for %o of %o: %o\",\nthis.inputPath,\n- filenameRegex[1]\n+ filenameRegex[1],\n+ dateObj\n);\n- return DateTime.fromISO(filenameRegex[1]).toJSDate();\n+ return dateObj;\n}\nlet createdDate = new Date(stat.birthtimeMs);\n@@ -558,19 +591,17 @@ class Template {\nasync getMapped() {\ndebugDev(\"%o getMapped()\", this.inputPath);\n- let outputPath = await this.getOutputPath();\n- let url = await this.getOutputHref();\nlet data = await this.getRenderedData();\nlet map = {\ntemplate: this,\n- inputPath: this.getInputPath(),\n- outputPath: outputPath,\n- url: url,\n+ inputPath: this.inputPath,\ndata: data\n};\n// we can reuse the mapped date stored in the data obj\nmap.date = data.page.date;\n+ map.url = data.page.url;\n+ map.outputPath = data.page.outputPath;\nreturn map;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateTest.js",
"new_path": "test/TemplateTest.js",
"diff": "@@ -501,6 +501,26 @@ test(\"Permalink with variables!\", async t => {\nt.is(await tmpl.getOutputPath(), \"./dist/subdir/slug-candidate/index.html\");\n});\n+test(\"Permalink with dates!\", async t => {\n+ let tmpl = new Template(\n+ \"./test/stubs/permalinkdate.liquid\",\n+ \"./test/stubs/\",\n+ \"./dist\"\n+ );\n+\n+ t.is(await tmpl.getOutputPath(), \"./dist/2016/01/01/index.html\");\n+});\n+\n+test(\"Permalink with dates on file name regex!\", async t => {\n+ let tmpl = new Template(\n+ \"./test/stubs/2016-02-01-permalinkdate.liquid\",\n+ \"./test/stubs/\",\n+ \"./dist\"\n+ );\n+\n+ t.is(await tmpl.getOutputPath(), \"./dist/2016/02/01/index.html\");\n+});\n+\ntest(\"mapDataAsRenderedTemplates\", async t => {\nlet tmpl = new Template(\n\"./test/stubs/default.ejs\",\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/2016-02-01-permalinkdate.liquid",
"diff": "+---\n+title: Date Permalink\n+permalink: \"/{{ page.date | date: '%Y/%m/%d' }}/index.html\"\n+---\n+Date Permalinks\n\\ No newline at end of file\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/permalinkdate.liquid",
"diff": "+---\n+title: Date Permalink\n+date: \"2016-01-01T06:00-06:00\"\n+permalink: \"/{{ page.date | date: '%Y/%m/%d' }}/index.html\"\n+---\n+Date Permalinks\n\\ No newline at end of file\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Use `page.date` to set permalink with date variables. Related to #68 https://github.com/11ty/eleventy/issues/68#issuecomment-370175964 |
699 | 05.03.2018 17:29:54 | 21,600 | e54c9e676531a588e44a49764616147b7be7d6d5 | Move getLocalDataPaths from Template to TemplateData where it belongs. | [
{
"change_type": "MODIFY",
"old_path": "src/Template.js",
"new_path": "src/Template.js",
"diff": "@@ -191,25 +191,6 @@ class Template {\nreturn merged;\n}\n- getLocalDataPaths() {\n- let paths = [];\n-\n- if (this.parsed.dir) {\n- let lastDir = TemplatePath.getLastDir(this.parsed.dir);\n- let dirPath = this.parsed.dir + \"/\" + lastDir + \".json\";\n- let filePath = this.parsed.dir + \"/\" + this.parsed.name + \".json\";\n-\n- paths.push(dirPath);\n-\n- // unique\n- if (filePath !== dirPath) {\n- paths.push(filePath);\n- }\n- }\n-\n- return paths;\n- }\n-\nasync mapDataAsRenderedTemplates(data, templateData) {\nif (Array.isArray(data)) {\nlet arr = [];\n@@ -242,7 +223,7 @@ class Template {\nlet data = {};\nif (this.templateData) {\n- data = await this.templateData.getLocalData(this.getLocalDataPaths());\n+ data = await this.templateData.getLocalData(this.inputPath);\n}\nlet frontMatterData = this.getFrontMatterData();\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateData.js",
"new_path": "src/TemplateData.js",
"diff": "@@ -128,7 +128,8 @@ TemplateData.prototype.combineLocalData = async function(localDataPaths) {\nreturn localData;\n};\n-TemplateData.prototype.getLocalData = async function(localDataPaths) {\n+TemplateData.prototype.getLocalData = async function(templatePath) {\n+ let localDataPaths = this.getLocalDataPaths(templatePath);\nlet importedData = await this.combineLocalData(localDataPaths);\nlet globalData = await this.getData();\n@@ -182,4 +183,24 @@ TemplateData.prototype.getJson = async function(\nreturn {};\n};\n+TemplateData.prototype.getLocalDataPaths = function(templatePath) {\n+ let paths = [];\n+ let parsed = parsePath(templatePath);\n+\n+ if (parsed.dir) {\n+ let lastDir = TemplatePath.getLastDir(parsed.dir);\n+ let dirPath = parsed.dir + \"/\" + lastDir + \".json\";\n+ let filePath = parsed.dir + \"/\" + parsed.name + \".json\";\n+\n+ paths.push(dirPath);\n+\n+ // unique\n+ if (filePath !== dirPath) {\n+ paths.push(filePath);\n+ }\n+ }\n+\n+ return paths;\n+};\n+\nmodule.exports = TemplateData;\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateTest.js",
"new_path": "test/TemplateTest.js",
"diff": "@@ -394,7 +394,7 @@ test(\"Local template data file import (without a global data json)\", async t =>\n);\nlet data = await tmpl.getData();\n- t.deepEqual(tmpl.getLocalDataPaths(), [\n+ t.deepEqual(dataObj.getLocalDataPaths(tmpl.getInputPath()), [\n\"./test/stubs/component/component.json\"\n]);\nt.is(data.localdatakey1, \"localdatavalue1\");\n@@ -412,7 +412,7 @@ test(\"Local template data file import (two subdirectories deep)\", async t => {\ndataObj\n);\n- t.deepEqual(tmpl.getLocalDataPaths(), [\n+ t.deepEqual(dataObj.getLocalDataPaths(tmpl.getInputPath()), [\n\"./test/stubs/firstdir/seconddir/seconddir.json\",\n\"./test/stubs/firstdir/seconddir/component.json\"\n]);\n@@ -429,13 +429,13 @@ test(\"Posts inherits local JSON, layouts\", async t => {\ndataObj\n);\n- let localDataPaths = tmpl.getLocalDataPaths();\n+ let localDataPaths = dataObj.getLocalDataPaths(tmpl.getInputPath());\nt.deepEqual(localDataPaths, [\n\"./test/stubs/posts/posts.json\",\n\"./test/stubs/posts/post1.json\"\n]);\n- let localData = await dataObj.getLocalData(localDataPaths);\n+ let localData = await dataObj.getLocalData(tmpl.getInputPath());\nt.is(localData.layout, \"mylocallayout.njk\");\nt.truthy(localData.pkg);\n@@ -460,10 +460,10 @@ test(\"Template and folder name are the same, make sure data imports work ok\", as\ndataObj\n);\n- let localDataPaths = tmpl.getLocalDataPaths();\n+ let localDataPaths = dataObj.getLocalDataPaths(tmpl.getInputPath());\nt.deepEqual(localDataPaths, [\"./test/stubs/posts/posts.json\"]);\n- let localData = await dataObj.getLocalData(localDataPaths);\n+ let localData = await dataObj.getLocalData(tmpl.getInputPath());\nt.is(localData.layout, \"mylocallayout.njk\");\nt.truthy(localData.pkg);\n"
},
{
"change_type": "ADD",
"old_path": "test/stubs/datafiledoesnotexist/template.njk",
"new_path": "test/stubs/datafiledoesnotexist/template.njk",
"diff": ""
}
] | JavaScript | MIT License | 11ty/eleventy | Move getLocalDataPaths from Template to TemplateData where it belongs. |
699 | 05.03.2018 17:30:25 | 21,600 | 410602e30df9e1b4c1a7b9f675c0b7d9e1359dbf | Adds more tests for liquid includes (data passed in on dynamic partials) | [
{
"change_type": "MODIFY",
"old_path": "test/TemplateRenderLiquidTest.js",
"new_path": "test/TemplateRenderLiquidTest.js",
"diff": "@@ -57,17 +57,6 @@ test(\"Liquid Render Include with HTML Suffix and Data Pass in\", async t => {\nt.is((await fn()).trim(), \"This is an include. myValue\");\n});\n-// This is an upstream limitation of the Liquid implementation\n-// test(\"Liquid Render Include No Quotes\", async t => {\n-// t.is(new TemplateRender(\"liquid\", \"./test/stubs/\").getEngineName(), \"liquid\");\n-\n-// let fn = await new TemplateRender(\n-// \"liquid\",\n-// \"./test/stubs/\"\n-// ).getCompiledTemplate(\"<p>{% include included.liquid %}</p>\");\n-// t.is(await fn(), \"<p>This is an include.</p>\");\n-// });\n-\ntest(\"Liquid Custom Filter\", async t => {\nlet tr = new TemplateRender(\"liquid\", \"./test/stubs/\");\ntr.engine.addFilter(\"prefixWithZach\", function(val) {\n@@ -287,3 +276,23 @@ test(\"Liquid Render Include Subfolder Double quotes HTML dynamicPartials true\",\n);\nt.is(await fn(), \"<p>This is an include.</p>\");\n});\n+\n+test(\"Liquid Render Include Subfolder Single quotes HTML dynamicPartials true, data passed in\", async t => {\n+ let tr = new TemplateRender(\"liquid\", \"./test/stubs/\");\n+ tr.engine.setLiquidOptions({ dynamicPartials: true });\n+\n+ let fn = await tr.getCompiledTemplate(\n+ `<p>{% include 'subfolder/included.html', myVariable: 'myValue' %}</p>`\n+ );\n+ t.is(await fn(), \"<p>This is an include.</p>\");\n+});\n+\n+test(\"Liquid Render Include Subfolder Double quotes HTML dynamicPartials true, data passed in\", async t => {\n+ let tr = new TemplateRender(\"liquid\", \"./test/stubs/\");\n+ tr.engine.setLiquidOptions({ dynamicPartials: true });\n+\n+ let fn = await tr.getCompiledTemplate(\n+ `<p>{% include \"subfolder/included.html\", myVariable: \"myValue\" %}</p>`\n+ );\n+ t.is(await fn(), \"<p>This is an include.</p>\");\n+});\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Adds more tests for liquid includes (data passed in on dynamic partials) |
699 | 09.03.2018 21:58:23 | 21,600 | 9a9cf10e669c846583e0445fbfbdd21fac25b1af | Adds --dryrun to run through eleventy without writing files. | [
{
"change_type": "MODIFY",
"old_path": "cmd.js",
"new_path": "cmd.js",
"diff": "@@ -18,12 +18,14 @@ EleventyNodeVersionCheck().then(function() {\n(argv.pathprefix ? \" --pathprefix=\" + argv.pathprefix : \"\") +\n(argv.quiet ? \" --quiet\" : \"\") +\n(argv.version ? \" --version\" : \"\") +\n- (argv.watch ? \" --watch\" : \"\")\n+ (argv.watch ? \" --watch\" : \"\") +\n+ (argv.dryrun ? \" --dryrun\" : \"\")\n);\nlet elev = new Eleventy(argv.input, argv.output);\nelev.setConfigPath(argv.config);\nelev.setPathPrefix(argv.pathprefix);\n+ elev.setDryRun(argv.dryrun);\nelev.setFormats(argv.formats);\nif (process.env.DEBUG) {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Template.js",
"new_path": "src/Template.js",
"diff": "@@ -59,6 +59,7 @@ class Template {\nthis.parsed.name === \"index\";\nthis.isVerbose = true;\n+ this.isDryRun = false;\nthis.writeCount = 0;\nthis.initialLayout = undefined;\nthis.wrapWithLayouts = true;\n@@ -72,6 +73,10 @@ class Template {\nthis.isVerbose = isVerbose;\n}\n+ setDryRun(isDryRun) {\n+ this.isDryRun = !!isDryRun;\n+ }\n+\nsetWrapWithLayouts(wrap) {\nthis.wrapWithLayouts = wrap;\n}\n@@ -257,6 +262,7 @@ class Template {\ndata.page.date\n);\n}\n+\ndata.page.date = await this.getMappedDate(data);\nreturn data;\n@@ -469,12 +475,15 @@ class Template {\n// debug(`Template.write: ${outputPath}\n// ${finalContent}`);\nthis.writeCount++;\n+ if (!this.isDryRun) {\nawait pify(fs.outputFile)(outputPath, finalContent);\n+ }\n+ let writeDesc = this.isDryRun ? \"Pretending to write\" : \"Writing\";\nif (this.isVerbose) {\n- console.log(`Writing ${outputPath} from ${this.inputPath}.`);\n+ console.log(`${writeDesc} ${outputPath} from ${this.inputPath}.`);\n} else {\n- debug(\"Writing %o from %o.\", outputPath, this.inputPath);\n+ debug(`${writeDesc} %o from %o.`, outputPath, this.inputPath);\n}\n} else {\ndebug(\n@@ -492,6 +501,7 @@ class Template {\nthis.templateData\n);\ntmpl.setIsVerbose(this.isVerbose);\n+ tmpl.setDryRun(this.isDryRun);\nreturn tmpl;\n}\n@@ -562,8 +572,6 @@ class Template {\n// CREATED\nreturn createdDate;\n}\n-\n- return date;\n}\nasync isEqual(compareTo) {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplatePassthrough.js",
"new_path": "src/TemplatePassthrough.js",
"diff": "@@ -6,12 +6,17 @@ class TemplatePassthrough {\nconstructor(inputPath, outputDir) {\nthis.path = inputPath;\nthis.outputDir = outputDir;\n+ this.isDryRun = false;\n}\ngetOutputPath() {\nreturn TemplatePath.normalize(this.outputDir, this.path);\n}\n+ setDryRun(isDryRun) {\n+ this.isDryRun = !!isDryRun;\n+ }\n+\nasync write() {\n// debug(\n// `${this.path} has no TemplateEngine engine and will copy to ${\n@@ -19,8 +24,10 @@ class TemplatePassthrough {\n// }`\n// );\n+ if (!this.isDryRun) {\nreturn fs.copy(this.path, this.getOutputPath());\n}\n}\n+}\nmodule.exports = TemplatePassthrough;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateWriter.js",
"new_path": "src/TemplateWriter.js",
"diff": "@@ -23,6 +23,7 @@ function TemplateWriter(inputPath, outputDir, extensions, templateData) {\nthis.outputDir = outputDir;\nthis.templateData = templateData;\nthis.isVerbose = true;\n+ this.isDryRun = false;\nthis.writeCount = 0;\nthis.copyCount = 0;\n@@ -174,6 +175,7 @@ TemplateWriter.prototype._getTemplate = function(path) {\n);\ntmpl.setIsVerbose(this.isVerbose);\n+ tmpl.setDryRun(this.isDryRun);\n/*\n* Sample filter: arg str, return pretty HTML string\n@@ -205,6 +207,7 @@ TemplateWriter.prototype._getTemplate = function(path) {\nTemplateWriter.prototype._copyPassthroughPath = async function(path) {\nlet pass = new TemplatePassthrough(path, this.outputDir);\n+ pass.setDryRun(this.isDryRun);\ntry {\nawait pass.write();\ndebugDev(\"Copied %o\", path);\n@@ -294,6 +297,10 @@ TemplateWriter.prototype.setVerboseOutput = function(isVerbose) {\nthis.isVerbose = isVerbose;\n};\n+TemplateWriter.prototype.setDryRun = function(isDryRun) {\n+ this.isDryRun = !!isDryRun;\n+};\n+\nTemplateWriter.prototype.getCopyCount = function() {\nreturn this.copyCount;\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplatePassthroughTest.js",
"new_path": "test/TemplatePassthroughTest.js",
"diff": "@@ -6,3 +6,9 @@ test(\"Constructor\", t => {\nt.truthy(pass);\nt.is(pass.getOutputPath(), \"_site/avatar.png\");\n});\n+\n+test(\"Constructor Dry Run\", t => {\n+ let pass = new TemplatePassthrough(\"avatar.png\", \"_site\");\n+ pass.setDryRun(true);\n+ t.is(pass.isDryRun, true);\n+});\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Adds --dryrun to run through eleventy without writing files. |
669 | 16.03.2018 09:53:00 | -3,600 | 9a923640bac12f6c09363af52154927578e1ea25 | Make EleventyConfig.addPassthroughCopy chainable | [
{
"change_type": "MODIFY",
"old_path": "src/EleventyConfig.js",
"new_path": "src/EleventyConfig.js",
"diff": "@@ -154,8 +154,19 @@ class EleventyConfig {\npluginCallback(this);\n}\n+ /**\n+ * Adds a path to a file or directory to the list of pass-through copies\n+ * which are copied as-is to the output.\n+ *\n+ * @param {String} fileOrDir The path to the file or directory that should\n+ * be copied.\n+ * @returns {any} a reference to the `EleventyConfig` object.\n+ * @memberof EleventyConfig\n+ */\naddPassthroughCopy(fileOrDir) {\nthis.passthroughCopies[fileOrDir] = true;\n+\n+ return this;\n}\nsetTemplateFormats(templateFormats) {\n"
},
{
"change_type": "MODIFY",
"old_path": "test/EleventyConfigTest.js",
"new_path": "test/EleventyConfigTest.js",
"diff": "@@ -29,6 +29,19 @@ test(\"Add Collections throws error on key collision\", t => {\n});\n});\n+test(\"Set manual Pass-through File Copy (single call)\", t => {\n+ eleventyConfig.addPassthroughCopy(\"img\");\n+\n+ t.is(eleventyConfig.passthroughCopies[\"img\"], true);\n+});\n+\n+test(\"Set manual Pass-through File Copy (chained calls)\", t => {\n+ eleventyConfig.addPassthroughCopy(\"css\").addPassthroughCopy(\"js\");\n+\n+ t.is(eleventyConfig.passthroughCopies[\"css\"], true);\n+ t.is(eleventyConfig.passthroughCopies[\"js\"], true);\n+});\n+\ntest(\"Set Template Formats (string)\", t => {\neleventyConfig.setTemplateFormats(\"ejs, njk, liquid\");\nt.deepEqual(eleventyConfig.templateFormats, [\"ejs\", \"njk\", \"liquid\"]);\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Make EleventyConfig.addPassthroughCopy chainable |
699 | 26.03.2018 08:47:35 | 18,000 | 315e4907946650f7fd26402ce39de26bf6690c80 | Upgrades a bunch of dependencies. | [
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"devDependencies\": {\n\"ava\": \"^0.25.0\",\n\"husky\": \"^0.14.3\",\n- \"lint-staged\": \"^6.0.0\",\n+ \"lint-staged\": \"^7.0.0\",\n\"markdown-it-emoji\": \"^1.4.0\",\n- \"nyc\": \"^11.4.1\",\n- \"prettier\": \"1.9.1\"\n+ \"nyc\": \"^11.6.0\",\n+ \"prettier\": \"1.11.1\"\n},\n\"dependencies\": {\n- \"chalk\": \"^2.3.0\",\n- \"check-node-version\": \"^3.1.1\",\n+ \"chalk\": \"^2.3.2\",\n+ \"check-node-version\": \"^3.2.0\",\n\"debug\": \"^3.1.0\",\n- \"ejs\": \"^2.5.7\",\n- \"fs-extra\": \"^4.0.2\",\n- \"glob-watcher\": \"^4.0.0\",\n+ \"ejs\": \"^2.5.8\",\n+ \"fs-extra\": \"^5.0.0\",\n+ \"glob-watcher\": \"^5.0.1\",\n\"globby\": \"^7.1.1\",\n\"gray-matter\": \"^3.1.1\",\n\"hamljs\": \"^0.6.2\",\n\"lodash.clonedeep\": \"^4.5.0\",\n\"lodash.get\": \"^4.4.2\",\n\"lodash.isobject\": \"^3.0.2\",\n- \"lodash.merge\": \"^4.6.0\",\n+ \"lodash.merge\": \"^4.6.1\",\n\"lodash.set\": \"^4.3.2\",\n\"lodash.uniq\": \"^4.5.0\",\n- \"luxon\": \"^0.2.12\",\n- \"markdown-it\": \"^8.4.0\",\n+ \"luxon\": \"^1.0.0\",\n+ \"markdown-it\": \"^8.4.1\",\n\"minimist\": \"^1.2.0\",\n\"multimatch\": \"^2.1.0\",\n\"mustache\": \"^2.3.0\",\n\"normalize-path\": \"^2.1.1\",\n- \"nunjucks\": \"^3.0.1\",\n- \"parse-filepath\": \"^1.0.1\",\n+ \"nunjucks\": \"^3.1.2\",\n+ \"parse-filepath\": \"^1.0.2\",\n\"pify\": \"^3.0.0\",\n\"pretty\": \"^2.0.0\",\n- \"pug\": \"^2.0.0-rc.4\",\n- \"slugify\": \"^1.2.7\",\n+ \"pug\": \"^2.0.3\",\n+ \"slugify\": \"^1.2.9\",\n\"time-require\": \"^0.1.2\",\n\"valid-url\": \"^1.0.9\"\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateGlob.js",
"new_path": "src/TemplateGlob.js",
"diff": "-const globby = require(\"globby\");\nconst TemplatePath = require(\"./TemplatePath\");\nclass TemplateGlob {\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateTest.js",
"new_path": "test/TemplateTest.js",
"diff": "import test from \"ava\";\n-import { DateTime } from \"luxon\";\nimport TemplateData from \"../src/TemplateData\";\nimport Template from \"../src/Template\";\nimport pretty from \"pretty\";\n-import normalize from \"normalize-path\";\nimport templateConfig from \"../src/Config\";\nconst config = templateConfig.getConfig();\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Upgrades a bunch of dependencies. |
699 | 26.03.2018 21:34:15 | 18,000 | a80f5dbec9421e4b58d1d6515be55ab81a06e6b1 | Add collections.all refs to tests for | [
{
"change_type": "MODIFY",
"old_path": "test/TemplateWriterTest.js",
"new_path": "test/TemplateWriterTest.js",
"diff": "@@ -304,6 +304,7 @@ test(\"Use a collection inside of a template\", async t => {\nTemplate\n+All 2 templates\nTemplate 1 dog`\n);\n});\n@@ -344,6 +345,7 @@ test(\"Use a collection inside of a layout\", async t => {\nTemplate\n+All 2 templates\nLayout 1 dog`\n);\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "test/stubs/collection-layout/_includes/layout.ejs",
"new_path": "test/stubs/collection-layout/_includes/layout.ejs",
"diff": "@@ -2,4 +2,5 @@ Layout\n<%- content %>\n+All <%= collections.all.length %> templates\nLayout <%= collections.dog.length %> dog\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "test/stubs/collection-template/template.ejs",
"new_path": "test/stubs/collection-template/template.ejs",
"diff": "@@ -3,4 +3,5 @@ layout: layout.ejs\n---\nTemplate\n+All <%= collections.all.length %> templates\nTemplate <%= collections.dog.length %> dog\n\\ No newline at end of file\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Add collections.all refs to tests for #88 |
699 | 30.03.2018 12:54:59 | 18,000 | 385db1f45c3d8445a39e806528a0ed2fbf90d848 | Assist for | [
{
"change_type": "MODIFY",
"old_path": "src/TemplatePassthrough.js",
"new_path": "src/TemplatePassthrough.js",
"diff": "@@ -3,9 +3,10 @@ const TemplatePath = require(\"./TemplatePath\");\nconst debug = require(\"debug\")(\"Eleventy:TemplatePassthrough\");\nclass TemplatePassthrough {\n- constructor(inputPath, outputDir) {\n+ constructor(inputPath, outputDir, inputDir) {\nthis.path = inputPath;\nthis.outputDir = outputDir;\n+ this.inputDir = inputDir;\nthis.isDryRun = false;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateWriter.js",
"new_path": "src/TemplateWriter.js",
"diff": "@@ -192,8 +192,9 @@ TemplateWriter.prototype._getTemplate = function(path) {\n};\nTemplateWriter.prototype._copyPassthroughPath = async function(path) {\n- let pass = new TemplatePassthrough(path, this.outputDir);\n+ let pass = new TemplatePassthrough(path, this.outputDir, this.inputDir);\npass.setDryRun(this.isDryRun);\n+\ntry {\nawait pass.write();\ndebugDev(\"Copied %o\", path);\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Assist for #92 #90 |
699 | 30.03.2018 12:59:44 | 18,000 | 7b6f2c5156e69a375afb885bae6f54f95b0542b2 | inputDir passed to TemplatePassthrough | [
{
"change_type": "MODIFY",
"old_path": "test/TemplatePassthroughTest.js",
"new_path": "test/TemplatePassthroughTest.js",
"diff": "@@ -2,13 +2,13 @@ import test from \"ava\";\nimport TemplatePassthrough from \"../src/TemplatePassthrough\";\ntest(\"Constructor\", t => {\n- let pass = new TemplatePassthrough(\"avatar.png\", \"_site\");\n+ let pass = new TemplatePassthrough(\"avatar.png\", \"_site\", \".\");\nt.truthy(pass);\nt.is(pass.getOutputPath(), \"_site/avatar.png\");\n});\ntest(\"Constructor Dry Run\", t => {\n- let pass = new TemplatePassthrough(\"avatar.png\", \"_site\");\n+ let pass = new TemplatePassthrough(\"avatar.png\", \"_site\", \".\");\npass.setDryRun(true);\nt.is(pass.isDryRun, true);\n});\n"
}
] | JavaScript | MIT License | 11ty/eleventy | inputDir passed to TemplatePassthrough |
699 | 02.04.2018 18:01:21 | 18,000 | f3f283210529fa2144631d161c2d1a0713f7c33c | Allows eleventy version checking and errors in downstream projects.
eleventyConfig.versionCheck("v0.3.1") | [
{
"change_type": "MODIFY",
"old_path": "cmd.js",
"new_path": "cmd.js",
"diff": "@@ -6,7 +6,8 @@ if (process.env.DEBUG) {\nconst argv = require(\"minimist\")(process.argv.slice(2));\nconst EleventyNodeVersionCheck = require(\"./src/VersionCheck\");\n-EleventyNodeVersionCheck().then(function() {\n+EleventyNodeVersionCheck().then(\n+ function() {\nconst Eleventy = require(\"./src/Eleventy\");\nconst EleventyCommandCheck = require(\"./src/EleventyCommandCheck\");\n@@ -44,4 +45,10 @@ EleventyNodeVersionCheck().then(function() {\n});\n}\n});\n-});\n+ },\n+ function(error) {\n+ // EleventyNodeVersionCheck rejection\n+ const chalk = require(\"chalk\");\n+ console.log(chalk.red(error.toString()));\n+ }\n+);\n"
},
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"source\": [\"**/.eleventyignore\", \"src/**/*.js\"]\n},\n\"lint-staged\": {\n- \"*.{js,json,css,md}\": [\"prettier --write\", \"git add\"]\n+ \"*.{js,css,md}\": [\"prettier --write\", \"git add\"]\n},\n\"devDependencies\": {\n\"ava\": \"^0.25.0\",\n\"pify\": \"^3.0.0\",\n\"pretty\": \"^2.0.0\",\n\"pug\": \"^2.0.3\",\n+ \"semver\": \"^5.5.0\",\n\"slugify\": \"^1.2.9\",\n\"time-require\": \"^0.1.2\",\n\"valid-url\": \"^1.0.9\"\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Config.js",
"new_path": "src/Config.js",
"diff": "@@ -2,4 +2,6 @@ const TemplateConfig = require(\"./TemplateConfig\");\nconst debug = require(\"debug\")(\"Eleventy:Config\");\ndebug(\"Setting up global TemplateConfig.\");\n-module.exports = new TemplateConfig();\n+let config = new TemplateConfig();\n+\n+module.exports = config;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/EleventyConfig.js",
"new_path": "src/EleventyConfig.js",
"diff": "const EventEmitter = require(\"events\");\n-const lodashget = require(\"lodash.get\");\n-const Sortable = require(\"./Util/Sortable\");\nconst chalk = require(\"chalk\");\n+const semver = require(\"semver\");\n+const { DateTime } = require(\"luxon\");\nconst debug = require(\"debug\")(\"Eleventy:EleventyConfig\");\n+const pkg = require(\"../package.json\");\n// API to expose configuration options in config file\nclass EleventyConfig {\n@@ -25,6 +26,18 @@ class EleventyConfig {\n// now named `transforms` in API\nthis.filters = {};\n+\n+ this.DateTime = DateTime;\n+ }\n+\n+ versionCheck(expected) {\n+ if (!semver.satisfies(pkg.version, expected)) {\n+ throw new Error(\n+ `This project requires the eleventy version to match '${expected}' but found ${\n+ pkg.version\n+ }`\n+ );\n+ }\n}\non(eventName, callback) {\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Allows eleventy version checking and errors in downstream projects.
eleventyConfig.versionCheck("v0.3.1") |
724 | 04.04.2018 16:06:21 | 14,400 | fbbfe67b66244d8974d68d7be62a5e487d07eca7 | Fixes - Prevent partial matches when filtering tag(s). | [
{
"change_type": "MODIFY",
"old_path": "src/TemplateCollection.js",
"new_path": "src/TemplateCollection.js",
"diff": "@@ -43,15 +43,19 @@ class TemplateCollection extends Sortable {\ngetFilteredByTag(tagName) {\nreturn this.getAllSorted().filter(function(item) {\n+ let match = false;\nif (!tagName) {\nreturn true;\n- } else if (\n- Array.isArray(item.data.tags) ||\n- typeof item.data.tags === \"string\"\n- ) {\n- return item.data.tags.indexOf(tagName) > -1;\n+ } else if (Array.isArray(item.data.tags)) {\n+ item.data.tags.forEach(tag => {\n+ if (tag === tagName) {\n+ match = true;\n}\n- return false;\n+ });\n+ } else if (typeof item.data.tags === \"string\") {\n+ match = item.data.tags === tagName;\n+ }\n+ return match;\n});\n}\n}\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Fixes #95 - Prevent partial matches when filtering tag(s). |
702 | 11.04.2018 09:32:17 | 10,800 | ba7a1438d04bfe4204121bbd5919f77290ab4582 | Localize engine configs | [
{
"change_type": "MODIFY",
"old_path": "src/EleventyConfig.js",
"new_path": "src/EleventyConfig.js",
"diff": "@@ -24,6 +24,7 @@ class EleventyConfig {\nthis.handlebarsHelpers = {};\nthis.passthroughCopies = {};\nthis.pugOptions = {};\n+ this.ejsOptions = {};\nthis.libraryOverrides = {};\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Engines/Ejs.js",
"new_path": "src/Engines/Ejs.js",
"diff": "@@ -11,6 +11,7 @@ class Ejs extends TemplateEngine {\nthis.config = config.getConfig();\nthis.setLibrary(this.config.libraryOverrides.ejs);\n+ this.setEjsOptions(this.config.ejsOptions);\n}\nsetLibrary(lib) {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Engines/Liquid.js",
"new_path": "src/Engines/Liquid.js",
"diff": "@@ -9,9 +9,10 @@ class Liquid extends TemplateEngine {\nsuper(name, inputDir);\nthis.config = config.getConfig();\n- this.liquidOptions = this.config.liquidOptions;\n+ this.liquidOptions = {};\nthis.setLibrary(this.config.libraryOverrides.liquid);\n+ this.setLiquidOptions(this.config.liquidOptions);\n}\nsetLibrary(lib) {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Engines/Pug.js",
"new_path": "src/Engines/Pug.js",
"diff": "@@ -8,9 +8,10 @@ class Pug extends TemplateEngine {\nsuper(name, inputDir);\nthis.config = config.getConfig();\n- this.pugOptions = this.config.pugOptions;\n+ this.pugOptions = {};\nthis.setLibrary(this.config.libraryOverrides.pug);\n+ this.setPugOptions(this.config.pugOptions);\n}\nsetLibrary(lib) {\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Localize engine configs |
702 | 11.04.2018 10:49:59 | 10,800 | fc7b99ae0939de197cf97c4aa570ceffc790ff83 | Add support for relative EJS includes | [
{
"change_type": "MODIFY",
"old_path": "src/Engines/Ejs.js",
"new_path": "src/Engines/Ejs.js",
"diff": "@@ -2,6 +2,7 @@ const ejsLib = require(\"ejs\");\nconst TemplateEngine = require(\"./TemplateEngine\");\nconst lodashMerge = require(\"lodash.merge\");\nconst config = require(\"../Config\");\n+const path = require(\"path\");\nclass Ejs extends TemplateEngine {\nconstructor(name, inputDir) {\n@@ -40,8 +41,11 @@ class Ejs extends TemplateEngine {\n);\n}\n- async compile(str) {\n- let fn = this.ejsLib.compile(str, this.getEjsOptions());\n+ async compile(str, inputPath) {\n+ let options = this.getEjsOptions();\n+ options.filename = inputPath || options.filename;\n+\n+ let fn = this.ejsLib.compile(str, options);\nreturn function(data) {\nreturn fn(data);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Engines/Markdown.js",
"new_path": "src/Engines/Markdown.js",
"diff": "@@ -37,14 +37,21 @@ class Markdown extends TemplateEngine {\n);\n}\n- async compile(str, preTemplateEngine, bypassMarkdown) {\n+ async compile(str, inputPath, preTemplateEngine, bypassMarkdown) {\nlet mdlib = this.mdLib;\n+\nif (preTemplateEngine) {\n+ let fn;\nlet engine = TemplateEngine.getEngine(\npreTemplateEngine,\nsuper.getInputDir()\n);\n- let fn = await engine.compile(str);\n+\n+ if (preTemplateEngine === \"ejs\") {\n+ fn = await engine.compile(str, inputPath);\n+ } else {\n+ fn = await engine.compile(str);\n+ }\nif (bypassMarkdown) {\nreturn async function(data) {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Template.js",
"new_path": "src/Template.js",
"diff": "@@ -395,7 +395,7 @@ class Template {\nthis.templateRender.engineName\n);\n- let fn = await this.templateRender.getCompiledTemplate(str);\n+ let fn = await this.templateRender.getCompiledTemplate(str, this.inputPath);\nlet rendered = fn(data);\nreturn rendered;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateRender.js",
"new_path": "src/TemplateRender.js",
"diff": "@@ -149,12 +149,19 @@ TemplateRender.prototype.render = async function(str, data) {\nreturn this.engine.render(str, data);\n};\n-TemplateRender.prototype.getCompiledTemplate = async function(str) {\n+TemplateRender.prototype.getCompiledTemplate = async function(str, inputPath) {\n// TODO refactor better, move into TemplateEngine logic\nif (this.engineName === \"md\") {\n- return this.engine.compile(str, this.parseMarkdownWith, !this.useMarkdown);\n+ return this.engine.compile(\n+ str,\n+ this.parseMarkdownWith,\n+ !this.useMarkdown,\n+ inputPath\n+ );\n} else if (this.engineName === \"html\") {\nreturn this.engine.compile(str, this.parseHtmlWith);\n+ } else if (this.engineName === \"ejs\") {\n+ return this.engine.compile(str, inputPath);\n} else {\nreturn this.engine.compile(str);\n}\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Add support for relative EJS includes |
699 | 16.04.2018 08:51:39 | 18,000 | 479ffeba84b05c0bf5609bde60291ba5591f309d | Move EleventyConfig class to UserConfig for testing. Adds `addMarkdownHighlighter` for markdown syntax highlighting. Will be added in official plugin too. | [
{
"change_type": "MODIFY",
"old_path": "src/Engines/Markdown.js",
"new_path": "src/Engines/Markdown.js",
"diff": "@@ -16,6 +16,15 @@ class Markdown extends TemplateEngine {\nsetLibrary(mdLib) {\nthis.mdLib = mdLib || markdownIt(this.getMarkdownOptions());\n+\n+ // Overrides a highlighter set in `markdownOptions`\n+ // This is separate so devs can pass in a new mdLib and still use the official eleventy plugin for markdown highlighting\n+ if (this.config.markdownHighlighter) {\n+ this.mdLib.set({\n+ highlight: this.config.markdownHighlighter\n+ });\n+ }\n+\nthis.setEngineLib(this.mdLib);\n}\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Move EleventyConfig class to UserConfig for testing. Adds `addMarkdownHighlighter` for markdown syntax highlighting. Will be added in official plugin too. |
702 | 16.04.2018 20:16:50 | 10,800 | 617f3a0272093c279c3df9150e6f1b426c12e11c | Document custom file formats in permalinks | [
{
"change_type": "MODIFY",
"old_path": "docs/permalinks.md",
"new_path": "docs/permalinks.md",
"diff": "@@ -79,6 +79,18 @@ permalinkBypassOutputDir: true\nWrites to `_includes/index.html` even though the output directory is `_site`. This is useful for writing child templates to the `_includes` directory for re-use in your other templates.\n+### Custom File Formats\n+To generate different file formats for your built site, you can use a different extension in the `permalink` option of your front matter.\n+\n+For example, to generate a JSON search index to be used by popular search libraries.\n+\n+```\n+---\n+permalink: index.json\n+---\n+<%- JSON.stringify(collections.all) _%>\n+```\n+\n### Pagination\nPagination variables also work here. [Read more about Pagination](pagination.md)\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Document custom file formats in permalinks |
699 | 17.04.2018 07:22:18 | 18,000 | ba9a7576d55ef075cb19e43cab48fa859544c099 | specify ejs on example | [
{
"change_type": "MODIFY",
"old_path": "docs/permalinks.md",
"new_path": "docs/permalinks.md",
"diff": "@@ -80,11 +80,12 @@ permalinkBypassOutputDir: true\nWrites to `_includes/index.html` even though the output directory is `_site`. This is useful for writing child templates to the `_includes` directory for re-use in your other templates.\n### Custom File Formats\n+\nTo generate different file formats for your built site, you can use a different extension in the `permalink` option of your front matter.\n-For example, to generate a JSON search index to be used by popular search libraries.\n+For example, to generate a JSON search index to be used by popular search libraries (using `ejs` template syntax):\n-```\n+```ejs\n---\npermalink: index.json\n---\n"
}
] | JavaScript | MIT License | 11ty/eleventy | specify ejs on example |
699 | 18.04.2018 22:56:05 | 18,000 | 4557861e0a90966ddca6bc5cd3ccfa591d36c238 | Add per template times to output | [
{
"change_type": "MODIFY",
"old_path": "src/Eleventy.js",
"new_path": "src/Eleventy.js",
"diff": "@@ -98,7 +98,13 @@ Eleventy.prototype.logFinished = function() {\n);\nlet time = ((new Date() - this.start) / 1000).toFixed(2);\n- ret.push(`in ${time} ${simplePlural(time, \"second\", \"seconds\")}`);\n+ ret.push(\n+ `in ${time} ${simplePlural(time, \"second\", \"seconds\")} (${(\n+ time *\n+ 1000 /\n+ writeCount\n+ ).toFixed(1)}ms each)`\n+ );\nreturn ret.join(\" \");\n};\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Add per template times to output |
699 | 18.04.2018 23:50:58 | 18,000 | 48d24506a141d5e3f11607fb8d3cdf441560318e | Only show per ms numbers with more than 10 templates | [
{
"change_type": "MODIFY",
"old_path": "src/Eleventy.js",
"new_path": "src/Eleventy.js",
"diff": "@@ -98,13 +98,11 @@ Eleventy.prototype.logFinished = function() {\n);\nlet time = ((new Date() - this.start) / 1000).toFixed(2);\n- ret.push(\n- `in ${time} ${simplePlural(time, \"second\", \"seconds\")} (${(\n- time *\n- 1000 /\n- writeCount\n- ).toFixed(1)}ms each)`\n- );\n+ ret.push(`in ${time} ${simplePlural(time, \"second\", \"seconds\")}`);\n+\n+ if (writeCount >= 10) {\n+ ret.push(`(${(time * 1000 / writeCount).toFixed(1)}ms each)`);\n+ }\nreturn ret.join(\" \");\n};\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Only show per ms numbers with more than 10 templates |
699 | 18.04.2018 23:51:15 | 18,000 | c41ced5e4785b4dc4ad5fc1164547df10b000eef | Default dynamicPermalinks to true, obvs | [
{
"change_type": "MODIFY",
"old_path": "src/UserConfig.js",
"new_path": "src/UserConfig.js",
"diff": "@@ -26,17 +26,14 @@ class UserConfig {\nthis.pugOptions = {};\nthis.ejsOptions = {};\nthis.markdownHighlighter = null;\n-\nthis.libraryOverrides = {};\nthis.layoutAliases = {};\n-\n// now named `transforms` in API\nthis.filters = {};\n-\nthis.activeNamespace = \"\";\n-\nthis.DateTime = DateTime;\n+ this.dynamicPermalinks = true;\n}\nversionCheck(expected) {\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Default dynamicPermalinks to true, obvs |
699 | 20.04.2018 08:07:11 | 18,000 | b2151f786a901822685cdb4bef2a29744c3b7569 | Remove deep clone code | [
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"liquidjs\": \"^2.2.1\",\n\"lodash.chunk\": \"^4.2.0\",\n\"lodash.clone\": \"^4.5.0\",\n- \"lodash.clonedeep\": \"^4.5.0\",\n\"lodash.get\": \"^4.4.2\",\n\"lodash.isobject\": \"^3.0.2\",\n\"lodash.merge\": \"^4.6.1\",\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateMap.js",
"new_path": "src/TemplateMap.js",
"diff": "const lodashClone = require(\"lodash.clone\");\n-const lodashCloneDeep = require(\"lodash.clonedeep\");\nconst TemplateCollection = require(\"./TemplateCollection\");\nconst eleventyConfig = require(\"./EleventyConfig\");\nconst debug = require(\"debug\")(\"Eleventy:TemplateMap\");\n@@ -74,7 +73,6 @@ class TemplateMap {\nasync createTemplateMapCopy(filteredMap) {\nlet copy = [];\nfor (let map of filteredMap) {\n- // let mapCopy = lodashCloneDeep(map);\nlet mapCopy = lodashClone(map);\n// Circular reference\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Remove deep clone code |
699 | 20.04.2018 22:30:33 | 18,000 | d1874cfbeb68cead75a8c0337b04e8fc5702592d | Add version info to `fileSlug`. | [
{
"change_type": "MODIFY",
"old_path": "README.md",
"new_path": "README.md",
"diff": "@@ -190,6 +190,7 @@ Note that `{{ title }}` above outputs the `title` data value (this can come from\n// the path to the original source file for the template\ninputPath: \"/current/page/file.md\",\n+ // New in Eleventy v0.3.4\n// mapped from inputPath, useful for clean permalinks\nfileSlug: \"file\"\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Add version info to `fileSlug`. |
699 | 26.04.2018 21:58:51 | 18,000 | bc8edb38adf604f363fccfd71e674eb3db80f5ba | Add an EleventyExtensionMap to map from keys in templateFormats to file extensions. | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/EleventyExtensionMap.js",
"diff": "+class EleventyExtensionMap {\n+ constructor(formats) {\n+ this.formats = formats.filter(function(key) {\n+ return EleventyExtensionMap.hasExtension(key);\n+ });\n+ }\n+\n+ getFileList(path, dir) {\n+ if (!path) {\n+ return [];\n+ }\n+ return this.formats.map(function(key) {\n+ return (\n+ (dir ? dir + \"/\" : \"\") +\n+ path +\n+ \".\" +\n+ EleventyExtensionMap.getExtension(key)\n+ );\n+ });\n+ }\n+\n+ getGlobs(inputDir) {\n+ return this.formats.map(function(key) {\n+ return (\n+ (inputDir ? inputDir + \"/\" : \"\") +\n+ \"**/*.\" +\n+ EleventyExtensionMap.getExtension(key)\n+ );\n+ });\n+ }\n+\n+ static hasExtension(key) {\n+ return key in this.keyMapToExtension;\n+ }\n+\n+ static getExtension(key) {\n+ return this.keyMapToExtension[key];\n+ }\n+\n+ static get keyMapToExtension() {\n+ return {\n+ ejs: \"ejs\",\n+ md: \"md\",\n+ jstl: \"jstl\",\n+ html: \"html\",\n+ hbs: \"hbs\",\n+ mustache: \"mustache\",\n+ haml: \"haml\",\n+ pug: \"pug\",\n+ njk: \"njk\",\n+ liquid: \"liquid\",\n+ js: \"11ty.js\"\n+ };\n+ }\n+}\n+\n+module.exports = EleventyExtensionMap;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Engines/Handlebars.js",
"new_path": "src/Engines/Handlebars.js",
"diff": "@@ -28,7 +28,7 @@ class Handlebars extends TemplateEngine {\n}\n}\n- async compile(str) {\n+ async compile(str, inputPath) {\nlet fn = this.handlebarsLib.compile(str);\nreturn function(data) {\nreturn fn(data);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Engines/Html.js",
"new_path": "src/Engines/Html.js",
"diff": "const TemplateEngine = require(\"./TemplateEngine\");\nclass Html extends TemplateEngine {\n- async compile(str, preTemplateEngine) {\n+ async compile(str, inputPath, preTemplateEngine) {\nif (preTemplateEngine) {\nlet engine = TemplateEngine.getEngine(\npreTemplateEngine,\nsuper.getInputDir()\n);\n- let fn = await engine.compile(str);\n+ let fn = await engine.compile(str, inputPath);\nreturn async function(data) {\nreturn fn(data);\n"
},
{
"change_type": "RENAME",
"old_path": "src/Engines/JavaScript.js",
"new_path": "src/Engines/JavaScriptTemplateLiteral.js",
"diff": "@@ -2,7 +2,7 @@ const TemplateEngine = require(\"./TemplateEngine\");\nconst EleventyError = require(\"../EleventyError\");\nclass JavaScript extends TemplateEngine {\n- async compile(str) {\n+ async compile(str, inputPath) {\nreturn function(data) {\n// avoid `with`\nlet dataStr = \"\";\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Engines/Liquid.js",
"new_path": "src/Engines/Liquid.js",
"diff": "@@ -73,7 +73,7 @@ class Liquid extends TemplateEngine {\nthis.liquidLib.registerFilter(name, filter);\n}\n- async compile(str) {\n+ async compile(str, inputPath) {\nlet engine = this.liquidLib;\nlet tmpl = await engine.parse(str);\nreturn async function(data) {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Engines/Markdown.js",
"new_path": "src/Engines/Markdown.js",
"diff": "@@ -56,11 +56,7 @@ class Markdown extends TemplateEngine {\nsuper.getInputDir()\n);\n- if (preTemplateEngine === \"ejs\") {\nfn = await engine.compile(str, inputPath);\n- } else {\n- fn = await engine.compile(str);\n- }\nif (bypassMarkdown) {\nreturn async function(data) {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Engines/Mustache.js",
"new_path": "src/Engines/Mustache.js",
"diff": "@@ -15,7 +15,7 @@ class Mustache extends TemplateEngine {\nthis.setEngineLib(this.mustacheLib);\n}\n- async compile(str) {\n+ async compile(str, inputPath) {\nlet partials = super.getPartials();\nreturn function(data) {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Engines/Nunjucks.js",
"new_path": "src/Engines/Nunjucks.js",
"diff": "@@ -28,7 +28,7 @@ class Nunjucks extends TemplateEngine {\n}\n}\n- async compile(str) {\n+ async compile(str, inputPath) {\nlet tmpl = NunjucksLib.compile(str, this.njkEnv);\nreturn async function(data) {\nreturn new Promise(function(resolve, reject) {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Template.js",
"new_path": "src/Template.js",
"diff": "@@ -404,7 +404,7 @@ class Template {\nthis.templateRender.engineName\n);\n- let fn = await this.templateRender.getCompiledTemplate(str, this.inputPath);\n+ let fn = await this.templateRender.getCompiledTemplate(str);\nlet rendered = fn(data);\nreturn rendered;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateLayout.js",
"new_path": "src/TemplateLayout.js",
"diff": "const fs = require(\"fs-extra\");\nconst config = require(\"./Config\");\n+const EleventyExtensionMap = require(\"./EleventyExtensionMap\");\nconst debug = require(\"debug\")(\"Eleventy:TemplateLayout\");\nfunction TemplateLayout(path, dir) {\n@@ -69,7 +70,6 @@ TemplateLayout.prototype.getFullPath = function() {\n};\nTemplateLayout.prototype.findFileName = function() {\n- let file;\nif (!fs.existsSync(this.dir)) {\nthrow Error(\n\"TemplateLayout directory does not exist for \" +\n@@ -79,16 +79,13 @@ TemplateLayout.prototype.findFileName = function() {\n);\n}\n- this.config.templateFormats.forEach(\n- function(extension) {\n- let filename = this.path + \".\" + extension;\n- if (!file && fs.existsSync(this.dir + \"/\" + filename)) {\n- file = filename;\n+ let extensionMap = new EleventyExtensionMap(this.config.templateFormats);\n+ for (let filename of extensionMap.getFileList(this.path)) {\n+ // TODO async\n+ if (fs.existsSync(this.dir + \"/\" + filename)) {\n+ return filename;\n+ }\n}\n- }.bind(this)\n- );\n-\n- return file;\n};\nmodule.exports = TemplateLayout;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateRender.js",
"new_path": "src/TemplateRender.js",
"diff": "@@ -149,21 +149,19 @@ TemplateRender.prototype.render = async function(str, data) {\nreturn this.engine.render(str, data);\n};\n-TemplateRender.prototype.getCompiledTemplate = async function(str, inputPath) {\n+TemplateRender.prototype.getCompiledTemplate = async function(str) {\n// TODO refactor better, move into TemplateEngine logic\nif (this.engineName === \"md\") {\nreturn this.engine.compile(\nstr,\n- inputPath,\n+ this.path,\nthis.parseMarkdownWith,\n!this.useMarkdown\n);\n} else if (this.engineName === \"html\") {\n- return this.engine.compile(str, this.parseHtmlWith);\n- } else if (this.engineName === \"ejs\") {\n- return this.engine.compile(str, inputPath);\n+ return this.engine.compile(str, this.path, this.parseHtmlWith);\n} else {\n- return this.engine.compile(str);\n+ return this.engine.compile(str, this.path);\n}\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateWriter.js",
"new_path": "src/TemplateWriter.js",
"diff": "@@ -8,16 +8,17 @@ const TemplateRender = require(\"./TemplateRender\");\nconst TemplatePassthrough = require(\"./TemplatePassthrough\");\nconst EleventyError = require(\"./EleventyError\");\nconst TemplateGlob = require(\"./TemplateGlob\");\n+const EleventyExtensionMap = require(\"./EleventyExtensionMap\");\nconst eleventyConfig = require(\"./EleventyConfig\");\nconst config = require(\"./Config\");\nconst debug = require(\"debug\")(\"Eleventy:TemplateWriter\");\nconst debugDev = require(\"debug\")(\"Dev:Eleventy:TemplateWriter\");\n-function TemplateWriter(inputPath, outputDir, extensions, templateData) {\n+function TemplateWriter(inputPath, outputDir, templateKeys, templateData) {\nthis.config = config.getConfig();\nthis.input = inputPath;\nthis.inputDir = this._getInputPathDir(inputPath);\n- this.templateExtensions = extensions;\n+ this.templateKeys = templateKeys;\nthis.outputDir = outputDir;\nthis.templateData = templateData;\nthis.isVerbose = true;\n@@ -30,15 +31,11 @@ function TemplateWriter(inputPath, outputDir, extensions, templateData) {\n// Duplicated with TemplateData.getDataDir();\nthis.dataDir = this.inputDir + \"/\" + this.config.dir.data;\n+ this.extensionMap = new EleventyExtensionMap(this.templateKeys);\n+\n// Input was a directory\nif (this.input === this.inputDir) {\n- this.rawFiles = TemplateGlob.map(\n- this.templateExtensions.map(\n- function(extension) {\n- return this.inputDir + \"/**/*.\" + extension;\n- }.bind(this)\n- )\n- );\n+ this.rawFiles = TemplateGlob.map(this.extensionMap.getGlobs(this.inputDir));\n} else {\nthis.rawFiles = TemplateGlob.map([inputPath]);\n}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/EleventyExtensionMapTest.js",
"diff": "+import test from \"ava\";\n+import EleventyExtensionMap from \"../src/EleventyExtensionMap\";\n+\n+test(\"Empty formats\", t => {\n+ let map = new EleventyExtensionMap([]);\n+ t.deepEqual(map.getGlobs(), []);\n+});\n+test(\"Single format\", t => {\n+ let map = new EleventyExtensionMap([\"pug\"]);\n+ t.deepEqual(map.getGlobs(), [\"**/*.pug\"]);\n+ t.deepEqual(map.getGlobs(\"src\"), [\"src/**/*.pug\"]);\n+});\n+test(\"Multiple formats\", t => {\n+ let map = new EleventyExtensionMap([\"njk\", \"pug\"]);\n+ t.deepEqual(map.getGlobs(), [\"**/*.njk\", \"**/*.pug\"]);\n+ t.deepEqual(map.getGlobs(\"src\"), [\"src/**/*.njk\", \"src/**/*.pug\"]);\n+});\n+\n+test(\"Invalid keys are filtered\", t => {\n+ let map = new EleventyExtensionMap([\"lksdjfjlsk\"]);\n+ t.deepEqual(map.getGlobs(), []);\n+});\n+\n+test(\"Empty path for fileList\", t => {\n+ let map = new EleventyExtensionMap([\"njk\", \"pug\"]);\n+ t.deepEqual(map.getFileList(), []);\n+});\n+\n+test(\"fileList\", t => {\n+ let map = new EleventyExtensionMap([\"njk\", \"pug\"]);\n+ t.deepEqual(map.getFileList(\"filename\"), [\"filename.njk\", \"filename.pug\"]);\n+});\n+\n+test(\"fileList with dir\", t => {\n+ let map = new EleventyExtensionMap([\"njk\", \"pug\"]);\n+ t.deepEqual(map.getFileList(\"filename\", \"_includes\"), [\n+ \"_includes/filename.njk\",\n+ \"_includes/filename.pug\"\n+ ]);\n+});\n+\n+test(\"fileList with dir in path\", t => {\n+ let map = new EleventyExtensionMap([\"njk\", \"pug\"]);\n+ t.deepEqual(map.getFileList(\"layouts/filename\"), [\n+ \"layouts/filename.njk\",\n+ \"layouts/filename.pug\"\n+ ]);\n+});\n+\n+test(\"fileList with dir in path and dir\", t => {\n+ let map = new EleventyExtensionMap([\"njk\", \"pug\"]);\n+ t.deepEqual(map.getFileList(\"layouts/filename\", \"_includes\"), [\n+ \"_includes/layouts/filename.njk\",\n+ \"_includes/layouts/filename.pug\"\n+ ]);\n+});\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateRenderEJSTest.js",
"new_path": "test/TemplateRenderEJSTest.js",
"diff": "@@ -5,6 +5,7 @@ import path from \"path\";\n// EJS\ntest(\"EJS\", t => {\nt.is(new TemplateRender(\"ejs\").getEngineName(), \"ejs\");\n+ t.is(new TemplateRender(\"./test/stubs/filename.ejs\").getEngineName(), \"ejs\");\n});\ntest(\"EJS Render\", async t => {\n@@ -15,42 +16,58 @@ test(\"EJS Render\", async t => {\n});\ntest(\"EJS Render Absolute Include, Preprocessor Directive\", async t => {\n- let fn = await new TemplateRender(\"ejs\", \"./test/stubs/\").getCompiledTemplate(\n- \"<p><% include /included %></p>\"\n- );\n+ // includes require a full filename passed in\n+ let fn = await new TemplateRender(\n+ \"./test/stubs/filename.ejs\",\n+ \"./test/stubs/\"\n+ ).getCompiledTemplate(\"<p><% include /included %></p>\");\nt.is(await fn(), \"<p>This is an include.</p>\");\n});\ntest(\"EJS Render Absolute Include, Fxn no Data\", async t => {\n- let fn = await new TemplateRender(\"ejs\", \"./test/stubs/\").getCompiledTemplate(\n- \"<p><%- include('/included') %></p>\"\n- );\n+ // includes require a full filename passed in\n+ let fn = await new TemplateRender(\n+ \"./test/stubs/filename.ejs\",\n+ \"./test/stubs/\"\n+ ).getCompiledTemplate(\"<p><%- include('/included') %></p>\");\nt.is(await fn(), \"<p>This is an include.</p>\");\n});\ntest(\"EJS Render Absolute Include, Fxn with Data\", async t => {\n- let fn = await new TemplateRender(\"ejs\", \"./test/stubs/\").getCompiledTemplate(\n+ // includes require a full filename passed in\n+ let fn = await new TemplateRender(\n+ \"./test/stubs/filename.ejs\",\n+ \"./test/stubs/\"\n+ ).getCompiledTemplate(\n\"<p><%- include('/includedvar', { name: 'Bill' }) %></p>\"\n);\nt.is(await fn(), \"<p>This is an Bill.</p>\");\n});\ntest(\"EJS Render Relative Include, Preprocessor Directive\", async t => {\n- let fn = await new TemplateRender(\"ejs\", \"./test/stubs/\").getCompiledTemplate(\n- \"<p><% include _includes/included %></p>\"\n- );\n+ // includes require a full filename passed in\n+ let fn = await new TemplateRender(\n+ \"./test/stubs/filename.ejs\",\n+ \"./test/stubs/\"\n+ ).getCompiledTemplate(\"<p><% include _includes/included %></p>\");\nt.is(await fn(), \"<p>This is an include.</p>\");\n});\ntest(\"EJS Render Relative Include, Fxn no Data\", async t => {\n- let fn = await new TemplateRender(\"ejs\", \"./test/stubs/\").getCompiledTemplate(\n- \"<p><%- include('_includes/included', {}) %></p>\"\n- );\n+ // includes require a full filename passed in\n+ let fn = await new TemplateRender(\n+ \"./test/stubs/filename.ejs\",\n+ \"./test/stubs/\"\n+ ).getCompiledTemplate(\"<p><%- include('_includes/included', {}) %></p>\");\nt.is(await fn(), \"<p>This is an include.</p>\");\n});\ntest(\"EJS Render Relative Include, Fxn with Data\", async t => {\n- let fn = await new TemplateRender(\"ejs\", \"./test/stubs/\").getCompiledTemplate(\n+ // includes require a full filename passed in\n+ let fn = await new TemplateRender(\n+ \"./test/stubs/filename.ejs\",\n+ \"./test/stubs/\"\n+ ).getCompiledTemplate(\n\"<p><%- include('_includes/includedvar', { name: 'Bill' }) %></p>\"\n);\nt.is(await fn(), \"<p>This is an Bill.</p>\");\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Add an EleventyExtensionMap to map from keys in templateFormats to file extensions. |
699 | 03.05.2018 07:27:09 | 18,000 | 63345936386b6b5e29e4bbd49b41a8300f8946d7 | Dry run language | [
{
"change_type": "MODIFY",
"old_path": "src/Eleventy.js",
"new_path": "src/Eleventy.js",
"diff": "@@ -88,13 +88,24 @@ Eleventy.prototype.logFinished = function() {\nlet writeCount = this.writer.getWriteCount();\nlet copyCount = this.writer.getCopyCount();\n+ if (this.isDryRun) {\n+ ret.push(\"Pretended to\");\n+ }\nif (copyCount) {\nret.push(\n- `Copied ${copyCount} ${simplePlural(copyCount, \"item\", \"items\")} and`\n+ `${this.isDryRun ? \"Copy\" : \"Copied\"} ${copyCount} ${simplePlural(\n+ copyCount,\n+ \"item\",\n+ \"items\"\n+ )} and`\n);\n}\nret.push(\n- `Processed ${writeCount} ${simplePlural(writeCount, \"file\", \"files\")}`\n+ `${this.isDryRun ? \"Process\" : \"Processed\"} ${writeCount} ${simplePlural(\n+ writeCount,\n+ \"file\",\n+ \"files\"\n+ )}`\n);\nlet time = ((new Date() - this.start) / 1000).toFixed(2);\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Dry run language |
699 | 03.05.2018 08:43:59 | 18,000 | abde5811fb0e18352f939903b7f9cfec8657de51 | Refactor to prepare for | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/TemplatePassthroughManagerTest.js",
"diff": "+import test from \"ava\";\n+import TemplatePassthroughManager from \"../src/TemplatePassthroughManager\";\n+\n+test(\"Get Paths from Config\", async t => {\n+ let mgr = new TemplatePassthroughManager();\n+ mgr.setConfig({\n+ passthroughFileCopy: true,\n+ passthroughCopies: {\n+ img: true\n+ }\n+ });\n+\n+ t.deepEqual(mgr.getConfigPaths(), { img: true });\n+});\n+\n+test(\"Empty config paths when disabled in config\", async t => {\n+ let mgr = new TemplatePassthroughManager();\n+ mgr.setConfig({\n+ passthroughFileCopy: false,\n+ passthroughCopies: {\n+ img: true\n+ }\n+ });\n+\n+ t.deepEqual(mgr.getConfigPaths(), {});\n+});\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Refactor to prepare for #83 |
699 | 03.05.2018 21:36:52 | 18,000 | c3cb6a0e2aafbaf47cd6a8ea37692b53cd6d9f84 | Re-runs on changes to both _includes and _data directories when --watching. Fixes | [
{
"change_type": "MODIFY",
"old_path": "src/TemplateWriter.js",
"new_path": "src/TemplateWriter.js",
"diff": "@@ -33,13 +33,18 @@ function TemplateWriter(inputPath, outputDir, templateKeys, templateData) {\n// Input was a directory\nif (this.input === this.inputDir) {\n- this.rawFiles = TemplateGlob.map(this.extensionMap.getGlobs(this.inputDir));\n+ this.templateGlobs = TemplateGlob.map(\n+ this.extensionMap.getGlobs(this.inputDir)\n+ );\n} else {\n- this.rawFiles = TemplateGlob.map([inputPath]);\n+ this.templateGlobs = TemplateGlob.map([inputPath]);\n}\n- this.watchedFiles = this.addIgnores(this.inputDir, this.rawFiles);\n- this.files = this.addWritingIgnores(this.inputDir, this.watchedFiles);\n+ this.cachedIgnores = this.getIgnores();\n+ this.watchedGlobs = this.templateGlobs.concat(this.cachedIgnores);\n+ this.templateGlobsWithIgnores = this.watchedGlobs.concat(\n+ this.getWritingIgnores()\n+ );\nlet mgr = new TemplatePassthroughManager();\nmgr.setInputDir(this.inputDir);\n@@ -77,18 +82,12 @@ TemplateWriter.prototype._getInputPathDir = function(inputPath) {\nreturn \".\";\n};\n-TemplateWriter.prototype.getRawFiles = function() {\n- return this.rawFiles;\n-};\n-\n-TemplateWriter.prototype.getWatchedIgnores = function() {\n- return this.addIgnores(this.inputDir, []).map(ignore =>\n- TemplatePath.stripLeadingDotSlash(ignore.substr(1))\n- );\n+TemplateWriter.prototype.getFiles = function() {\n+ return this.templateGlobsWithIgnores;\n};\n-TemplateWriter.prototype.getFiles = function() {\n- return this.files;\n+TemplateWriter.prototype.getRawFiles = function() {\n+ return this.templateGlobs;\n};\nTemplateWriter.getFileIgnores = function(\n@@ -134,13 +133,28 @@ TemplateWriter.getFileIgnores = function(\nreturn ignores;\n};\n-TemplateWriter.prototype.addIgnores = function(inputDir, files) {\n+TemplateWriter.prototype.getGlobWatcherFiles = function() {\n+ return this.templateGlobs.concat(this.getIncludesAndDataDirs());\n+};\n+\n+TemplateWriter.prototype.getGlobWatcherIgnores = function() {\n+ return this.cachedIgnores.map(ignore =>\n+ TemplatePath.stripLeadingDotSlash(ignore.substr(1))\n+ );\n+};\n+\n+TemplateWriter.prototype.getIgnores = function() {\n+ let files = [];\n+\nfiles = files.concat(\n- TemplateWriter.getFileIgnores(\".gitignore\", \"node_modules/\")\n+ TemplateWriter.getFileIgnores(\n+ this.inputDir + \"/.gitignore\",\n+ \"node_modules/\"\n+ )\n);\nfiles = files.concat(\n- TemplateWriter.getFileIgnores(inputDir + \"/.eleventyignore\")\n+ TemplateWriter.getFileIgnores(this.inputDir + \"/.eleventyignore\")\n);\nfiles = files.concat(TemplateGlob.map(\"!\" + this.outputDir + \"/**\"));\n@@ -148,21 +162,28 @@ TemplateWriter.prototype.addIgnores = function(inputDir, files) {\nreturn files;\n};\n-TemplateWriter.prototype.addWritingIgnores = function(inputDir, files) {\n+TemplateWriter.prototype.getIncludesAndDataDirs = function() {\n+ let files = [];\nif (this.config.dir.includes) {\n- files = files.concat(TemplateGlob.map(\"!\" + this.includesDir + \"/**\"));\n+ files = files.concat(TemplateGlob.map(this.includesDir + \"/**\"));\n}\nif (this.config.dir.data && this.config.dir.data !== \".\") {\n- files = files.concat(TemplateGlob.map(\"!\" + this.dataDir + \"/**\"));\n+ files = files.concat(TemplateGlob.map(this.dataDir + \"/**\"));\n}\nreturn files;\n};\n+TemplateWriter.prototype.getWritingIgnores = function() {\n+ return this.getIncludesAndDataDirs().map(function(dir) {\n+ return \"!\" + dir;\n+ });\n+};\n+\nTemplateWriter.prototype._getAllPaths = async function() {\n// Note the gitignore: true option for globby is _really slow_\n- return globby(this.files); //, { gitignore: true });\n+ return globby(this.templateGlobsWithIgnores); //, { gitignore: true });\n};\nTemplateWriter.prototype._getTemplate = function(path) {\n@@ -226,7 +247,7 @@ TemplateWriter.prototype._writeTemplate = async function(mapEntry) {\n};\nTemplateWriter.prototype.write = async function() {\n- debug(\"Searching for: %O\", this.files);\n+ debug(\"Searching for: %O\", this.templateGlobsWithIgnores);\nlet paths = await this._getAllPaths();\ndebug(\"Found: %o\", paths);\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplatePassthroughManagerTest.js",
"new_path": "test/TemplatePassthroughManagerTest.js",
"diff": "import test from \"ava\";\nimport TemplatePassthroughManager from \"../src/TemplatePassthroughManager\";\n-test(\"Get Paths from Config\", async t => {\n+test(\"Get paths from Config\", async t => {\nlet mgr = new TemplatePassthroughManager();\nmgr.setConfig({\npassthroughFileCopy: true,\n@@ -24,3 +24,39 @@ test(\"Empty config paths when disabled in config\", async t => {\nt.deepEqual(mgr.getConfigPaths(), {});\n});\n+\n+test(\"Get file paths\", async t => {\n+ let mgr = new TemplatePassthroughManager();\n+ mgr.setConfig({\n+ passthroughFileCopy: true\n+ });\n+\n+ t.deepEqual(mgr.getFilePaths([\"test.png\"]), [\"test.png\"]);\n+});\n+\n+test(\"Get file paths (filter out real templates)\", async t => {\n+ let mgr = new TemplatePassthroughManager();\n+ mgr.setConfig({\n+ passthroughFileCopy: true\n+ });\n+\n+ t.deepEqual(mgr.getFilePaths([\"test.njk\"]), []);\n+});\n+\n+test(\"Get file paths (filter out real templates), multiple\", async t => {\n+ let mgr = new TemplatePassthroughManager();\n+ mgr.setConfig({\n+ passthroughFileCopy: true\n+ });\n+\n+ t.deepEqual(mgr.getFilePaths([\"test.njk\", \"test.png\"]), [\"test.png\"]);\n+});\n+\n+test(\"Get file paths when disabled in config\", async t => {\n+ let mgr = new TemplatePassthroughManager();\n+ mgr.setConfig({\n+ passthroughFileCopy: false\n+ });\n+\n+ t.deepEqual(mgr.getFilePaths([\"test.png\"]), []);\n+});\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateWriterTest.js",
"new_path": "test/TemplateWriterTest.js",
"diff": "@@ -15,8 +15,8 @@ test(\"Mutually exclusive Input and Output dirs\", async t => {\n[\"ejs\", \"md\"]\n);\n- let files = await globby(tw.files);\n- t.is(tw.rawFiles.length, 2);\n+ let files = await globby(tw.getFiles());\n+ t.is(tw.getRawFiles().length, 2);\nt.true(files.length > 0);\nt.is(files[0], \"./test/stubs/writeTest/test.md\");\n});\n@@ -27,8 +27,8 @@ test(\"Single File Input\", async t => {\n\"md\"\n]);\n- let files = await globby(tw.files);\n- t.is(tw.rawFiles.length, 1);\n+ let files = await globby(tw.getFiles());\n+ t.is(tw.getRawFiles().length, 1);\nt.is(files.length, 1);\nt.is(files[0], \"./test/stubs/index.html\");\n});\n@@ -36,8 +36,8 @@ test(\"Single File Input\", async t => {\ntest(\"Single File Input\", async t => {\nlet tw = new TemplateWriter(\"README.md\", \"./test/stubs/_site\", [\"md\"]);\n- let files = await globby(tw.files);\n- t.is(tw.rawFiles.length, 1);\n+ let files = await globby(tw.getFiles());\n+ t.is(tw.getRawFiles().length, 1);\nt.is(files.length, 1);\nt.is(files[0], \"./README.md\");\n});\n@@ -50,8 +50,8 @@ test(\"Output is a subdir of input\", async t => {\n[\"ejs\", \"md\"]\n);\n- let files = await globby(tw.files);\n- t.is(tw.rawFiles.length, 2);\n+ let files = await globby(tw.getFiles());\n+ t.is(tw.getRawFiles().length, 2);\nt.true(files.length > 0);\nlet tmpl = tw._getTemplate(files[0]);\n@@ -85,7 +85,7 @@ test(\".eleventyignore files\", async t => {\nlet ignoredFiles = await globby(\"test/stubs/ignoredFolder/*.md\");\nt.is(ignoredFiles.length, 1);\n- let files = await globby(tw.files);\n+ let files = await globby(tw.getFiles());\nt.true(files.length > 0);\nt.is(\n@@ -349,3 +349,32 @@ All 2 templates\nLayout 1 dog`\n);\n});\n+\n+test(\"Get ignores\", t => {\n+ let tw = new TemplateWriter(\"test/stubs\", \"test/stubs/_site\", []);\n+\n+ t.deepEqual(tw.getIgnores(), [\n+ \"!./test/stubs/node_modules\",\n+ \"!./test/stubs/ignoredFolder/**\",\n+ \"!./test/stubs/ignoredFolder/ignored.md\",\n+ \"!./test/stubs/_site/**\"\n+ ]);\n+});\n+\n+test(\"Include and Data Dirs\", t => {\n+ let tw = new TemplateWriter(\"test/stubs\", \"test/stubs/_site\", []);\n+\n+ t.deepEqual(tw.getIncludesAndDataDirs(), [\n+ \"./test/stubs/_includes/**\",\n+ \"./test/stubs/_data/**\"\n+ ]);\n+});\n+\n+test(\"Ignore Include and Data Dirs\", t => {\n+ let tw = new TemplateWriter(\"test/stubs\", \"test/stubs/_site\", []);\n+\n+ t.deepEqual(tw.getWritingIgnores(), [\n+ \"!./test/stubs/_includes/**\",\n+ \"!./test/stubs/_data/**\"\n+ ]);\n+});\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Re-runs on changes to both _includes and _data directories when --watching. Fixes #99 |
699 | 04.05.2018 22:11:32 | 18,000 | 3825b69f0b9e48a0a035d718b1652728adea1330 | Fixes Now re-runs on changes to passthrough files/dirs | [
{
"change_type": "MODIFY",
"old_path": "docs/copy.md",
"new_path": "docs/copy.md",
"diff": "@@ -19,7 +19,7 @@ Although `png` is not a recognized Eleventy template, Eleventy will now search f\n## Manual Passthrough Copy (Faster)\n-_(New in Eleventy `v0.2.14`)_ Searching the entire directory structure for files to copy based on file extensions is not optimal with large directory structures. If we know what non-template static content we want to appear in our output, we can opt-in to specify _files_ or _directories_ for Eleventy to copy for you. This will probably speed up your build times.\n+_(New in Eleventy `v0.2.14`)_ Searching the entire directory structure for files to copy based on file extensions is not optimal with large directory structures. If we know what non-template static content we want to appear in our output, we can opt-in to specify _files_ or _directories_ for Eleventy to copy for you. This will probably speed up your build times. These entries are relative to your the root of your project and _not_ your eleventy input directory.\n```\n// .eleventy.js\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Eleventy.js",
"new_path": "src/Eleventy.js",
"diff": "@@ -233,7 +233,7 @@ Eleventy.prototype.watch = async function() {\nconst watch = require(\"glob-watcher\");\n- let rawFiles = this.writer.getGlobWatcherFiles();\n+ let rawFiles = await this.writer.getGlobWatcherFiles();\n// Watch the local project config file\nrawFiles.push(config.getLocalProjectConfigFile());\ndebug(\"Eleventy.watch rawFiles: %o\", rawFiles);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/EleventyExtensionMap.js",
"new_path": "src/EleventyExtensionMap.js",
"diff": "+const TemplatePath = require(\"./TemplatePath\");\n+const config = require(\"./Config\");\n+\nclass EleventyExtensionMap {\nconstructor(formats) {\n- this.formats = formats.filter(function(key) {\n+ this.config = config.getConfig();\n+\n+ this.unfilteredFormats = formats.map(function(key) {\n+ return key.trim().toLowerCase();\n+ });\n+\n+ this.formats = this.unfilteredFormats.filter(function(key) {\nreturn EleventyExtensionMap.hasExtension(key);\n});\n+\n+ this.prunedFormats = this.unfilteredFormats.filter(function(key) {\n+ return !EleventyExtensionMap.hasExtension(key);\n+ });\n+ }\n+\n+ setConfig(configOverride) {\n+ this.config = configOverride || {};\n}\ngetFileList(path, dir) {\n@@ -19,12 +36,26 @@ class EleventyExtensionMap {\n});\n}\n+ getPrunedGlobs(inputDir) {\n+ return this._getGlobs(this.prunedFormats, inputDir);\n+ }\n+\ngetGlobs(inputDir) {\n- return this.formats.map(function(key) {\n+ if (this.config.passthroughFileCopy) {\n+ return this._getGlobs(this.unfilteredFormats, inputDir);\n+ }\n+\n+ return this._getGlobs(this.formats, inputDir);\n+ }\n+\n+ _getGlobs(formats, inputDir) {\n+ return formats.map(function(key) {\nreturn (\n- (inputDir ? inputDir + \"/\" : \"\") +\n- \"**/*.\" +\n- EleventyExtensionMap.getExtension(key)\n+ TemplatePath.convertToGlob(inputDir) +\n+ \"/*.\" +\n+ (EleventyExtensionMap.hasExtension(key)\n+ ? EleventyExtensionMap.getExtension(key)\n+ : key)\n);\n});\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplatePath.js",
"new_path": "src/TemplatePath.js",
"diff": "const path = require(\"path\");\nconst normalize = require(\"normalize-path\");\n+const pify = require(\"pify\");\n+const fs = require(\"fs-extra\");\nfunction TemplatePath() {}\n@@ -103,4 +105,22 @@ TemplatePath.stripPathFromDir = function(targetDir, prunedPath) {\nreturn targetDir;\n};\n+TemplatePath.isDirectorySync = function(path) {\n+ return fs.statSync(path).isDirectory();\n+};\n+\n+TemplatePath.convertToGlob = function(path) {\n+ if (!path) {\n+ return \"./**\";\n+ }\n+\n+ path = TemplatePath.addLeadingDotSlash(path);\n+\n+ if (TemplatePath.isDirectorySync(path)) {\n+ return path + (!TemplatePath.hasTrailingSlash(path) ? \"/\" : \"\") + \"**\";\n+ }\n+\n+ return path;\n+};\n+\nmodule.exports = TemplatePath;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateWriter.js",
"new_path": "src/TemplateWriter.js",
"diff": "@@ -31,6 +31,8 @@ function TemplateWriter(inputPath, outputDir, templateKeys, templateData) {\nthis.extensionMap = new EleventyExtensionMap(this.templateKeys);\n+ this.setPassthroughManager();\n+\n// Input was a directory\nif (this.input === this.inputDir) {\nthis.templateGlobs = TemplateGlob.map(\n@@ -43,20 +45,24 @@ function TemplateWriter(inputPath, outputDir, templateKeys, templateData) {\nthis.cachedIgnores = this.getIgnores();\nthis.watchedGlobs = this.templateGlobs.concat(this.cachedIgnores);\nthis.templateGlobsWithIgnores = this.watchedGlobs.concat(\n- this.getWritingIgnores()\n+ this.getTemplateIgnores()\n);\n+}\n- let mgr = new TemplatePassthroughManager();\n+TemplateWriter.prototype.setPassthroughManager = function(mgr) {\n+ if (!mgr) {\n+ mgr = new TemplatePassthroughManager();\nmgr.setInputDir(this.inputDir);\nmgr.setOutputDir(this.outputDir);\n- this.passthroughManager = mgr;\n-\n- this.templateMap;\n}\n+ this.passthroughManager = mgr;\n+};\n+\nTemplateWriter.prototype.restart = function() {\nthis.writeCount = 0;\nthis.passthroughManager.reset();\n+ this.cachedPaths = null;\ndebugDev(\"Resetting counts to 0\");\n};\n@@ -70,7 +76,7 @@ TemplateWriter.prototype.getDataDir = function() {\nTemplateWriter.prototype._getInputPathDir = function(inputPath) {\n// Input points to a file\n- if (!fs.statSync(inputPath).isDirectory()) {\n+ if (!TemplatePath.isDirectorySync(inputPath)) {\nreturn parsePath(inputPath).dir;\n}\n@@ -134,10 +140,14 @@ TemplateWriter.getFileIgnores = function(\n};\nTemplateWriter.prototype.getGlobWatcherFiles = function() {\n- return this.templateGlobs.concat(this.getIncludesAndDataDirs());\n+ // TODO is it better to tie the includes and data to specific file extensions or keep the **?\n+ return this.templateGlobs\n+ .concat(this.getIncludesAndDataDirs())\n+ .concat(this.getPassthroughPaths());\n};\nTemplateWriter.prototype.getGlobWatcherIgnores = function() {\n+ // convert to format without ! since they are passed in as a separate argument to glob watcher\nreturn this.cachedIgnores.map(ignore =>\nTemplatePath.stripLeadingDotSlash(ignore.substr(1))\n);\n@@ -162,6 +172,14 @@ TemplateWriter.prototype.getIgnores = function() {\nreturn files;\n};\n+TemplateWriter.prototype.getPassthroughPaths = function() {\n+ let paths = [];\n+ paths = paths.concat(this.passthroughManager.getConfigPathGlobs());\n+ // These are already added in the root templateGlobs\n+ // paths = paths.concat(this.extensionMap.getPrunedGlobs(this.inputDir));\n+ return paths;\n+};\n+\nTemplateWriter.prototype.getIncludesAndDataDirs = function() {\nlet files = [];\nif (this.config.dir.includes) {\n@@ -175,15 +193,20 @@ TemplateWriter.prototype.getIncludesAndDataDirs = function() {\nreturn files;\n};\n-TemplateWriter.prototype.getWritingIgnores = function() {\n+TemplateWriter.prototype.getTemplateIgnores = function() {\nreturn this.getIncludesAndDataDirs().map(function(dir) {\nreturn \"!\" + dir;\n});\n};\nTemplateWriter.prototype._getAllPaths = async function() {\n+ debug(\"Searching for: %O\", this.templateGlobsWithIgnores);\n+ if (!this.cachedPaths) {\n// Note the gitignore: true option for globby is _really slow_\n- return globby(this.templateGlobsWithIgnores); //, { gitignore: true });\n+ this.cachedPaths = await globby(this.templateGlobsWithIgnores); //, { gitignore: true });\n+ }\n+\n+ return this.cachedPaths;\n};\nTemplateWriter.prototype._getTemplate = function(path) {\n@@ -247,7 +270,6 @@ TemplateWriter.prototype._writeTemplate = async function(mapEntry) {\n};\nTemplateWriter.prototype.write = async function() {\n- debug(\"Searching for: %O\", this.templateGlobsWithIgnores);\nlet paths = await this._getAllPaths();\ndebug(\"Found: %o\", paths);\n"
},
{
"change_type": "MODIFY",
"old_path": "test/EleventyExtensionMapTest.js",
"new_path": "test/EleventyExtensionMapTest.js",
"diff": "@@ -7,20 +7,41 @@ test(\"Empty formats\", t => {\n});\ntest(\"Single format\", t => {\nlet map = new EleventyExtensionMap([\"pug\"]);\n- t.deepEqual(map.getGlobs(), [\"**/*.pug\"]);\n- t.deepEqual(map.getGlobs(\"src\"), [\"src/**/*.pug\"]);\n+ t.deepEqual(map.getGlobs(), [\"./**/*.pug\"]);\n+ t.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(\"src\"), [\"src/**/*.njk\", \"src/**/*.pug\"]);\n+ t.deepEqual(map.getGlobs(), [\"./**/*.njk\", \"./**/*.pug\"]);\n+ t.deepEqual(map.getGlobs(\"src\"), [\"./src/**/*.njk\", \"./src/**/*.pug\"]);\n});\ntest(\"Invalid keys are filtered\", t => {\nlet map = new EleventyExtensionMap([\"lksdjfjlsk\"]);\n+ map.setConfig({\n+ passthroughFileCopy: false\n+ });\nt.deepEqual(map.getGlobs(), []);\n});\n+test(\"Invalid keys are filtered\", t => {\n+ let map = new EleventyExtensionMap([\"lksdjfjlsk\"]);\n+ map.setConfig({\n+ passthroughFileCopy: true\n+ });\n+ t.deepEqual(map.getGlobs(), [\"./**/*.lksdjfjlsk\"]);\n+});\n+\n+test(\"Keys are mapped to lower case\", t => {\n+ let map = new EleventyExtensionMap([\"PUG\", \"NJK\"]);\n+ t.deepEqual(map.getGlobs(), [\"./**/*.pug\", \"./**/*.njk\"]);\n+});\n+\n+test(\"Pruned globs\", t => {\n+ let map = new EleventyExtensionMap([\"pug\", \"njk\", \"png\"]);\n+ t.deepEqual(map.getPrunedGlobs(), [\"./**/*.png\"]);\n+});\n+\ntest(\"Empty path for fileList\", t => {\nlet map = new EleventyExtensionMap([\"njk\", \"pug\"]);\nt.deepEqual(map.getFileList(), []);\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplatePassthroughManagerTest.js",
"new_path": "test/TemplatePassthroughManagerTest.js",
"diff": "@@ -10,7 +10,7 @@ test(\"Get paths from Config\", async t => {\n}\n});\n- t.deepEqual(mgr.getConfigPaths(), { img: true });\n+ t.deepEqual(mgr.getConfigPaths(), [\"./img\"]);\n});\ntest(\"Empty config paths when disabled in config\", async t => {\n@@ -22,7 +22,19 @@ test(\"Empty config paths when disabled in config\", async t => {\n}\n});\n- t.deepEqual(mgr.getConfigPaths(), {});\n+ t.deepEqual(mgr.getConfigPaths(), []);\n+});\n+\n+test(\"Get glob paths from Config\", async t => {\n+ let mgr = new TemplatePassthroughManager();\n+ mgr.setConfig({\n+ passthroughFileCopy: true,\n+ passthroughCopies: {\n+ \"test/stubs/img\": true\n+ }\n+ });\n+\n+ t.deepEqual(mgr.getConfigPathGlobs(), [\"./test/stubs/img/**\"]);\n});\ntest(\"Get file paths\", async t => {\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplatePathTest.js",
"new_path": "test/TemplatePathTest.js",
"diff": "@@ -95,3 +95,10 @@ test(\"getAllDirs\", t => {\n\"./src\"\n]);\n});\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+});\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Fixes #83. Now re-runs on changes to passthrough files/dirs |
699 | 09.05.2018 07:47:18 | 18,000 | 1eca46104671a0c46a98280f8d14f90fc876b98f | Get rid of unnecessary static | [
{
"change_type": "MODIFY",
"old_path": "src/EleventyExtensionMap.js",
"new_path": "src/EleventyExtensionMap.js",
"diff": "@@ -10,12 +10,12 @@ class EleventyExtensionMap {\n});\nthis.formats = this.unfilteredFormats.filter(function(key) {\n- return EleventyExtensionMap.hasExtension(key);\n- });\n+ return this.hasExtension(key);\n+ }.bind(this));\nthis.prunedFormats = this.unfilteredFormats.filter(function(key) {\n- return !EleventyExtensionMap.hasExtension(key);\n- });\n+ return !this.hasExtension(key);\n+ }.bind(this));\n}\nsetConfig(configOverride) {\n@@ -31,9 +31,9 @@ class EleventyExtensionMap {\n(dir ? dir + \"/\" : \"\") +\npath +\n\".\" +\n- EleventyExtensionMap.getExtension(key)\n+ this.getExtension(key)\n);\n- });\n+ }.bind(this));\n}\ngetPrunedGlobs(inputDir) {\n@@ -53,22 +53,22 @@ class EleventyExtensionMap {\nreturn (\nTemplatePath.convertToGlob(inputDir) +\n\"/*.\" +\n- (EleventyExtensionMap.hasExtension(key)\n- ? EleventyExtensionMap.getExtension(key)\n+ (this.hasExtension(key)\n+ ? this.getExtension(key)\n: key)\n);\n- });\n+ }.bind(this));\n}\n- static hasExtension(key) {\n+ hasExtension(key) {\nreturn key in this.keyMapToExtension;\n}\n- static getExtension(key) {\n+ getExtension(key) {\nreturn this.keyMapToExtension[key];\n}\n- static get keyMapToExtension() {\n+ get keyMapToExtension() {\nreturn {\nejs: \"ejs\",\nmd: \"md\",\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Get rid of unnecessary static |
699 | 09.05.2018 23:24:59 | 18,000 | b32133ccbc72f11dd2b7676bf8bbcf73dc6b3721 | Adds examples for template literals, vue.js templates, viperhtml templates. | [
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "],\n\"source\": [\n\"**/.eleventyignore\",\n- \"src/**/*.js\"\n+ \"src/**/*.js\",\n+ \"test/stubs/**\"\n]\n},\n\"lint-staged\": {\n\"husky\": \"^0.14.3\",\n\"lint-staged\": \"^7.0.0\",\n\"markdown-it-emoji\": \"^1.4.0\",\n- \"nyc\": \"^11.6.0\",\n- \"prettier\": \"1.11.1\"\n+ \"nyc\": \"^11.7.3\",\n+ \"prettier\": \"1.11.1\",\n+ \"viperhtml\": \"^2.12.0\",\n+ \"vue\": \"^2.5.16\",\n+ \"vue-server-renderer\": \"^2.5.16\"\n},\n\"dependencies\": {\n\"chalk\": \"^2.3.2\",\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Engines/JavaScript.js",
"new_path": "src/Engines/JavaScript.js",
"diff": "const TemplateEngine = require(\"./TemplateEngine\");\n-const EleventyError = require(\"../EleventyError\");\nclass JavaScript extends TemplateEngine {\nasync compile(str, inputPath) {\nconst cls = require(inputPath);\n+ if (typeof cls === \"function\") {\n+ if (cls.prototype && \"render\" in cls.prototype) {\nlet inst = new cls(inputPath);\n- return inst.compile();\n+ return function(data) {\n+ return inst.render(data);\n+ };\n+ }\n+\n+ return cls;\n+ }\n}\n}\n"
},
{
"change_type": "DELETE",
"old_path": "test/TemplateRenderJSTest.js",
"new_path": null,
"diff": "-import test from \"ava\";\n-import TemplateRender from \"../src/TemplateRender\";\n-import path from \"path\";\n-\n-test(\"JS\", t => {\n- t.is(new TemplateRender(\"js\").getEngineName(), \"js\");\n- t.is(new TemplateRender(\"./test/stubs/filename.js\").getEngineName(), \"js\");\n-});\n-\n-test(\"JS Render\", async t => {\n- let fn = await new TemplateRender(\"../../test/stubs/filename.js\").getCompiledTemplate(\n- \"<p>${data.name}</p>\"\n- );\n- t.is(await fn({ name: \"Zach\" }), \"<p>Zach</p>\");\n-});\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/TemplateRenderJavaScriptTest.js",
"diff": "+import test from \"ava\";\n+import TemplateRender from \"../src/TemplateRender\";\n+\n+test(\"JS\", t => {\n+ t.is(new TemplateRender(\"js\").getEngineName(), \"js\");\n+ t.is(new TemplateRender(\"./test/stubs/filename.js\").getEngineName(), \"js\");\n+});\n+\n+test(\"JS Render\", async t => {\n+ let fn = await new TemplateRender(\n+ \"../../test/stubs/template-literal.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+\n+test(\"JS Render with a Class\", async t => {\n+ let fn = await new TemplateRender(\n+ \"../../test/stubs/class-template-literal.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+\n+test(\"JS Render using Vue\", async t => {\n+ let fn = await new TemplateRender(\n+ \"../../test/stubs/vue.js\"\n+ ).getCompiledTemplate();\n+ t.is(\n+ await fn({ name: \"Zach\" }),\n+ '<p data-server-rendered=\"true\">Hello Zach, this is a Vue template.</p>'\n+ );\n+ t.is(\n+ await fn({ name: \"Bill\" }),\n+ '<p data-server-rendered=\"true\">Hello Bill, this is a Vue template.</p>'\n+ );\n+});\n+\n+test(\"JS Render using Vue (with a layout)\", async t => {\n+ let fn = await new TemplateRender(\n+ \"../../test/stubs/vue-layout.js\"\n+ ).getCompiledTemplate();\n+ t.is(\n+ await fn({ name: \"Zach\" }),\n+ `<!doctype html>\n+<title>Test</title>\n+<p data-server-rendered=\"true\">Hello Zach, this is a Vue template.</p>`\n+ );\n+});\n+\n+test(\"JS Render using ViperHTML\", async t => {\n+ let fn = await new TemplateRender(\n+ \"../../test/stubs/viperhtml.js\"\n+ ).getCompiledTemplate();\n+ t.is(\n+ await fn({ name: \"Zach\", html: \"<strong>Hi</strong>\" }),\n+ `<div>\n+ This is a viper template, Zach\n+ <strong>Hi</strong>\n+</div>`\n+ );\n+});\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/class-template-literal.js",
"diff": "+class Test {\n+ render(data) {\n+ return `<p>${data.name}</p>`;\n+ }\n+}\n+\n+module.exports = Test;\n"
},
{
"change_type": "DELETE",
"old_path": "test/stubs/filename.js",
"new_path": null,
"diff": "-class Test {\n- compile() {\n- return function(data) {\n- return `<p>${data.name}</p>`;\n- }\n- }\n-}\n-\n-module.exports = Test;\n\\ No newline at end of file\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/template-literal.js",
"diff": "+module.exports = function(data) {\n+ return `<p>${data.name}</p>`;\n+};\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/viperhtml.js",
"diff": "+const viperHTML = require(\"viperhtml\");\n+\n+module.exports = function(data) {\n+ return (\n+ \"\" +\n+ viperHTML.wire()`<div>\n+ This is a viper template, ${data.name}\n+ ${[data.html]}\n+</div>`\n+ );\n+};\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/vue-layout.js",
"diff": "+const Vue = require(\"vue\");\n+const renderer = require(\"vue-server-renderer\").createRenderer({\n+ template: `<!doctype html>\n+<title>{{ title }}</title>\n+<!--vue-ssr-outlet-->`\n+});\n+\n+module.exports = async function(data) {\n+ var app = new Vue({\n+ template: \"<p>Hello {{ data.name }}, this is a Vue template.</p>\",\n+ data: function() {\n+ return { data };\n+ }\n+ // components: {\n+ // 'test': ComponentA\n+ // }\n+ });\n+\n+ return renderer.renderToString(app, { title: \"Test\" });\n+};\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/vue.js",
"diff": "+const Vue = require(\"vue\");\n+const renderer = require(\"vue-server-renderer\").createRenderer();\n+\n+module.exports = async function(data) {\n+ var app = new Vue({\n+ template: \"<p>Hello {{ data.name }}, this is a Vue template.</p>\",\n+ data: function() {\n+ return { data };\n+ }\n+ // components: {\n+ // 'test': ComponentA\n+ // }\n+ });\n+\n+ return renderer.renderToString(app);\n+};\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Adds examples for template literals, vue.js templates, viperhtml templates. |
699 | 10.05.2018 11:04:04 | 18,000 | cc6231f8151767ec237b22c99c89928a8fc08555 | Add string support to js templates | [
{
"change_type": "MODIFY",
"old_path": "src/Engines/JavaScript.js",
"new_path": "src/Engines/JavaScript.js",
"diff": "@@ -3,7 +3,11 @@ const TemplateEngine = require(\"./TemplateEngine\");\nclass JavaScript extends TemplateEngine {\nasync compile(str, inputPath) {\nconst cls = require(inputPath);\n- if (typeof cls === \"function\") {\n+ if (typeof cls === \"string\") {\n+ return function() {\n+ return cls;\n+ };\n+ } else if (typeof cls === \"function\") {\nif (cls.prototype && \"render\" in cls.prototype) {\nlet inst = new cls(inputPath);\nreturn function(data) {\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateRenderJavaScriptTest.js",
"new_path": "test/TemplateRenderJavaScriptTest.js",
"diff": "@@ -6,7 +6,14 @@ test(\"JS\", t => {\nt.is(new TemplateRender(\"./test/stubs/filename.js\").getEngineName(), \"js\");\n});\n-test(\"JS Render\", async t => {\n+test(\"JS Render a string (no data)\", async t => {\n+ let fn = await new TemplateRender(\n+ \"../../test/stubs/string.js\"\n+ ).getCompiledTemplate();\n+ t.is(await fn({ name: \"Bill\" }), \"<p>Zach</p>\");\n+});\n+\n+test(\"JS Render a function\", async t => {\nlet fn = await new TemplateRender(\n\"../../test/stubs/template-literal.js\"\n).getCompiledTemplate();\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/string.js",
"diff": "+module.exports = \"<p>Zach</p>\";\n"
},
{
"change_type": "MODIFY",
"old_path": "test/stubs/vue.js",
"new_path": "test/stubs/vue.js",
"diff": "const Vue = require(\"vue\");\nconst renderer = require(\"vue-server-renderer\").createRenderer();\n-module.exports = async function(data) {\n+module.exports = async function(templateData) {\nvar app = new Vue({\ntemplate: \"<p>Hello {{ data.name }}, this is a Vue template.</p>\",\n- data: function() {\n- return { data };\n+ data: {\n+ data: templateData\n}\n// components: {\n// 'test': ComponentA\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Add string support to js templates |
699 | 10.05.2018 23:59:46 | 18,000 | b8019b51d530a89b004ba182b15ef593a1e75e30 | Switch to Browsersync for --serve (seamless reloads when watch finishes). Works transparently with `pathPrefix` to emulate the subdirectory specified in your config file. Smart reloads CSS files: 1. If they are in _includes, reload the entire page (css files included directly in <style>). 2. If they are anywhere else, injects them without reload. | [
{
"change_type": "MODIFY",
"old_path": "cmd.js",
"new_path": "cmd.js",
"diff": "@@ -36,16 +36,7 @@ EleventyNodeVersionCheck().then(\nconsole.log(elev.getHelp());\n} else if (argv.serve) {\nelev.watch().then(function() {\n- const serve = require(\"serve\");\n- const server = serve(elev.getOutputDir(), {\n- port: argv.port || 8080,\n- ignore: [\"node_modules\"]\n- });\n-\n- process.on(\"SIGINT\", function() {\n- server.stop();\n- process.exit();\n- });\n+ elev.serve(argv.port);\n});\n} else if (argv.watch) {\nelev.watch();\n"
},
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"prettier\": \"1.11.1\"\n},\n\"dependencies\": {\n+ \"browser-sync\": \"^2.24.4\",\n\"chalk\": \"^2.3.2\",\n\"check-node-version\": \"^3.2.0\",\n\"debug\": \"^3.1.0\",\n\"pretty\": \"^2.0.0\",\n\"pug\": \"^2.0.3\",\n\"semver\": \"^5.5.0\",\n- \"serve\": \"^6.5.5\",\n\"slugify\": \"^1.2.9\",\n\"time-require\": \"^0.1.2\",\n\"valid-url\": \"^1.0.9\"\n"
},
{
"change_type": "MODIFY",
"old_path": "playground/pretty.html",
"new_path": "playground/pretty.html",
"diff": "<!doctype html>\n-<html lang=\"en\"><head></head><body></body></html>\n+<html lang=\"en\"><head></head><body>Howdy</body></html>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Eleventy.js",
"new_path": "src/Eleventy.js",
"diff": "-const fs = require(\"fs\");\n+const fs = require(\"fs-extra\");\nconst chalk = require(\"chalk\");\nconst parsePath = require(\"parse-filepath\");\n+const browserSync = require(\"browser-sync\");\n+\n+const TemplatePath = require(\"./TemplatePath\");\nconst TemplateData = require(\"./TemplateData\");\nconst TemplateWriter = require(\"./TemplateWriter\");\nconst templateCache = require(\"./TemplateCache\");\n@@ -214,6 +217,20 @@ Eleventy.prototype._watch = async function(path) {\nthis.restart();\nawait this.write();\n+\n+ if (this.server) {\n+ // Is a CSS input file and is not in the includes folder\n+ // TODO check output path file extension of this template (not input path)\n+ if (\n+ path.split(\".\").pop() === \"css\" &&\n+ !TemplatePath.contains(path, this.writer.getIncludesDir())\n+ ) {\n+ this.server.reload(\"*.css\");\n+ } else {\n+ this.server.reload();\n+ }\n+ }\n+\nthis.active = false;\nif (this.queuedToRun) {\n@@ -260,6 +277,49 @@ Eleventy.prototype.watch = async function() {\n);\n};\n+Eleventy.prototype.serve = function(port) {\n+ this.server = browserSync.create();\n+\n+ // TODO customize this in Configuration API?\n+ let serverConfig = {\n+ baseDir: this.getOutputDir()\n+ };\n+\n+ if (this.config.pathPrefix !== \"/\") {\n+ let redirectDirectoryName = \"_eleventy_redirect\";\n+ let redirectDir = this.getOutputDir() + \"/\" + redirectDirectoryName;\n+\n+ fs.outputFile(\n+ redirectDir + \"/index.html\",\n+ `<!doctype html>\n+<meta http-equiv=\"refresh\" content=\"0; url=${this.config.pathPrefix}\">\n+<title>Browsersync pathPrefix Redirect</title>\n+<a href=\"${this.config.pathPrefix}\">Go to ${this.config.pathPrefix}</a>`\n+ );\n+\n+ serverConfig.baseDir = redirectDir;\n+ serverConfig.routes = {};\n+ serverConfig.routes[this.config.pathPrefix] = this.getOutputDir();\n+ }\n+\n+ this.server.init({\n+ server: serverConfig,\n+ port: port || 8080,\n+ ignore: [\"node_modules\"],\n+ watch: false,\n+ open: false,\n+ index: \"index.html\"\n+ });\n+\n+ process.on(\n+ \"SIGINT\",\n+ function() {\n+ this.server.exit();\n+ process.exit();\n+ }.bind(this)\n+ );\n+};\n+\nEleventy.prototype.write = async function() {\ntry {\nlet ret = await this.writer.write();\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Template.js",
"new_path": "src/Template.js",
"diff": "@@ -503,7 +503,7 @@ class Template {\nthis.writeCount++;\nif (!this.isDryRun) {\n- await pify(fs.outputFile)(outputPath, finalContent);\n+ await fs.outputFile(outputPath, finalContent);\n}\nlet writeDesc = this.isDryRun ? \"Pretending to write\" : \"Writing\";\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplatePath.js",
"new_path": "src/TemplatePath.js",
"diff": "@@ -94,6 +94,13 @@ TemplatePath.stripLeadingDotSlash = function(dir) {\nreturn dir.replace(/^\\.\\//, \"\");\n};\n+TemplatePath.contains = function(haystack, needle) {\n+ haystack = TemplatePath.stripLeadingDotSlash(normalize(haystack));\n+ needle = TemplatePath.stripLeadingDotSlash(normalize(needle));\n+\n+ return haystack.indexOf(needle) === 0;\n+};\n+\nTemplatePath.stripPathFromDir = function(targetDir, prunedPath) {\ntargetDir = TemplatePath.stripLeadingDotSlash(normalize(targetDir));\nprunedPath = TemplatePath.stripLeadingDotSlash(normalize(prunedPath));\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplatePathTest.js",
"new_path": "test/TemplatePathTest.js",
"diff": "@@ -56,6 +56,31 @@ test(\"addLeadingDotSlash\", t => {\nt.is(TemplatePath.addLeadingDotSlash(\".nyc_output\"), \"./.nyc_output\");\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+ t.true(\n+ TemplatePath.contains(\"testing/hello/subdir/test\", \"testing/hello/subdir\")\n+ );\n+ t.true(\n+ TemplatePath.contains(\n+ \"testing/hello/subdir/test\",\n+ \"testing/hello/subdir/test\"\n+ )\n+ );\n+});\n+\ntest(\"stripPathFromDir\", t => {\nt.is(\nTemplatePath.stripPathFromDir(\"./testing/hello\", \"./lskdjklfjz\"),\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Switch to Browsersync for --serve (seamless reloads when watch finishes). Works transparently with `pathPrefix` to emulate the subdirectory specified in your config file. Smart reloads CSS files: 1. If they are in _includes, reload the entire page (css files included directly in <style>). 2. If they are anywhere else, injects them without reload. |
686 | 12.05.2018 19:56:20 | -3,600 | fa3a94e83d569695464b2b1442d50e14c21a1f84 | Update liquidjs dependancy | [
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"gray-matter\": \"^3.1.1\",\n\"hamljs\": \"^0.6.2\",\n\"handlebars\": \"^4.0.11\",\n- \"liquidjs\": \"^2.2.1\",\n+ \"liquidjs\": \"^4.0.0\",\n\"lodash.chunk\": \"^4.2.0\",\n\"lodash.clone\": \"^4.5.0\",\n\"lodash.get\": \"^4.4.2\",\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Update liquidjs dependancy |
699 | 12.05.2018 21:17:24 | 18,000 | 6481ee796263181a1b69f13c2ab0aa729c0efe2e | Got 3 more skipped tests passing too! | [
{
"change_type": "MODIFY",
"old_path": "test/TemplateRenderLiquidTest.js",
"new_path": "test/TemplateRenderLiquidTest.js",
"diff": "@@ -133,8 +133,7 @@ test(\"Liquid addTags\", async t => {\n);\n});\n-/* Skipped tests pending https://github.com/harttle/liquidjs/issues/61 */\n-test.skip(\"Liquid Render Include Subfolder\", async t => {\n+test(\"Liquid Render Include Subfolder\", async t => {\nlet fn = await new TemplateRender(\n\"liquid\",\n\"./test/stubs/\"\n@@ -142,51 +141,52 @@ test.skip(\"Liquid Render Include Subfolder\", async t => {\nt.is(await fn(), \"<p>This is an include.</p>\");\n});\n-test.skip(\"Liquid Render Include Subfolder Single quotes\", async t => {\n+test(\"Liquid Render Include Subfolder HTML\", async t => {\nlet fn = await new TemplateRender(\n\"liquid\",\n\"./test/stubs/\"\n- ).getCompiledTemplate(`<p>{% include 'subfolder/included.liquid' %}</p>`);\n+ ).getCompiledTemplate(`<p>{% include subfolder/included.html %}</p>`);\nt.is(await fn(), \"<p>This is an include.</p>\");\n});\n-test.skip(\"Liquid Render Include Subfolder Double quotes\", async t => {\n+test(\"Liquid Render Include Subfolder No file extension\", async t => {\nlet fn = await new TemplateRender(\n\"liquid\",\n\"./test/stubs/\"\n- ).getCompiledTemplate(`<p>{% include \"subfolder/included.liquid\" %}</p>`);\n+ ).getCompiledTemplate(`<p>{% include subfolder/included %}</p>`);\nt.is(await fn(), \"<p>This is an include.</p>\");\n});\n-test.skip(\"Liquid Render Include Subfolder HTML\", async t => {\n+/* Skipped tests pending https://github.com/harttle/liquidjs/issues/61 */\n+test.skip(\"Liquid Render Include Subfolder Single quotes\", async t => {\nlet fn = await new TemplateRender(\n\"liquid\",\n\"./test/stubs/\"\n- ).getCompiledTemplate(`<p>{% include subfolder/included.html %}</p>`);\n+ ).getCompiledTemplate(`<p>{% include 'subfolder/included.liquid' %}</p>`);\nt.is(await fn(), \"<p>This is an include.</p>\");\n});\n-test.skip(\"Liquid Render Include Subfolder Single quotes HTML\", async t => {\n+test.skip(\"Liquid Render Include Subfolder Double quotes\", async t => {\nlet fn = await new TemplateRender(\n\"liquid\",\n\"./test/stubs/\"\n- ).getCompiledTemplate(`<p>{% include 'subfolder/included.html' %}</p>`);\n+ ).getCompiledTemplate(`<p>{% include \"subfolder/included.liquid\" %}</p>`);\nt.is(await fn(), \"<p>This is an include.</p>\");\n});\n-test.skip(\"Liquid Render Include Subfolder Double quotes HTML\", async t => {\n+test.skip(\"Liquid Render Include Subfolder Single quotes HTML\", async t => {\nlet fn = await new TemplateRender(\n\"liquid\",\n\"./test/stubs/\"\n- ).getCompiledTemplate(`<p>{% include \"subfolder/included.html\" %}</p>`);\n+ ).getCompiledTemplate(`<p>{% include 'subfolder/included.html' %}</p>`);\nt.is(await fn(), \"<p>This is an include.</p>\");\n});\n-test.skip(\"Liquid Render Include Subfolder No file extension\", async t => {\n+test.skip(\"Liquid Render Include Subfolder Double quotes HTML\", async t => {\nlet fn = await new TemplateRender(\n\"liquid\",\n\"./test/stubs/\"\n- ).getCompiledTemplate(`<p>{% include subfolder/included %}</p>`);\n+ ).getCompiledTemplate(`<p>{% include \"subfolder/included.html\" %}</p>`);\nt.is(await fn(), \"<p>This is an include.</p>\");\n});\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Got 3 more skipped tests passing too! |
699 | 14.05.2018 21:47:18 | 18,000 | dda137ffd7b3ff61b59977e52b3af48727115f18 | Move browsersync stuff to EleventyServe class. | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/EleventyServeTest.js",
"diff": "+import test from \"ava\";\n+import EleventyServe from \"../src/EleventyServe\";\n+\n+test(\"Constructor\", t => {\n+ let es = new EleventyServe();\n+ t.is(es.getPathPrefix(), \"/\");\n+});\n+\n+test(\"Directories\", t => {\n+ let es = new EleventyServe();\n+ es.setOutputDir(\"_site\");\n+ t.is(es.getRedirectDir(\"test\"), \"_site/test\");\n+ t.is(es.getRedirectFilename(\"test\"), \"_site/test/index.html\");\n+});\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Move browsersync stuff to EleventyServe class. |
699 | 15.05.2018 21:42:05 | 18,000 | d80b86d41fc03c4fedf39fffea3a9070bd2119ac | Check to make sure we have a path before we split it | [
{
"change_type": "MODIFY",
"old_path": "src/EleventyServe.js",
"new_path": "src/EleventyServe.js",
"diff": "@@ -141,7 +141,7 @@ class EleventyServe {\n} else {\n// Is a CSS input file and is not in the includes folder\n// TODO check output path file extension of this template (not input path)\n- if (path.split(\".\").pop() === \"css\" && !isInclude) {\n+ if (path && path.split(\".\").pop() === \"css\" && !isInclude) {\nthis.server.reload(\"*.css\");\n} else {\nthis.server.reload();\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Check to make sure we have a path before we split it |
699 | 16.05.2018 21:43:51 | 18,000 | 5661a9228681d3bae94b3ea9f2b0618e9032be55 | Switch to an async file read | [
{
"change_type": "MODIFY",
"old_path": "src/Template.js",
"new_path": "src/Template.js",
"diff": "@@ -22,7 +22,6 @@ class Template {\nthis.config = config.getConfig();\nthis.inputPath = path;\n- this.inputContent = fs.readFileSync(path, \"utf-8\");\nthis.parsed = parsePath(path);\n// for pagination\n@@ -41,8 +40,6 @@ class Template {\nthis.outputDir = false;\n}\n- this.frontMatter = this.getMatter();\n-\nthis.transforms = [];\nthis.plugins = {};\nthis.templateData = templateData;\n@@ -141,7 +138,7 @@ class Template {\n// TODO check for conflicts, see if file already exists?\nasync getOutputPath() {\nlet uri = await this.getOutputLink();\n- if (this.getFrontMatterData()[this.config.keys.permalinkRoot]) {\n+ if ((await this.getFrontMatterData())[this.config.keys.permalinkRoot]) {\nreturn normalize(uri);\n} else {\nreturn normalize(this.outputDir + \"/\" + uri);\n@@ -156,14 +153,39 @@ class Template {\nreturn this.outputDir === false;\n}\n- getMatter() {\n- return matter(this.inputContent);\n+ async read() {\n+ this.inputContent = await this.getInputContent();\n+ this.frontMatter = matter(this.inputContent);\n+ }\n+\n+ async getInputContent() {\n+ return fs.readFile(this.inputPath, \"utf-8\");\n+ }\n+\n+ async getPreRender() {\n+ if (!this.frontMatter) {\n+ await this.read();\n}\n- getPreRender() {\nreturn this.frontMatter.content;\n}\n+ async getFrontMatter() {\n+ if (!this.frontMatter) {\n+ await this.read();\n+ }\n+\n+ return this.frontMatter;\n+ }\n+\n+ async getFrontMatterData() {\n+ if (!this.frontMatter) {\n+ await this.read();\n+ }\n+\n+ return this.frontMatter.data || {};\n+ }\n+\ngetLayoutTemplateFilePath(layoutPath) {\nreturn new TemplateLayout(layoutPath, this.layoutsDir).getFullPath();\n}\n@@ -180,10 +202,6 @@ class Template {\nreturn tmpl;\n}\n- getFrontMatterData() {\n- return this.frontMatter.data || {};\n- }\n-\nasync getAllLayoutFrontMatterData(tmpl, data, merged) {\ndebugDev(\"%o getAllLayoutFrontMatterData\", this.inputPath);\n@@ -196,7 +214,7 @@ class Template {\ndata[this.config.keys.layout]\n);\nlet layout = tmpl.getLayoutTemplate(layoutFilePath);\n- let layoutData = layout.getFrontMatterData();\n+ let layoutData = await layout.getFrontMatterData();\nreturn this.getAllLayoutFrontMatterData(\ntmpl,\n@@ -251,7 +269,7 @@ class Template {\ndata = await this.templateData.getLocalData(this.inputPath);\n}\n- let frontMatterData = this.getFrontMatterData();\n+ let frontMatterData = await this.getFrontMatterData();\nlet mergedLayoutData = await this.getAllLayoutFrontMatterData(\nthis,\n@@ -368,8 +386,11 @@ class Template {\nlet layoutData = await layout.getData(tmplData);\n// debug(\"layoutData: %O\", layoutData)\n// debug(\"tmplData (passed to layoutContent = renderContent(): %O\", tmplData);\n- // debug(\"renderLayout -> renderContent(%o)\", tmpl.getPreRender());\n- let layoutContent = await tmpl.renderContent(tmpl.getPreRender(), tmplData);\n+ // debug(\"renderLayout -> renderContent(%o)\", await tmpl.getPreRender());\n+ let layoutContent = await tmpl.renderContent(\n+ await tmpl.getPreRender(),\n+ tmplData\n+ );\n// debug(\"renderLayout -> layoutContent %o\", layoutContent);\nlayoutData.content = layoutContent;\n@@ -389,7 +410,7 @@ class Template {\nreturn tmpl.renderLayout(layout, layoutData);\n}\n- return layout.renderContent(layout.getPreRender(), layoutData);\n+ return layout.renderContent(await layout.getPreRender(), layoutData);\n}\nasync renderContent(str, data, bypassMarkdown) {\n@@ -455,7 +476,7 @@ class Template {\nreturn this.renderLayout(this, data, this.initialLayout);\n} else {\ndebugDev(\"Template.render renderContent for %o\", this.inputPath);\n- return this.renderContent(this.getPreRender(), data);\n+ return this.renderContent(await this.getPreRender(), data);\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateTest.js",
"new_path": "test/TemplateTest.js",
"diff": "@@ -90,14 +90,15 @@ test(\"HTML files output to the same as the input directory have a file suffix ad\nt.is(await tmpl.getOutputPath(), \"./test/stubs/subfolder/index-o.html\");\n});\n-test(\"Test raw front matter from template\", t => {\n+test(\"Test raw front matter from template\", async t => {\nlet tmpl = new Template(\n\"./test/stubs/templateFrontMatter.ejs\",\n\"./test/stubs/\",\n\"./dist\"\n);\n- t.truthy(tmpl.inputContent, \"template exists and can be opened.\");\n- t.is(tmpl.frontMatter.data.key1, \"value1\");\n+ t.truthy(await tmpl.getInputContent(), \"template exists and can be opened.\");\n+\n+ t.is((await tmpl.getFrontMatter()).data.key1, \"value1\");\n});\ntest(\"Test that getData() works\", async t => {\n@@ -113,7 +114,7 @@ test(\"Test that getData() works\", async t => {\nlet mergedFrontMatter = await tmpl.getAllLayoutFrontMatterData(\ntmpl,\n- tmpl.getFrontMatterData()\n+ await tmpl.getFrontMatterData()\n);\nt.is(mergedFrontMatter.key1, \"value1\");\n@@ -152,7 +153,7 @@ test(\"One Layout (using new content var)\", async t => {\ndataObj\n);\n- t.is(tmpl.frontMatter.data[config.keys.layout], \"defaultLayout\");\n+ t.is((await tmpl.getFrontMatter()).data[config.keys.layout], \"defaultLayout\");\nlet data = await tmpl.getData();\nt.is(data[config.keys.layout], \"defaultLayout\");\n@@ -166,7 +167,7 @@ test(\"One Layout (using new content var)\", async t => {\nlet mergedFrontMatter = await tmpl.getAllLayoutFrontMatterData(\ntmpl,\n- tmpl.getFrontMatterData()\n+ await tmpl.getFrontMatterData()\n);\nt.is(mergedFrontMatter.keymain, \"valuemain\");\n@@ -182,7 +183,10 @@ test(\"One Layout (using layoutContent)\", async t => {\ndataObj\n);\n- t.is(tmpl.frontMatter.data[config.keys.layout], \"defaultLayoutLayoutContent\");\n+ t.is(\n+ (await tmpl.getFrontMatter()).data[config.keys.layout],\n+ \"defaultLayoutLayoutContent\"\n+ );\nlet data = await tmpl.getData();\nt.is(data[config.keys.layout], \"defaultLayoutLayoutContent\");\n@@ -196,7 +200,7 @@ test(\"One Layout (using layoutContent)\", async t => {\nlet mergedFrontMatter = await tmpl.getAllLayoutFrontMatterData(\ntmpl,\n- tmpl.getFrontMatterData()\n+ await tmpl.getFrontMatterData()\n);\nt.is(mergedFrontMatter.keymain, \"valuemain\");\n@@ -214,7 +218,10 @@ test(\"One Layout (layouts disabled)\", async t => {\ntmpl.setWrapWithLayouts(false);\n- t.is(tmpl.frontMatter.data[config.keys.layout], \"defaultLayoutLayoutContent\");\n+ t.is(\n+ (await tmpl.getFrontMatter()).data[config.keys.layout],\n+ \"defaultLayoutLayoutContent\"\n+ );\nlet data = await tmpl.getData();\nt.is(data[config.keys.layout], \"defaultLayoutLayoutContent\");\n@@ -223,7 +230,7 @@ test(\"One Layout (layouts disabled)\", async t => {\nlet mergedFrontMatter = await tmpl.getAllLayoutFrontMatterData(\ntmpl,\n- tmpl.getFrontMatterData()\n+ await tmpl.getFrontMatterData()\n);\nt.is(mergedFrontMatter.keymain, \"valuemain\");\n@@ -240,7 +247,7 @@ test(\"One Layout (_layoutContent deprecated but supported)\", async t => {\n);\nt.is(\n- tmpl.frontMatter.data[config.keys.layout],\n+ (await tmpl.getFrontMatter()).data[config.keys.layout],\n\"defaultLayout_layoutContent\"\n);\n@@ -256,7 +263,7 @@ test(\"One Layout (_layoutContent deprecated but supported)\", async t => {\nlet mergedFrontMatter = await tmpl.getAllLayoutFrontMatterData(\ntmpl,\n- tmpl.getFrontMatterData()\n+ await tmpl.getFrontMatterData()\n);\nt.is(mergedFrontMatter.keymain, \"valuemain\");\n@@ -272,7 +279,10 @@ test(\"One Layout (liquid test)\", async t => {\ndataObj\n);\n- t.is(tmpl.frontMatter.data[config.keys.layout], \"layoutLiquid.liquid\");\n+ t.is(\n+ (await tmpl.getFrontMatter()).data[config.keys.layout],\n+ \"layoutLiquid.liquid\"\n+ );\nlet data = await tmpl.getData();\nt.is(data[config.keys.layout], \"layoutLiquid.liquid\");\n@@ -286,7 +296,7 @@ test(\"One Layout (liquid test)\", async t => {\nlet mergedFrontMatter = await tmpl.getAllLayoutFrontMatterData(\ntmpl,\n- tmpl.getFrontMatterData()\n+ await tmpl.getFrontMatterData()\n);\nt.is(mergedFrontMatter.keymain, \"valuemain\");\n@@ -302,7 +312,7 @@ test(\"Two Layouts\", async t => {\ndataObj\n);\n- t.is(tmpl.frontMatter.data[config.keys.layout], \"layout-a\");\n+ t.is((await tmpl.getFrontMatter()).data[config.keys.layout], \"layout-a\");\nlet data = await tmpl.getData();\nt.is(data[config.keys.layout], \"layout-a\");\n@@ -319,7 +329,7 @@ test(\"Two Layouts\", async t => {\nlet mergedFrontMatter = await tmpl.getAllLayoutFrontMatterData(\ntmpl,\n- tmpl.getFrontMatterData()\n+ await tmpl.getFrontMatterData()\n);\nt.is(mergedFrontMatter.daysPosted, 152);\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Switch to an async file read |
699 | 21.05.2018 08:23:18 | 18,000 | b6dc9b0fee03aa185de1e7b5e0e6c8b32786860d | Fixes wraps it all in a try catch. | [
{
"change_type": "MODIFY",
"old_path": "cmd.js",
"new_path": "cmd.js",
"diff": "@@ -8,18 +8,19 @@ const EleventyNodeVersionCheck = require(\"./src/VersionCheck\");\nEleventyNodeVersionCheck().then(\nfunction() {\n+ const chalk = require(\"chalk\");\nconst Eleventy = require(\"./src/Eleventy\");\nconst EleventyCommandCheck = require(\"./src/EleventyCommandCheck\");\n- let cmdCheck = new EleventyCommandCheck(argv);\ntry {\n+ let cmdCheck = new EleventyCommandCheck(argv);\ncmdCheck.hasUnknownArguments();\n} catch (e) {\n- const chalk = require(\"chalk\");\n- console.log(chalk.red(e.toString()));\n+ console.log(chalk.red(\"Eleventy error:\"), chalk.red(e.toString()));\nreturn;\n}\n+ try {\nlet elev = new Eleventy(argv.input, argv.output);\nelev.setConfigPath(argv.config);\nelev.setPathPrefix(argv.pathprefix);\n@@ -46,6 +47,9 @@ EleventyNodeVersionCheck().then(\n});\n}\n});\n+ } catch (e) {\n+ console.log(chalk.red(\"Eleventy error:\"), e);\n+ }\n},\nfunction(error) {\n// EleventyNodeVersionCheck rejection\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Fixes #110, wraps it all in a try catch. |
699 | 21.05.2018 08:27:38 | 18,000 | 4817962a1bfe57f501b81b4f8870b4c4f8bd7105 | Fix for .htaccess (all files starting with dot) in passthrough copies | [
{
"change_type": "MODIFY",
"old_path": "src/TemplatePath.js",
"new_path": "src/TemplatePath.js",
"diff": "const path = require(\"path\");\nconst normalize = require(\"normalize-path\");\n-const pify = require(\"pify\");\nconst fs = require(\"fs-extra\");\nfunction TemplatePath() {}\n@@ -105,7 +104,7 @@ TemplatePath.stripPathFromDir = function(targetDir, prunedPath) {\ntargetDir = TemplatePath.stripLeadingDotSlash(normalize(targetDir));\nprunedPath = TemplatePath.stripLeadingDotSlash(normalize(prunedPath));\n- if (targetDir.indexOf(prunedPath) === 0) {\n+ if (prunedPath && prunedPath !== \".\" && targetDir.indexOf(prunedPath) === 0) {\nreturn targetDir.substr(prunedPath.length + 1);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplatePassthroughTest.js",
"new_path": "test/TemplatePassthroughTest.js",
"diff": "@@ -93,3 +93,15 @@ test(\"Full input file path and deep input path\", t => {\n\"_site/avatar.png\"\n);\n});\n+\n+test(\".htaccess\", t => {\n+ let pass = new TemplatePassthrough(\".htaccess\", \"_site\", \".\");\n+ t.truthy(pass);\n+ t.is(pass.getOutputPath(), \"_site/.htaccess\");\n+});\n+\n+test(\".htaccess with input dir\", t => {\n+ let pass = new TemplatePassthrough(\".htaccess\", \"_site\", \"_src\");\n+ t.truthy(pass);\n+ t.is(pass.getOutputPath(), \"_site/.htaccess\");\n+});\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplatePathTest.js",
"new_path": "test/TemplatePathTest.js",
"diff": "import test from \"ava\";\nimport path from \"path\";\n+import normalize from \"normalize-path\";\nimport TemplatePath from \"../src/TemplatePath\";\ntest(\"Working dir\", t => {\n@@ -26,6 +27,9 @@ test(\"Normalizer\", async t => {\nt.is(TemplatePath.normalize(\"./testing\", \"hello/\"), \"testing/hello\");\nt.is(TemplatePath.normalize(\"./testing/hello\"), \"testing/hello\");\nt.is(TemplatePath.normalize(\"./testing/hello/\"), \"testing/hello\");\n+\n+ t.is(normalize(\".htaccess\"), \".htaccess\");\n+ t.is(TemplatePath.normalize(\".htaccess\"), \".htaccess\");\n});\ntest(\"stripLeadingDotSlash\", t => {\n@@ -33,6 +37,8 @@ test(\"stripLeadingDotSlash\", t => {\nt.is(TemplatePath.stripLeadingDotSlash(\"./dist\"), \"dist\");\nt.is(TemplatePath.stripLeadingDotSlash(\"../dist\"), \"../dist\");\nt.is(TemplatePath.stripLeadingDotSlash(\"dist\"), \"dist\");\n+\n+ t.is(TemplatePath.stripLeadingDotSlash(\".htaccess\"), \".htaccess\");\n});\ntest(\"hasTrailingSlash\", t => {\n@@ -94,6 +100,9 @@ test(\"stripPathFromDir\", t => {\nTemplatePath.stripPathFromDir(\"testing/hello/subdir/test\", \"testing\"),\n\"hello/subdir/test\"\n);\n+\n+ t.is(TemplatePath.stripPathFromDir(\".htaccess\", \"./\"), \".htaccess\");\n+ t.is(TemplatePath.stripPathFromDir(\".htaccess\", \".\"), \".htaccess\");\n});\ntest(\"getLastDir\", t => {\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Fix for .htaccess (all files starting with dot) in passthrough copies |
699 | 21.05.2018 08:36:41 | 18,000 | d44c66ba7de3fe31138af42485cc6e36d9dc293a | make sure path exists when comparing isInclude, removes pify (superfluous with fs-extra) | [
{
"change_type": "MODIFY",
"old_path": "src/Eleventy.js",
"new_path": "src/Eleventy.js",
"diff": "@@ -10,7 +10,6 @@ const templateCache = require(\"./TemplateCache\");\nconst EleventyError = require(\"./EleventyError\");\nconst simplePlural = require(\"./Util/Pluralize\");\nconst config = require(\"./Config\");\n-const pkg = require(\"../package.json\");\nconst debug = require(\"debug\")(\"Eleventy\");\nfunction Eleventy(input, output) {\n@@ -170,7 +169,7 @@ Eleventy.prototype.setFormats = function(formats) {\n};\nEleventy.prototype.getVersion = function() {\n- return pkg.version;\n+ return require(\"../package.json\").version;\n};\nEleventy.prototype.getHelp = function() {\n@@ -228,7 +227,8 @@ Eleventy.prototype._watch = async function(path) {\nthis.restart();\nawait this.write();\n- let isInclude = TemplatePath.contains(path, this.writer.getIncludesDir());\n+ let isInclude =\n+ path && TemplatePath.contains(path, this.writer.getIncludesDir());\nthis.eleventyServe.reload(path, isInclude);\nthis.active = false;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Template.js",
"new_path": "src/Template.js",
"diff": "-const pify = require(\"pify\");\nconst fs = require(\"fs-extra\");\nconst parsePath = require(\"parse-filepath\");\nconst matter = require(\"gray-matter\");\n@@ -594,7 +593,7 @@ class Template {\ndebug(\"getMappedDate: YAML parsed it: %o\", data.date);\nreturn data.date;\n} else {\n- let stat = await pify(fs.stat)(this.inputPath);\n+ let stat = await fs.stat(this.inputPath);\n// string\nif (data.date.toLowerCase() === \"last modified\") {\nreturn new Date(stat.ctimeMs);\n@@ -633,7 +632,7 @@ class Template {\nreturn dateObj;\n}\n- let stat = await pify(fs.stat)(this.inputPath);\n+ let stat = await fs.stat(this.inputPath);\nlet createdDate = new Date(stat.birthtimeMs);\ndebug(\n\"getMappedDate: using file created time for %o of %o\",\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateData.js",
"new_path": "src/TemplateData.js",
"diff": "const fs = require(\"fs-extra\");\n-const pify = require(\"pify\");\nconst globby = require(\"globby\");\nconst parsePath = require(\"parse-filepath\");\nconst lodashset = require(\"lodash.set\");\n@@ -64,7 +63,7 @@ TemplateData.prototype.getGlobalDataGlob = async function() {\nlet dir = \".\";\nif (this.inputDir) {\n- let globalPathStat = await pify(fs.stat)(this.inputDir);\n+ let globalPathStat = await fs.stat(this.inputDir);\nif (!globalPathStat.isDirectory()) {\nthrow new Error(\"Could not find data path directory: \" + this.inputDir);\n@@ -145,7 +144,7 @@ TemplateData.prototype.getLocalData = async function(templatePath) {\nTemplateData.prototype._getLocalJson = async function(path) {\nlet rawInput;\ntry {\n- rawInput = await pify(fs.readFile)(path, \"utf-8\");\n+ rawInput = await fs.readFile(path, \"utf-8\");\n} catch (e) {\n// if file does not exist, return nothing\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateWriter.js",
"new_path": "src/TemplateWriter.js",
"diff": "@@ -200,7 +200,7 @@ TemplateWriter.prototype.getTemplateIgnores = function() {\n};\nTemplateWriter.prototype._getAllPaths = async function() {\n- debug(\"Searching for: %O\", this.templateGlobsWithIgnores);\n+ debug(\"Searching for: %o\", this.templateGlobsWithIgnores);\nif (!this.cachedPaths) {\n// Note the gitignore: true option for globby is _really slow_\nthis.cachedPaths = await globby(this.templateGlobsWithIgnores); //, { gitignore: true });\n"
}
] | JavaScript | MIT License | 11ty/eleventy | make sure path exists when comparing isInclude, removes pify (superfluous with fs-extra) |
699 | 25.05.2018 00:01:09 | 18,000 | 92111be28bffa0721081f68292aa4f1149f56038 | Add some tests around | [
{
"change_type": "MODIFY",
"old_path": "src/TemplateCollection.js",
"new_path": "src/TemplateCollection.js",
"diff": "@@ -29,14 +29,20 @@ class TemplateCollection extends Sortable {\n});\n}\n- getFilteredByGlob(globs) {\n+ getGlobs(globs) {\nif (typeof globs === \"string\") {\nglobs = [globs];\n}\n- return this._cache(\"getFilteredByGlob:\" + globs.join(\",\"), function() {\nglobs = globs.map(glob => TemplatePath.addLeadingDotSlash(glob));\n+ return globs;\n+ }\n+\n+ getFilteredByGlob(globs) {\n+ globs = this.getGlobs(globs);\n+\n+ return this._cache(\"getFilteredByGlob:\" + globs.join(\",\"), function() {\nreturn this.getAllSorted().filter(item => {\nif (multimatch([item.inputPath], globs).length) {\nreturn true;\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateCollectionTest.js",
"new_path": "test/TemplateCollectionTest.js",
"diff": "import test from \"ava\";\n+import multimatch from \"multimatch\";\nimport Template from \"../src/Template\";\nimport Collection from \"../src/TemplateCollection\";\nimport Sortable from \"../src/Util/Sortable\";\n@@ -148,3 +149,34 @@ test(\"partial match on tag string, issue 95\", async t => {\nlet posts = c.getFilteredByTag(\"cat\");\nt.is(posts.length, 1);\n});\n+\n+test(\"multimatch assumptions, issue #127\", async t => {\n+ t.deepEqual(\n+ multimatch(\n+ [\"src/bookmarks/test.md\"],\n+ \"**/+(bookmarks|posts|screencasts)/**/!(index)*.md\"\n+ ),\n+ [\"src/bookmarks/test.md\"]\n+ );\n+ t.deepEqual(\n+ multimatch(\n+ [\"./src/bookmarks/test.md\"],\n+ \"./**/+(bookmarks|posts|screencasts)/**/!(index)*.md\"\n+ ),\n+ [\"./src/bookmarks/test.md\"]\n+ );\n+\n+ let c = new Collection();\n+ let globs = c.getGlobs(\"**/+(bookmarks|posts|screencasts)/**/!(index)*.md\");\n+ t.deepEqual(globs, [\"./**/+(bookmarks|posts|screencasts)/**/!(index)*.md\"]);\n+\n+ t.deepEqual(multimatch([\"./src/bookmarks/test.md\"], globs), [\n+ \"./src/bookmarks/test.md\"\n+ ]);\n+ t.deepEqual(multimatch([\"./src/bookmarks/index.md\"], globs), []);\n+ t.deepEqual(multimatch([\"./src/bookmarks/index2.md\"], globs), []);\n+ t.deepEqual(\n+ multimatch([\"./src/_content/bookmarks/2018-03-27-git-message.md\"], globs),\n+ [\"./src/_content/bookmarks/2018-03-27-git-message.md\"]\n+ );\n+});\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Add some tests around #127 |
699 | 31.05.2018 08:01:58 | 18,000 | 00442d29a9a5f8ebe9a9e6f7e8fce26b25cb92b5 | Regression with data.page.url and data.page.outputPath for | [
{
"change_type": "MODIFY",
"old_path": "src/Template.js",
"new_path": "src/Template.js",
"diff": "@@ -499,13 +499,16 @@ class Template {\nlet results = [];\nif (!Pagination.hasPagination(data)) {\n+ data.page.url = await this.getOutputHref(data);\n+ data.page.outputPath = await this.getOutputPath(data);\n+\nresults.push({\ntemplate: this,\ninputPath: this.inputPath,\ndata: data,\ndate: data.page.date,\n- outputPath: await this.getOutputPath(data),\n- url: await this.getOutputHref(data)\n+ outputPath: data.page.outputPath,\n+ url: data.page.url\n});\n} else {\n// needs collections for pagination items\n"
},
{
"change_type": "MODIFY",
"old_path": "test/PaginationTest.js",
"new_path": "test/PaginationTest.js",
"diff": "@@ -325,3 +325,35 @@ test(\"Issue 135\", async t => {\n\"./dist/blog/do-you-even-paginate-bro/index.html\"\n);\n});\n+\n+test(\"Template with Pagination, getTemplates has page variables set\", async t => {\n+ let tmpl = new Template(\n+ \"./test/stubs/paged/pagedpermalinkif.njk\",\n+ \"./test/stubs/\",\n+ \"./dist\"\n+ );\n+\n+ let data = await tmpl.getData();\n+ let templates = await tmpl.getTemplates(data);\n+ t.is(templates[0].data.page.url, \"/paged/\");\n+ t.is(templates[0].data.page.outputPath, \"./dist/paged/index.html\");\n+\n+ t.is(templates[1].data.page.url, \"/paged/page-1/\");\n+ t.is(templates[1].data.page.outputPath, \"./dist/paged/page-1/index.html\");\n+});\n+\n+test(\"Template with Pagination, getRenderedTemplates has page variables set\", async t => {\n+ let tmpl = new Template(\n+ \"./test/stubs/paged/pagedpermalinkif.njk\",\n+ \"./test/stubs/\",\n+ \"./dist\"\n+ );\n+\n+ let data = await tmpl.getData();\n+ let templates = await tmpl.getRenderedTemplates(data);\n+ t.is(templates[0].data.page.url, \"/paged/\");\n+ t.is(templates[0].data.page.outputPath, \"./dist/paged/index.html\");\n+\n+ t.is(templates[1].data.page.url, \"/paged/page-1/\");\n+ t.is(templates[1].data.page.outputPath, \"./dist/paged/page-1/index.html\");\n+});\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateTest.js",
"new_path": "test/TemplateTest.js",
"diff": "@@ -745,6 +745,32 @@ test(\"getRenderedData() has page.url\", async t => {\nt.truthy(data.page.url);\n});\n+test(\"getTemplates() data has page.url\", async t => {\n+ let tmpl = new Template(\n+ \"./test/stubs/template.ejs\",\n+ \"./test/stubs/\",\n+ \"./dist\"\n+ );\n+ let data = await tmpl.getData();\n+ let templates = await tmpl.getTemplates(data);\n+\n+ t.is(templates[0].data.page.url, \"/template/\");\n+ t.is(templates[0].data.page.outputPath, \"./dist/template/index.html\");\n+});\n+\n+test(\"getRenderedTemplates() data has page.url\", async t => {\n+ let tmpl = new Template(\n+ \"./test/stubs/template.ejs\",\n+ \"./test/stubs/\",\n+ \"./dist\"\n+ );\n+ let data = await tmpl.getData();\n+\n+ let templates = await tmpl.getRenderedTemplates(data);\n+ t.is(templates[0].data.page.url, \"/template/\");\n+ t.is(templates[0].data.page.outputPath, \"./dist/template/index.html\");\n+});\n+\ntest(\"getRenderedData() has page.url\", async t => {\nlet tmpl = new Template(\n\"./test/stubs/template.ejs\",\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Regression with data.page.url and data.page.outputPath for #135 |
699 | 01.06.2018 08:08:16 | 18,000 | 4beb9c105a20b0c07e9400a7777c31f7dc4e3c25 | Regressions around url and outputPath in collections, | [
{
"change_type": "MODIFY",
"old_path": "src/Template.js",
"new_path": "src/Template.js",
"diff": "@@ -11,6 +11,7 @@ const TemplateLayout = require(\"./TemplateLayout\");\nconst TemplateFileSlug = require(\"./TemplateFileSlug\");\nconst templateCache = require(\"./TemplateCache\");\nconst Pagination = require(\"./Plugins/Pagination\");\n+const EleventyError = require(\"./EleventyError\");\nconst config = require(\"./Config\");\nconst debug = require(\"debug\")(\"Eleventy:Template\");\nconst debugDev = require(\"debug\")(\"Dev:Eleventy:Template\");\n@@ -438,9 +439,18 @@ class Template {\nthis.templateRender.engineName\n);\n+ try {\nlet fn = await this.templateRender.getCompiledTemplate(str);\n- let rendered = fn(data);\n+ let rendered = await fn(data);\nreturn rendered;\n+ } catch (e) {\n+ throw EleventyError.make(\n+ new Error(\n+ `Having trouble rendering template ${this.inputPath}: ${str}`\n+ ),\n+ e\n+ );\n+ }\n}\nasync _testRenderWithoutLayouts(data) {\n@@ -495,7 +505,7 @@ class Template {\n}\nasync getTemplates(data) {\n- // TODO cache this result\n+ // TODO cache this\nlet results = [];\nif (!Pagination.hasPagination(data)) {\n@@ -679,16 +689,24 @@ class Template {\n};\n}\n- async getSecondaryMapEntry(data) {\n+ async getSecondaryMapEntry(page) {\n+ return {\n+ url: page.url,\n+ outputPath: page.outputPath\n+ };\n+ }\n+\n+ async getTertiaryMapEntry(page) {\nthis.setWrapWithLayouts(false);\n- let mapEntry = (await this.getRenderedTemplates(data))[0];\n+ let mapEntry = {\n+ templateContent: await page.template._getContent(\n+ page.outputPath,\n+ page.data\n+ )\n+ };\nthis.setWrapWithLayouts(true);\n- return {\n- outputPath: mapEntry.outputPath,\n- url: mapEntry.url,\n- templateContent: mapEntry.templateContent\n- };\n+ return mapEntry;\n}\nasync getMapped() {\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateMapTest.js",
"new_path": "test/TemplateMapTest.js",
"diff": "@@ -110,6 +110,7 @@ test(\"TemplateMap circular references (map without templateContent)\", async t =>\nt.truthy(map[0].templateContent);\nt.truthy(map[0].data.collections);\nt.is(map[0].data.collections.all.length, 1);\n+\nt.is(\nawait map[0].template._testRenderWithoutLayouts(map[0].data),\nmap[0].templateContent\n@@ -264,3 +265,36 @@ This page is bars\n`\n);\n});\n+\n+test(\"TemplateMap adds collections data and has page data values\", async t => {\n+ let tm = new TemplateMap();\n+ await tm.add(tmpl1);\n+ await tm.add(tmpl2);\n+\n+ let map = tm.getMap();\n+ await tm.cache();\n+ t.is(map[0].data.page.url, \"/templateMapCollection/test1/\");\n+ t.is(\n+ map[0].data.page.outputPath,\n+ \"./test/stubs/_site/templateMapCollection/test1/index.html\"\n+ );\n+});\n+\n+test(\"TemplateMap adds collections data and has page data values\", async t => {\n+ let tm = new TemplateMap();\n+ await tm.add(tmpl1);\n+ await tm.add(tmpl2);\n+\n+ let collections = await tm.getCollectionsData();\n+ t.is(collections.all[0].url, \"/templateMapCollection/test1/\");\n+ t.is(\n+ collections.all[0].outputPath,\n+ \"./test/stubs/_site/templateMapCollection/test1/index.html\"\n+ );\n+\n+ t.is(collections.all[0].data.page.url, \"/templateMapCollection/test1/\");\n+ t.is(\n+ collections.all[0].data.page.outputPath,\n+ \"./test/stubs/_site/templateMapCollection/test1/index.html\"\n+ );\n+});\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Regressions around url and outputPath in collections, #135 |
699 | 01.06.2018 08:09:05 | 18,000 | 93d1a6cd4cc9cbe10df9280b256651fe172a28e9 | Better handling of vague indexOf errors when passing non-string values to url filter | [
{
"change_type": "MODIFY",
"old_path": "src/Filters/Url.js",
"new_path": "src/Filters/Url.js",
"diff": "@@ -2,6 +2,9 @@ const validUrl = require(\"valid-url\");\nconst TemplatePath = require(\"../TemplatePath\");\nmodule.exports = function(url, pathPrefix) {\n+ // work with undefined\n+ url = url || \"\";\n+\nif (\nvalidUrl.isUri(url) ||\nurl.indexOf(\"http://\") === 0 ||\n"
},
{
"change_type": "MODIFY",
"old_path": "test/UrlTest.js",
"new_path": "test/UrlTest.js",
"diff": "@@ -105,6 +105,7 @@ test(\"Test url filter with passthrough urls\", t => {\ntest(\"Test url filter\", t => {\nt.is(url(\"/\", \"/\"), \"/\");\nt.is(url(\"//\", \"/\"), \"/\");\n+ t.is(url(undefined, \"/\"), \".\");\nt.is(url(\"\", \"/\"), \".\");\n// leave . and .. alone\n@@ -129,6 +130,7 @@ test(\"Test url filter\", t => {\ntest(\"Test url filter with custom pathPrefix (empty, gets overwritten by root config `/`)\", t => {\nt.is(url(\"/\", \"\"), \"/\");\nt.is(url(\"//\", \"\"), \"/\");\n+ t.is(url(undefined, \"\"), \".\");\nt.is(url(\"\", \"\"), \".\");\n// leave . and .. alone\n@@ -153,6 +155,7 @@ test(\"Test url filter with custom pathPrefix (empty, gets overwritten by root co\ntest(\"Test url filter with custom pathPrefix (leading slash)\", t => {\nt.is(url(\"/\", \"/testdir\"), \"/testdir/\");\nt.is(url(\"//\", \"/testdir\"), \"/testdir/\");\n+ t.is(url(undefined, \"/testdir\"), \".\");\nt.is(url(\"\", \"/testdir\"), \".\");\n// leave . and .. alone\n@@ -177,6 +180,7 @@ test(\"Test url filter with custom pathPrefix (leading slash)\", t => {\ntest(\"Test url filter with custom pathPrefix (double slash)\", t => {\nt.is(url(\"/\", \"/testdir/\"), \"/testdir/\");\nt.is(url(\"//\", \"/testdir/\"), \"/testdir/\");\n+ t.is(url(undefined, \"/testdir/\"), \".\");\nt.is(url(\"\", \"/testdir/\"), \".\");\n// leave . and .. alone\n@@ -201,6 +205,7 @@ test(\"Test url filter with custom pathPrefix (double slash)\", t => {\ntest(\"Test url filter with custom pathPrefix (trailing slash)\", t => {\nt.is(url(\"/\", \"testdir/\"), \"/testdir/\");\nt.is(url(\"//\", \"testdir/\"), \"/testdir/\");\n+ t.is(url(undefined, \"testdir/\"), \".\");\nt.is(url(\"\", \"testdir/\"), \".\");\n// leave . and .. alone\n@@ -225,6 +230,7 @@ test(\"Test url filter with custom pathPrefix (trailing slash)\", t => {\ntest(\"Test url filter with custom pathPrefix (no slash)\", t => {\nt.is(url(\"/\", \"testdir\"), \"/testdir/\");\nt.is(url(\"//\", \"testdir\"), \"/testdir/\");\n+ t.is(url(undefined, \"testdir\"), \".\");\nt.is(url(\"\", \"testdir\"), \".\");\n// leave . and .. alone\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Better handling of vague indexOf errors when passing non-string values to url filter |
699 | 01.06.2018 21:33:58 | 18,000 | ee969d543f06c864ce25fe13d0894b5b25f7f3a1 | Add tests and docs around existing support for JSON and JS front matter. | [
{
"change_type": "MODIFY",
"old_path": "test/TemplateTest.js",
"new_path": "test/TemplateTest.js",
"diff": "@@ -90,7 +90,8 @@ test(\"HTML files output to the same as the input directory have a file suffix ad\nt.is(await tmpl.getOutputPath(), \"./test/stubs/subfolder/index-o.html\");\n});\n-test(\"Test raw front matter from template\", async t => {\n+test(\"Test raw front matter from template (yaml)\", async t => {\n+ // https://github.com/jonschlinkert/gray-matter/blob/master/examples/yaml.js\nlet tmpl = new Template(\n\"./test/stubs/templateFrontMatter.ejs\",\n\"./test/stubs/\",\n@@ -99,6 +100,52 @@ test(\"Test raw front matter from template\", async t => {\nt.truthy(await tmpl.getInputContent(), \"template exists and can be opened.\");\nt.is((await tmpl.getFrontMatter()).data.key1, \"value1\");\n+ t.is((await tmpl.getFrontMatter()).data.key3, \"value3\");\n+\n+ let data = await tmpl.getData();\n+ t.is(data.key1, \"value1\");\n+ t.is(data.key3, \"value3\");\n+\n+ let pages = await tmpl.getRenderedTemplates(data);\n+ t.is(pages[0].templateContent.trim(), \"c:value1:value2:value3\");\n+});\n+\n+test(\"Test raw front matter from template (json)\", async t => {\n+ // https://github.com/jonschlinkert/gray-matter/blob/master/examples/json.js\n+ let tmpl = new Template(\n+ \"./test/stubs/templateFrontMatterJson.ejs\",\n+ \"./test/stubs/\",\n+ \"./dist\"\n+ );\n+\n+ t.is((await tmpl.getFrontMatter()).data.key1, \"value1\");\n+ t.is((await tmpl.getFrontMatter()).data.key3, \"value3\");\n+\n+ let data = await tmpl.getData();\n+ t.is(data.key1, \"value1\");\n+ t.is(data.key3, \"value3\");\n+\n+ let pages = await tmpl.getRenderedTemplates(data);\n+ t.is(pages[0].templateContent.trim(), \"c:value1:value2:value3\");\n+});\n+\n+test(\"Test raw front matter from template (js)\", async t => {\n+ // https://github.com/jonschlinkert/gray-matter/blob/master/examples/javascript.js\n+ let tmpl = new Template(\n+ \"./test/stubs/templateFrontMatterJs.ejs\",\n+ \"./test/stubs/\",\n+ \"./dist\"\n+ );\n+\n+ t.is((await tmpl.getFrontMatter()).data.key1, \"value1\");\n+ t.is((await tmpl.getFrontMatter()).data.key3, \"value3\");\n+\n+ let data = await tmpl.getData();\n+ t.is(data.key1, \"value1\");\n+ t.is(data.key3, \"value3\");\n+\n+ let pages = await tmpl.getRenderedTemplates(data);\n+ t.is(pages[0].templateContent.trim(), \"c:value1:VALUE2:value3\");\n});\ntest(\"Test that getData() works\", async t => {\n"
},
{
"change_type": "MODIFY",
"old_path": "test/stubs/templateFrontMatter.ejs",
"new_path": "test/stubs/templateFrontMatter.ejs",
"diff": "---\nkey1: value1\n+key2: value2\nkey3: value3\n---\n-\nc:<%= key1 %>:<%= key2 %>:<%= key3 %>\n\\ No newline at end of file\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/templateFrontMatterJs.ejs",
"diff": "+---js\n+{\n+ key1: \"value1\",\n+ key2: function(value) {\n+ return value.toUpperCase();\n+ },\n+ key3: \"value3\"\n+}\n+---\n+c:<%= key1 %>:<%= key2(\"value2\") %>:<%= key3 %>\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/templateFrontMatterJson.ejs",
"diff": "+---json\n+{\n+ \"key1\": \"value1\",\n+ \"key2\": \"value2\",\n+ \"key3\": \"value3\"\n+}\n+---\n+c:<%= key1 %>:<%= key2 %>:<%= key3 %>\n\\ No newline at end of file\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Add tests and docs around existing support for JSON and JS front matter. |
699 | 06.06.2018 17:23:37 | 18,000 | 26b13f53d5d2fe0a969cfac3424020160a26a532 | Add logo to README and keywords to package.json | [
{
"change_type": "ADD",
"old_path": "docs/logo-github.png",
"new_path": "docs/logo-github.png",
"diff": "Binary files /dev/null and b/docs/logo-github.png differ\n"
},
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"engines\": {\n\"node\": \">=8.0.0\"\n},\n+ \"keywords\": [\n+ \"static-site-generator\",\n+ \"ssg\",\n+ \"documentation\",\n+ \"website\",\n+ \"jekyll\",\n+ \"blog\",\n+ \"templates\",\n+ \"generator\",\n+ \"framework\",\n+ \"eleventy\",\n+ \"11ty\",\n+ \"html\",\n+ \"markdown\",\n+ \"liquid\",\n+ \"nunjucks\",\n+ \"pug\",\n+ \"handlebars\",\n+ \"mustache\",\n+ \"ejs\",\n+ \"haml\"\n+ ],\n\"bin\": {\n\"eleventy\": \"./cmd.js\"\n},\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Add logo to README and keywords to package.json |
699 | 07.06.2018 17:37:54 | 18,000 | d5aea60087968607194465acb9207cafe98db662 | Pay the piper | [
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "},\n\"keywords\": [\n\"static-site-generator\",\n+ \"static-site\",\n\"ssg\",\n\"documentation\",\n\"website\",\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Pay the piper |
699 | 13.06.2018 21:37:24 | 18,000 | 6097248829e21d9e2477988b0a8fc9aa0c530b58 | Add `filter` for pagination to blacklist entries from pagination results. | [
{
"change_type": "MODIFY",
"old_path": "src/Plugins/Pagination.js",
"new_path": "src/Plugins/Pagination.js",
"diff": "@@ -59,6 +59,19 @@ Pagination.prototype.resolveObjectToValues = function() {\nreturn false;\n};\n+Pagination.prototype.isFiltered = function(value) {\n+ if (\"filter\" in this.data.pagination) {\n+ let filtered = this.data.pagination.filter;\n+ if (Array.isArray(filtered)) {\n+ return filtered.indexOf(value) > -1;\n+ }\n+\n+ return filtered === value;\n+ }\n+\n+ return false;\n+};\n+\nPagination.prototype._resolveItems = function() {\nlet notFoundValue = \"__NOT_FOUND_ERROR__\";\nlet key = this._getDataKey();\n@@ -77,7 +90,11 @@ Pagination.prototype._resolveItems = function() {\n}\n}\n- return ret;\n+ return ret.filter(\n+ function(value) {\n+ return !this.isFiltered(value);\n+ }.bind(this)\n+ );\n};\nPagination.prototype.getPagedItems = function() {\n"
},
{
"change_type": "MODIFY",
"old_path": "test/PaginationTest.js",
"new_path": "test/PaginationTest.js",
"diff": "@@ -415,3 +415,51 @@ test(\"Page over an object (use values)\", async t => {\n\"<ol><li>itemvalue5</li><li>itemvalue6</li><li>itemvalue7</li><li>itemvalue8</li></ol>\"\n);\n});\n+\n+test(\"Page over an object (filtered, array)\", async t => {\n+ let tmpl = new Template(\n+ \"./test/stubs/paged/pagedobjectfilterarray.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+ t.is(pages.length, 2);\n+\n+ t.is(\n+ (await pages[0].render()).trim(),\n+ \"<ol><li>item1</li><li>item2</li><li>item3</li><li>item5</li></ol>\"\n+ );\n+\n+ t.is(\n+ (await pages[1].render()).trim(),\n+ \"<ol><li>item6</li><li>item7</li><li>item8</li><li>item9</li></ol>\"\n+ );\n+});\n+\n+test(\"Page over an object (filtered, string)\", async t => {\n+ let tmpl = new Template(\n+ \"./test/stubs/paged/pagedobjectfilterstring.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+ t.is(pages.length, 2);\n+\n+ t.is(\n+ (await pages[0].render()).trim(),\n+ \"<ol><li>item1</li><li>item2</li><li>item3</li><li>item5</li></ol>\"\n+ );\n+\n+ t.is(\n+ (await pages[1].render()).trim(),\n+ \"<ol><li>item6</li><li>item7</li><li>item8</li><li>item9</li></ol>\"\n+ );\n+});\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/paged/pagedobjectfilterarray.njk",
"diff": "+---\n+pagination:\n+ data: testdata\n+ size: 4\n+ filter:\n+ - item4\n+testdata:\n+ item1: itemvalue1\n+ item2: itemvalue2\n+ item3: itemvalue3\n+ item4: itemvalue4\n+ item5: itemvalue5\n+ item6: itemvalue6\n+ item7: itemvalue7\n+ item8: itemvalue8\n+ item9: itemvalue9\n+---\n+<ol>{% for item in pagination.items %}<li>{{ item }}</li>{% endfor %}</ol>\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/paged/pagedobjectfilterstring.njk",
"diff": "+---\n+pagination:\n+ data: testdata\n+ size: 4\n+ filter: item4\n+testdata:\n+ item1: itemvalue1\n+ item2: itemvalue2\n+ item3: itemvalue3\n+ item4: itemvalue4\n+ item5: itemvalue5\n+ item6: itemvalue6\n+ item7: itemvalue7\n+ item8: itemvalue8\n+ item9: itemvalue9\n+---\n+<ol>{% for item in pagination.items %}<li>{{ item }}</li>{% endfor %}</ol>\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Add `filter` for pagination to blacklist entries from pagination results. |
699 | 14.06.2018 08:42:31 | 18,000 | f33ba8cf0bf72b931d8ca411ece0effde82ffefd | Better support for buffers returned from js templates, adds data support in template classes (getters or functions) | [
{
"change_type": "MODIFY",
"old_path": "src/Engines/JavaScript.js",
"new_path": "src/Engines/JavaScript.js",
"diff": "const TemplateEngine = require(\"./TemplateEngine\");\n+const lodashMerge = require(\"lodash.merge\");\nclass JavaScript extends TemplateEngine {\nasync compile(str, inputPath) {\n@@ -10,12 +11,31 @@ class JavaScript extends TemplateEngine {\n} else if (typeof cls === \"function\") {\nif (cls.prototype && \"render\" in cls.prototype) {\nlet inst = new cls(inputPath);\n+ let dataOverrides;\n+\n+ if (cls.prototype && \"data\" in cls.prototype) {\n+ // work with getter or function\n+ dataOverrides =\n+ typeof inst.data === \"function\" ? inst.data() : inst.data;\n+ }\n+\nreturn function(data) {\n+ if (dataOverrides) {\n+ return inst.render(lodashMerge({}, data, dataOverrides));\n+ }\n+\nreturn inst.render(data);\n};\n}\n- return cls;\n+ return function(data) {\n+ let result = cls(data || {});\n+ if (Buffer.isBuffer(result)) {\n+ return result.toString();\n+ }\n+\n+ return result;\n+ };\n}\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateRenderJavaScriptTest.js",
"new_path": "test/TemplateRenderJavaScriptTest.js",
"diff": "@@ -29,6 +29,30 @@ test(\"JS Render with a Class\", async t => {\nt.is(await fn({ name: \"Bill\" }), \"<p>Bill</p>\");\n});\n+test(\"JS Render with a Class, async render\", async t => {\n+ let fn = await new TemplateRender(\n+ \"../../test/stubs/class-template-literal-async.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+\n+test(\"JS Render with a Class and Data getter\", async t => {\n+ let fn = await new TemplateRender(\n+ \"../../test/stubs/class-template-literal-data.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-template-literal-data-fn.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.js\"\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/class-template-literal-async.js",
"diff": "+class Test {\n+ async render(data) {\n+ return `<p>${data.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.js",
"diff": "+class Test {\n+ data() {\n+ return {\n+ name: \"Ted\"\n+ };\n+ }\n+\n+ render(data) {\n+ return `<p>${data.name}</p>`;\n+ }\n+}\n+\n+module.exports = Test;\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/class-template-literal-data.js",
"diff": "+class Test {\n+ get data() {\n+ return {\n+ name: \"Ted\"\n+ };\n+ }\n+\n+ render(data) {\n+ return `<p>${data.name}</p>`;\n+ }\n+}\n+\n+module.exports = Test;\n"
},
{
"change_type": "MODIFY",
"old_path": "test/stubs/viperhtml.js",
"new_path": "test/stubs/viperhtml.js",
"diff": "const viperHTML = require(\"viperhtml\");\n+// Returns buffer\nmodule.exports = function(data) {\n- return (\n- \"\" +\n- viperHTML.wire()`<div>\n+ return viperHTML.wire()`<div>\nThis is a viper template, ${data.name}\n${[data.html]}\n-</div>`\n- );\n+</div>`;\n};\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Better support for buffers returned from js templates, adds data support in template classes (getters or functions) |
699 | 18.06.2018 17:35:25 | 18,000 | 706ab3106b9137fb9e0437cf5c2c8f29bd4b2bc7 | Adds some additional debug for | [
{
"change_type": "MODIFY",
"old_path": "src/Template.js",
"new_path": "src/Template.js",
"diff": "@@ -667,9 +667,10 @@ class Template {\nlet stat = await fs.stat(this.inputPath);\nlet createdDate = new Date(stat.birthtimeMs);\ndebug(\n- \"getMappedDate: using file created time for %o of %o\",\n+ \"getMappedDate: using file created time for %o of %o (from %o)\",\nthis.inputPath,\n- createdDate\n+ createdDate,\n+ stat.birthtimeMs\n);\n// CREATED\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Adds some additional debug for #127 |
699 | 18.06.2018 20:45:30 | 18,000 | 416b91a94e894c55f274022c978fbab13942aaa7 | Fixes (was not working with template/directory data files) | [
{
"change_type": "MODIFY",
"old_path": "src/Template.js",
"new_path": "src/Template.js",
"diff": "@@ -141,6 +141,7 @@ class Template {\n// TODO check for conflicts, see if file already exists?\nasync getOutputPath(data) {\nlet uri = await this.getOutputLink(data);\n+ // TODO this only works with immediate front matter and not data files\nif ((await this.getFrontMatterData())[this.config.keys.permalinkRoot]) {\nreturn normalize(uri);\n} else {\n@@ -266,20 +267,19 @@ class Template {\nasync getData(localData) {\nif (!this.dataCache) {\ndebugDev(\"%o getData()\", this.inputPath);\n- let data = {};\n+ let localData = {};\nif (this.templateData) {\n- data = await this.templateData.getLocalData(this.inputPath);\n+ localData = await this.templateData.getLocalData(this.inputPath);\n}\n- let frontMatterData = await this.getFrontMatterData();\n-\n+ Object.assign(localData, await this.getFrontMatterData());\nlet mergedLayoutData = await this.getAllLayoutFrontMatterData(\nthis,\n- frontMatterData\n+ localData\n);\n- let mergedData = Object.assign({}, data, mergedLayoutData);\n+ let mergedData = Object.assign({}, localData, mergedLayoutData);\nmergedData = await this.addPageDate(mergedData);\nmergedData = this.addPageData(mergedData);\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateTest.js",
"new_path": "test/TemplateTest.js",
"diff": "@@ -458,6 +458,21 @@ test(\"Permalink output directory from layout (fileslug)\", async t => {\n);\n});\n+test(\"Layout from template-data-file that has a permalink (fileslug) Issue #121\", async t => {\n+ let dataObj = new TemplateData(\"./test/stubs/\");\n+ let tmpl = new Template(\n+ \"./test/stubs/permalink-data-layout/test.njk\",\n+ \"./test/stubs/\",\n+ \"./dist\",\n+ dataObj\n+ );\n+\n+ let data = await tmpl.getData();\n+ let renderedTmpl = (await tmpl.getRenderedTemplates(data))[0];\n+ t.is(renderedTmpl.templateContent, \"Wrapper:Test 1:test\");\n+ t.is(await tmpl.getOutputPath(), \"./dist/test/index.html\");\n+});\n+\ntest(\"Local template data file import (without a global data json)\", async t => {\nlet dataObj = new TemplateData();\nawait dataObj.cacheData();\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/_includes/permalink-data-layout.njk",
"diff": "+---\n+permalink: \"{{ page.fileSlug }}/index.html\"\n+---\n+Wrapper:{{ layoutContent | safe }}\n\\ No newline at end of file\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/permalink-data-layout/test.json",
"diff": "+{\n+ \"layout\": \"permalink-data-layout.njk\"\n+}\n\\ No newline at end of file\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/permalink-data-layout/test.njk",
"diff": "+Test 1:{{ page.fileSlug }}\n\\ No newline at end of file\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Fixes #121 (was not working with template/directory data files) |
699 | 22.06.2018 07:23:50 | 18,000 | bd73326cf0ac0600b7b0676093c8b6b13ab8afce | Get rid of stars | [
{
"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-[](https://travis-ci.org/11ty/eleventy) [](https://github.com/11ty/eleventy/issues) [](https://github.com/11ty/eleventy/stargazers)\n+[](https://travis-ci.org/11ty/eleventy) [](https://github.com/11ty/eleventy/issues)\n## Tests\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Get rid of stars |
699 | 25.06.2018 08:08:40 | 18,000 | c472d19340900c50f5fbc649baa012b160065623 | Mustache tests for | [
{
"change_type": "MODIFY",
"old_path": "test/TemplateRenderMustacheTest.js",
"new_path": "test/TemplateRenderMustacheTest.js",
"diff": "@@ -39,3 +39,27 @@ test(\"Mustache Render: with Library Override\", async t => {\nlet fn = await tr.getCompiledTemplate(\"<p>{{name}}</p>\");\nt.is(await fn({ name: \"Zach\" }), \"<p>Zach</p>\");\n});\n+\n+test(\"Mustache Render Unescaped Output (no HTML)\", async t => {\n+ let fn = await new TemplateRender(\"mustache\").getCompiledTemplate(\n+ \"<p>{{{name}}}</p>\"\n+ );\n+ t.is(await fn({ name: \"Zach\" }), \"<p>Zach</p>\");\n+});\n+\n+test(\"Mustache Render Escaped Output\", async t => {\n+ let fn = await new TemplateRender(\"mustache\").getCompiledTemplate(\n+ \"<p>{{name}}</p>\"\n+ );\n+ t.is(\n+ await fn({ name: \"<b>Zach</b>\" }),\n+ \"<p><b>Zach</b></p>\"\n+ );\n+});\n+\n+test(\"Mustache Render Unescaped Output (HTML)\", async t => {\n+ let fn = await new TemplateRender(\"mustache\").getCompiledTemplate(\n+ \"<p>{{{name}}}</p>\"\n+ );\n+ t.is(await fn({ name: \"<b>Zach</b>\" }), \"<p><b>Zach</b></p>\");\n+});\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Mustache tests for #145 |
699 | 25.06.2018 21:36:06 | 18,000 | 90a02424b109d5c47fee49f38589d609998f1038 | Adds support for Nunjucks custom tags. Fixes
Adds support for Shortcodes (supported in Nunjucks and LiquidJS). Fixes | [
{
"change_type": "MODIFY",
"old_path": "src/Engines/Nunjucks.js",
"new_path": "src/Engines/Nunjucks.js",
"diff": "@@ -19,6 +19,7 @@ class Nunjucks extends TemplateEngine {\nthis.addFilters(this.config.nunjucksFilters);\nthis.addFilters(this.config.nunjucksAsyncFilters, true);\n+ this.addCustomTags(this.config.nunjucksTags);\nthis.setEngineLib(this.njkEnv);\n}\n@@ -28,6 +29,25 @@ class Nunjucks extends TemplateEngine {\n}\n}\n+ addCustomTags(tags) {\n+ for (let name in tags) {\n+ this.addTag(name, tags[name]);\n+ }\n+ }\n+\n+ addTag(name, tag) {\n+ let tagObj;\n+ if (typeof tag === \"function\") {\n+ tagObj = tag(NunjucksLib, this.njkEnv);\n+ } else {\n+ throw new Error(\n+ \"Nunjucks.addTag expects a callback function to be passed in: addTag(name, function(nunjucksEngine) {})\"\n+ );\n+ }\n+\n+ this.njkEnv.addExtension(name, tagObj);\n+ }\n+\nasync compile(str, inputPath) {\nlet tmpl = NunjucksLib.compile(str, this.njkEnv);\nreturn async function(data) {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/UserConfig.js",
"new_path": "src/UserConfig.js",
"diff": "@@ -2,6 +2,7 @@ const EventEmitter = require(\"events\");\nconst chalk = require(\"chalk\");\nconst semver = require(\"semver\");\nconst { DateTime } = require(\"luxon\");\n+const Liquid = require(\"liquidjs\");\nconst debug = require(\"debug\")(\"Eleventy:UserConfig\");\nconst pkg = require(\"../package.json\");\n@@ -21,6 +22,7 @@ class UserConfig {\nthis.liquidFilters = {};\nthis.nunjucksFilters = {};\nthis.nunjucksAsyncFilters = {};\n+ this.nunjucksTags = {};\nthis.handlebarsHelpers = {};\nthis.passthroughCopies = {};\nthis.pugOptions = {};\n@@ -157,6 +159,27 @@ class UserConfig {\nthis.addHandlebarsHelper(name, callback);\n}\n+ addNunjucksTag(name, tagFn) {\n+ name = this.getNamespacedName(name);\n+\n+ if (typeof tagFn !== \"function\") {\n+ throw new Error(\n+ `EleventyConfig.addNunjucksTag expects a callback function to be passed in for ${name}: addNunjucksTag(name, function(nunjucksEngine) {})`\n+ );\n+ }\n+\n+ if (this.nunjucksTags[name]) {\n+ debug(\n+ chalk.yellow(\n+ \"Warning, overwriting a Nunjucks tag with `addNunjucksTag(%o)`\"\n+ ),\n+ name\n+ );\n+ }\n+\n+ this.nunjucksTags[name] = tagFn;\n+ }\n+\naddTransform(name, callback) {\nname = this.getNamespacedName(name);\n@@ -258,6 +281,136 @@ class UserConfig {\nthis.useGitIgnore = !!enabled;\n}\n+ addShortcode(shortcodeName, shortcodeCallback) {\n+ this.addNunjucksShortcode(shortcodeName, shortcodeCallback);\n+ this.addLiquidShortcode(shortcodeName, shortcodeCallback);\n+ }\n+\n+ addNunjucksShortcode(shortcodeName, shortcodeCallback) {\n+ this.addNunjucksTag(shortcodeName, function(nunjucksEngine) {\n+ return new function() {\n+ this.tags = [shortcodeName];\n+\n+ this.parse = function(parser, nodes, lexer) {\n+ var tok = parser.nextToken();\n+\n+ var args = parser.parseSignature(null, true);\n+ parser.advanceAfterBlockEnd(tok.value);\n+\n+ return new nodes.CallExtensionAsync(this, \"run\", args);\n+ };\n+\n+ this.run = function(...args) {\n+ let callback = args.pop();\n+ let [context, ...argArray] = args;\n+\n+ let ret = new nunjucksEngine.runtime.SafeString(\n+ shortcodeCallback(...argArray)\n+ );\n+ callback(null, ret);\n+ };\n+ }();\n+ });\n+ }\n+\n+ addLiquidShortcode(shortcodeName, shortcodeCallback) {\n+ this.addLiquidTag(shortcodeName, function(liquidEngine) {\n+ return {\n+ parse: function(tagToken, remainTokens) {\n+ this.name = tagToken.name;\n+ this.args = tagToken.args;\n+ },\n+ render: function(scope, hash) {\n+ let argArray = [];\n+ if (typeof this.args === \"string\") {\n+ // TODO key=value key2=value\n+ // TODO JSON?\n+ let args = this.args.split(\" \");\n+ for (let arg of args) {\n+ argArray.push(Liquid.evalExp(arg, scope)); // or evalValue\n+ }\n+ }\n+\n+ return Promise.resolve(shortcodeCallback(...argArray));\n+ }\n+ };\n+ });\n+ }\n+\n+ addPairedShortcode(shortcodeName, shortcodeCallback) {\n+ this.addPairedNunjucksShortcode(shortcodeName, shortcodeCallback);\n+ this.addPairedLiquidShortcode(shortcodeName, shortcodeCallback);\n+ }\n+\n+ addPairedNunjucksShortcode(shortcodeName, shortcodeCallback) {\n+ this.addNunjucksTag(shortcodeName, function(nunjucksEngine, nunjucksEnv) {\n+ return new function() {\n+ this.tags = [shortcodeName];\n+\n+ this.parse = function(parser, nodes, lexer) {\n+ var tok = parser.nextToken();\n+\n+ var args = parser.parseSignature(null, true);\n+ parser.advanceAfterBlockEnd(tok.value);\n+\n+ var body = parser.parseUntilBlocks(\"end\" + shortcodeName);\n+ parser.advanceAfterBlockEnd();\n+\n+ return new nodes.CallExtensionAsync(this, \"run\", args, [body]);\n+ };\n+\n+ // run: function(context, arg1, arg2, body, callback) {\n+ this.run = function(...args) {\n+ let callback = args.pop();\n+ let body = args.pop();\n+ let [context, ...argArray] = args;\n+\n+ let ret = new nunjucksEngine.runtime.SafeString(\n+ shortcodeCallback(body(), ...argArray)\n+ );\n+ callback(null, ret);\n+ };\n+ }();\n+ });\n+ }\n+\n+ addPairedLiquidShortcode(shortcodeName, shortcodeCallback) {\n+ this.addLiquidTag(shortcodeName, function(liquidEngine) {\n+ return {\n+ parse: function(tagToken, remainTokens) {\n+ this.name = tagToken.name;\n+ this.args = tagToken.args;\n+ this.templates = [];\n+\n+ var stream = liquidEngine.parser\n+ .parseStream(remainTokens)\n+ .on(\"template\", tpl => this.templates.push(tpl))\n+ .on(\"tag:end\" + shortcodeName, token => stream.stop())\n+ .on(\"end\", x => {\n+ throw new Error(`tag ${tagToken.raw} not closed`);\n+ });\n+\n+ stream.start();\n+ },\n+ render: function(scope, hash) {\n+ let argArray = [];\n+ let args = this.args.split(\" \");\n+ for (let arg of args) {\n+ argArray.push(Liquid.evalExp(arg, scope)); // or evalValue\n+ }\n+\n+ return new Promise((resolve, reject) => {\n+ liquidEngine.renderer\n+ .renderTemplates(this.templates, scope)\n+ .then(function(html) {\n+ resolve(shortcodeCallback(html, ...argArray));\n+ });\n+ });\n+ }\n+ };\n+ });\n+ }\n+\ngetMergingConfigObject() {\nreturn {\ntemplateFormats: this.templateFormats,\n@@ -269,6 +422,7 @@ class UserConfig {\nliquidFilters: this.liquidFilters,\nnunjucksFilters: this.nunjucksFilters,\nnunjucksAsyncFilters: this.nunjucksAsyncFilters,\n+ nunjucksTags: this.nunjucksTags,\nhandlebarsHelpers: this.handlebarsHelpers,\npugOptions: this.pugOptions,\nejsOptions: this.ejsOptions,\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateConfigTest.js",
"new_path": "test/TemplateConfigTest.js",
"diff": "@@ -44,6 +44,17 @@ test(\"Add liquid tag\", t => {\nt.not(Object.keys(cfg.liquidTags).indexOf(\"myTagName\"), -1);\n});\n+test(\"Add nunjucks tag\", t => {\n+ eleventyConfig.addNunjucksTag(\"myNunjucksTag\", function() {});\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.nunjucksTags).indexOf(\"myNunjucksTag\"), -1);\n+});\n+\ntest(\"Add liquid filter\", t => {\neleventyConfig.addLiquidFilter(\"myFilterName\", function(liquidEngine) {\nreturn {};\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Adds support for Nunjucks custom tags. Fixes #151
Adds support for Shortcodes (supported in Nunjucks and LiquidJS). Fixes #13 |
699 | 26.06.2018 08:22:34 | 18,000 | f9d2ff7a9317da0320ada40390a5508a7346932e | Bunch more tests for | [
{
"change_type": "MODIFY",
"old_path": "test/TemplateRenderLiquidTest.js",
"new_path": "test/TemplateRenderLiquidTest.js",
"diff": "@@ -333,3 +333,48 @@ test(\"Liquid Render: with Library Override\", async t => {\nlet fn = await tr.getCompiledTemplate(\"<p>{{name | capitalize}}</p>\");\nt.is(await fn({ name: \"tim\" }), \"<p>Tim</p>\");\n});\n+\n+test(\"Liquid Paired Shortcode with Tag Inside\", async t => {\n+ let tr = new TemplateRender(\"liquid\", \"./test/stubs/\");\n+ tr.engine.addPairedShortcode(\"postfixWithZach\", function(content, str) {\n+ return str + content + \"Zach\";\n+ });\n+\n+ t.is(\n+ await tr.render(\n+ \"{% postfixWithZach name %}Content{% if tester %}If{% endif %}{% endpostfixWithZach %}\",\n+ { name: \"test\", tester: true }\n+ ),\n+ \"testContentIfZach\"\n+ );\n+});\n+\n+test(\"Liquid Nested Paired Shortcode\", async t => {\n+ let tr = new TemplateRender(\"liquid\", \"./test/stubs/\");\n+ tr.engine.addPairedShortcode(\"postfixWithZach\", function(content, str) {\n+ return str + content + \"Zach\";\n+ });\n+\n+ t.is(\n+ await tr.render(\n+ \"{% postfixWithZach name %}Content{% postfixWithZach name2 %}Content{% endpostfixWithZach %}{% endpostfixWithZach %}\",\n+ { name: \"test\", name2: \"test2\" }\n+ ),\n+ \"testContenttest2ContentZachZach\"\n+ );\n+});\n+\n+test(\"Liquid Shortcode Multiple Args\", async t => {\n+ let tr = new TemplateRender(\"liquid\", \"./test/stubs/\");\n+ tr.engine.addShortcode(\"postfixWithZach\", function(str, str2) {\n+ return str + str2 + \"Zach\";\n+ });\n+\n+ t.is(\n+ await tr.render(\"{% postfixWithZach name other %}\", {\n+ name: \"test\",\n+ other: \"howdy\"\n+ }),\n+ \"testhowdyZach\"\n+ );\n+});\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateRenderNunjucksTest.js",
"new_path": "test/TemplateRenderNunjucksTest.js",
"diff": "@@ -92,3 +92,78 @@ test(\"Nunjucks Paired Shortcode\", async t => {\n\"testContentZach\"\n);\n});\n+\n+test(\"Nunjucks Paired Shortcode with Tag Inside\", async t => {\n+ let tr = new TemplateRender(\"njk\", \"./test/stubs/\");\n+ tr.engine.addPairedShortcode(\"postfixWithZach\", function(content, str) {\n+ return str + content + \"Zach\";\n+ });\n+\n+ t.is(\n+ await tr.render(\n+ \"{% postfixWithZach name %}Content{% if tester %}If{% endif %}{% endpostfixWithZach %}\",\n+ { name: \"test\", tester: true }\n+ ),\n+ \"testContentIfZach\"\n+ );\n+});\n+\n+test(\"Nunjucks Nested Paired Shortcode\", async t => {\n+ let tr = new TemplateRender(\"njk\", \"./test/stubs/\");\n+ tr.engine.addPairedShortcode(\"postfixWithZach\", function(content, str) {\n+ return str + content + \"Zach\";\n+ });\n+\n+ t.is(\n+ await tr.render(\n+ \"{% postfixWithZach name %}Content{% postfixWithZach name2 %}Content{% endpostfixWithZach %}{% endpostfixWithZach %}\",\n+ { name: \"test\", name2: \"test2\" }\n+ ),\n+ \"testContenttest2ContentZachZach\"\n+ );\n+});\n+\n+test(\"Nunjucks Shortcode Multiple Args\", async t => {\n+ let tr = new TemplateRender(\"njk\", \"./test/stubs/\");\n+ tr.engine.addShortcode(\"postfixWithZach\", function(str, str2) {\n+ return str + str2 + \"Zach\";\n+ });\n+\n+ t.is(\n+ await tr.render(\"{% postfixWithZach name, other %}\", {\n+ name: \"test\",\n+ other: \"howdy\"\n+ }),\n+ \"testhowdyZach\"\n+ );\n+});\n+\n+test(\"Nunjucks Shortcode Named Args\", async t => {\n+ let tr = new TemplateRender(\"njk\", \"./test/stubs/\");\n+ tr.engine.addShortcode(\"postfixWithZach\", function(arg) {\n+ return arg.arg1 + arg.arg2 + \"Zach\";\n+ });\n+\n+ t.is(\n+ await tr.render(\"{% postfixWithZach arg1=name, arg2=other %}\", {\n+ name: \"test\",\n+ other: \"howdy\"\n+ }),\n+ \"testhowdyZach\"\n+ );\n+});\n+\n+test(\"Nunjucks Shortcode Named Args (JS notation)\", async t => {\n+ let tr = new TemplateRender(\"njk\", \"./test/stubs/\");\n+ tr.engine.addShortcode(\"postfixWithZach\", function(arg) {\n+ return arg.arg1 + arg.arg2 + \"Zach\";\n+ });\n+\n+ t.is(\n+ await tr.render(\"{% postfixWithZach { arg1: name, arg2: other } %}\", {\n+ name: \"test\",\n+ other: \"howdy\"\n+ }),\n+ \"testhowdyZach\"\n+ );\n+});\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Bunch more tests for #13 |
699 | 27.06.2018 07:36:35 | 18,000 | 5c1e4fded4f9fb9f4dd3d532c2605ed92226dee1 | Filter stuff should be close together | [
{
"change_type": "MODIFY",
"old_path": "src/Engines/Liquid.js",
"new_path": "src/Engines/Liquid.js",
"diff": "@@ -59,6 +59,10 @@ class Liquid extends TemplateEngine {\n}\n}\n+ addFilter(name, filter) {\n+ this.liquidLib.registerFilter(name, filter);\n+ }\n+\naddTag(name, tagFn) {\nlet tagObj;\nif (typeof tagFn === \"function\") {\n@@ -144,10 +148,6 @@ class Liquid extends TemplateEngine {\n});\n}\n- addFilter(name, filter) {\n- this.liquidLib.registerFilter(name, filter);\n- }\n-\nasync compile(str, inputPath) {\nlet engine = this.liquidLib;\nlet tmpl = await engine.parse(str);\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Filter stuff should be close together |
699 | 03.07.2018 08:53:53 | 18,000 | ec9539103eae31319f8401d16441cdf7b98028ad | A few more nunjucks tests | [
{
"change_type": "MODIFY",
"old_path": "test/TemplateRenderEJSTest.js",
"new_path": "test/TemplateRenderEJSTest.js",
"diff": "import test from \"ava\";\nimport TemplateRender from \"../src/TemplateRender\";\n-import path from \"path\";\n// EJS\ntest(\"EJS\", t => {\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateRenderHTMLTest.js",
"new_path": "test/TemplateRenderHTMLTest.js",
"diff": "import test from \"ava\";\nimport TemplateRender from \"../src/TemplateRender\";\n-import path from \"path\";\n// HTML\ntest(\"HTML\", t => {\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateRenderHandlebarsTest.js",
"new_path": "test/TemplateRenderHandlebarsTest.js",
"diff": "import test from \"ava\";\nimport TemplateRender from \"../src/TemplateRender\";\n-import path from \"path\";\n// Handlebars\ntest(\"Handlebars\", t => {\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateRenderJSTLTest.js",
"new_path": "test/TemplateRenderJSTLTest.js",
"diff": "import test from \"ava\";\nimport TemplateRender from \"../src/TemplateRender\";\n-import path from \"path\";\n// ES6\ntest(\"ES6 Template Literal\", t => {\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateRenderMustacheTest.js",
"new_path": "test/TemplateRenderMustacheTest.js",
"diff": "import test from \"ava\";\nimport TemplateRender from \"../src/TemplateRender\";\n-import path from \"path\";\n// Mustache\ntest(\"Mustache\", async t => {\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateRenderNunjucksTest.js",
"new_path": "test/TemplateRenderNunjucksTest.js",
"diff": "@@ -34,6 +34,20 @@ test(\"Nunjucks Render Include Subfolder\", async t => {\nt.is(await fn(), \"<p>This is an include.</p>\");\n});\n+test(\"Nunjucks Render Include Double Quotes\", async t => {\n+ let fn = await new TemplateRender(\"njk\", \"test/stubs\").getCompiledTemplate(\n+ `<p>{% include \"included.njk\" %}</p>`\n+ );\n+ t.is(await fn(), \"<p>This is an include.</p>\");\n+});\n+\n+test(\"Nunjucks Render Include Subfolder Double Quotes\", async t => {\n+ let fn = await new TemplateRender(\"njk\", \"test/stubs\").getCompiledTemplate(\n+ `<p>{% include \"subfolder/included.html\" %}</p>`\n+ );\n+ t.is(await fn(), \"<p>This is an include.</p>\");\n+});\n+\ntest(\"Nunjucks Render Imports\", async t => {\nlet fn = await new TemplateRender(\"njk\", \"test/stubs\").getCompiledTemplate(\n\"{% import 'imports.njk' as forms %}<div>{{ forms.label('Name') }}</div>\"\n@@ -153,6 +167,21 @@ test(\"Nunjucks Shortcode Named Args\", async t => {\n);\n});\n+test(\"Nunjucks Shortcode Named Args (Reverse Order)\", async t => {\n+ let tr = new TemplateRender(\"njk\", \"./test/stubs/\");\n+ tr.engine.addShortcode(\"postfixWithZach\", function(arg) {\n+ return arg.arg1 + arg.arg2 + \"Zach\";\n+ });\n+\n+ t.is(\n+ await tr.render(\"{% postfixWithZach arg2=other, arg1=name %}\", {\n+ name: \"test\",\n+ other: \"howdy\"\n+ }),\n+ \"testhowdyZach\"\n+ );\n+});\n+\ntest(\"Nunjucks Shortcode Named Args (JS notation)\", async t => {\nlet tr = new TemplateRender(\"njk\", \"./test/stubs/\");\ntr.engine.addShortcode(\"postfixWithZach\", function(arg) {\n"
}
] | JavaScript | MIT License | 11ty/eleventy | A few more nunjucks tests |
699 | 03.07.2018 16:40:20 | 18,000 | 6f3c510604cac0b4f81361a49ada69fd3d8305b7 | Tests for integration points with the syntax highlighter plugin | [
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"lint-staged\": \"^7.2.0\",\n\"markdown-it-emoji\": \"^1.4.0\",\n\"nyc\": \"^12.0.2\",\n- \"prettier\": \"1.13.5\"\n+ \"prettier\": \"1.13.5\",\n+ \"@11ty/eleventy-plugin-syntaxhighlight\": \"^1.0.5\"\n},\n\"dependencies\": {\n\"browser-sync\": \"^2.24.4\",\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Tests for integration points with the syntax highlighter plugin |
699 | 03.07.2018 17:13:43 | 18,000 | f2d7ed9f94d554778ad46cff0664553b12e426e3 | Adds test for Mustache partials too | [
{
"change_type": "MODIFY",
"old_path": "test/TemplateRenderMustacheTest.js",
"new_path": "test/TemplateRenderMustacheTest.js",
"diff": "@@ -29,6 +29,14 @@ test(\"Mustache Render Partial\", async t => {\nt.is(await fn({ name: \"Zach\" }), \"<p>This is a Zach.</p>\");\n});\n+test(\"Mustache Render Partial (Subdirectory)\", async t => {\n+ let fn = await new TemplateRender(\n+ \"mustache\",\n+ \"./test/stubs/\"\n+ ).getCompiledTemplate(\"<p>{{> subfolder/included}}</p>\");\n+ t.is(await fn({ name: \"Zach\" }), \"<p>This is an include.</p>\");\n+});\n+\ntest(\"Mustache Render: with Library Override\", async t => {\nlet tr = new TemplateRender(\"mustache\");\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/_includes/subfolder/included.mustache",
"diff": "+This is an include.\n\\ No newline at end of file\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Adds test for Mustache partials too #146 |
699 | 03.07.2018 22:35:41 | 18,000 | b89e35359f3c5687c781a2ce0ce49342d36c9b78 | Adds handlebars shortcodes and paired shortcodes. | [
{
"change_type": "MODIFY",
"old_path": "src/Engines/Handlebars.js",
"new_path": "src/Engines/Handlebars.js",
"diff": "@@ -20,11 +20,38 @@ class Handlebars extends TemplateEngine {\n}\nthis.addHelpers(this.config.handlebarsHelpers);\n+ this.addShortcodes(this.config.handlebarsShortcodes);\n+ this.addPairedShortcodes(this.config.handlebarsPairedShortcodes);\n+ }\n+\n+ addHelper(name, callback) {\n+ this.handlebarsLib.registerHelper(name, callback);\n}\naddHelpers(helpers) {\nfor (let name in helpers) {\n- this.handlebarsLib.registerHelper(name, helpers[name]);\n+ this.addHelper(name, helpers[name]);\n+ }\n+ }\n+\n+ addShortcodes(shortcodes) {\n+ for (let name in shortcodes) {\n+ this.addHelper(name, shortcodes[name]);\n+ }\n+ }\n+\n+ addPairedShortcodes(shortcodes) {\n+ for (let name in shortcodes) {\n+ let callback = shortcodes[name];\n+ this.addHelper(name, function(...args) {\n+ let options = args[args.length - 1];\n+ let content = \"\";\n+ if (options && options.fn) {\n+ content = options.fn(this);\n+ }\n+\n+ return callback.apply(this, [content, ...args]);\n+ });\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/UserConfig.js",
"new_path": "src/UserConfig.js",
"diff": "@@ -27,6 +27,8 @@ class UserConfig {\nthis.nunjucksShortcodes = {};\nthis.nunjucksPairedShortcodes = {};\nthis.handlebarsHelpers = {};\n+ this.handlebarsShortcodes = {};\n+ this.handlebarsPairedShortcodes = {};\nthis.passthroughCopies = {};\nthis.pugOptions = {};\nthis.ejsOptions = {};\n@@ -287,6 +289,7 @@ class UserConfig {\naddShortcode(name, callback) {\nthis.addNunjucksShortcode(name, callback);\nthis.addLiquidShortcode(name, callback);\n+ this.addHandlebarsShortcode(name, callback);\n}\naddNunjucksShortcode(name, callback) {\n@@ -297,9 +300,14 @@ class UserConfig {\nthis.liquidShortcodes[name] = callback;\n}\n+ addHandlebarsShortcode(name, callback) {\n+ this.handlebarsShortcodes[name] = callback;\n+ }\n+\naddPairedShortcode(name, callback) {\nthis.addPairedNunjucksShortcode(name, callback);\nthis.addPairedLiquidShortcode(name, callback);\n+ this.addPairedHandlebarsShortcode(name, callback);\n}\naddPairedNunjucksShortcode(name, callback) {\n@@ -310,6 +318,10 @@ class UserConfig {\nthis.liquidPairedShortcodes[name] = callback;\n}\n+ addPairedHandlebarsShortcode(name, callback) {\n+ this.handlebarsPairedShortcodes[name] = callback;\n+ }\n+\ngetMergingConfigObject() {\nreturn {\ntemplateFormats: this.templateFormats,\n@@ -327,6 +339,8 @@ class UserConfig {\nnunjucksShortcodes: this.nunjucksShortcodes,\nnunjucksPairedShortcodes: this.nunjucksPairedShortcodes,\nhandlebarsHelpers: this.handlebarsHelpers,\n+ handlebarsShortcodes: this.handlebarsShortcodes,\n+ handlebarsPairedShortcodes: this.handlebarsPairedShortcodes,\npugOptions: this.pugOptions,\nejsOptions: this.ejsOptions,\nmarkdownHighlighter: this.markdownHighlighter,\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateRenderHandlebarsTest.js",
"new_path": "test/TemplateRenderHandlebarsTest.js",
"diff": "@@ -64,3 +64,59 @@ test(\"Handlebars Render: with Library Override\", async t => {\nlet fn = await tr.getCompiledTemplate(\"<p>{{name}}</p>\");\nt.is(await fn({ name: \"Zach\" }), \"<p>Zach</p>\");\n});\n+\n+test(\"Handlebars Render Helper\", async t => {\n+ let tr = new TemplateRender(\"hbs\");\n+ tr.engine.addHelpers({\n+ helpername: function() {\n+ return \"Zach\";\n+ }\n+ });\n+\n+ let fn = await tr.getCompiledTemplate(\n+ \"<p>This is a {{helpername}} {{name}}.</p>\"\n+ );\n+ t.is(await fn({ name: \"Zach\" }), \"<p>This is a Zach Zach.</p>\");\n+});\n+\n+test(\"Handlebars Render Helper\", async t => {\n+ let tr = new TemplateRender(\"hbs\");\n+ tr.engine.addHelpers({\n+ helpername2: function(name) {\n+ return \"Zach\";\n+ }\n+ });\n+\n+ let fn = await tr.getCompiledTemplate(\n+ \"<p>This is a {{helpername2 name}}.</p>\"\n+ );\n+ t.is(await fn({ name: \"Zach\" }), \"<p>This is a Zach.</p>\");\n+});\n+\n+test(\"Handlebars Render Shortcode\", async t => {\n+ let tr = new TemplateRender(\"hbs\");\n+ tr.engine.addShortcodes({\n+ shortcodename: function(name) {\n+ return name.toUpperCase();\n+ }\n+ });\n+\n+ let fn = await tr.getCompiledTemplate(\n+ \"<p>This is a {{shortcodename name}}.</p>\"\n+ );\n+ t.is(await fn({ name: \"Howdy\" }), \"<p>This is a HOWDY.</p>\");\n+});\n+\n+test(\"Handlebars Render Paired Shortcode\", async t => {\n+ let tr = new TemplateRender(\"hbs\");\n+ tr.engine.addPairedShortcodes({\n+ shortcodename: function(content, name, options) {\n+ return (content + name).toUpperCase();\n+ }\n+ });\n+\n+ let fn = await tr.getCompiledTemplate(\n+ \"<p>This is a {{#shortcodename name}}Testing{{/shortcodename}}.</p>\"\n+ );\n+ t.is(await fn({ name: \"Howdy\" }), \"<p>This is a TESTINGHOWDY.</p>\");\n+});\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Adds handlebars shortcodes and paired shortcodes. #157. |
699 | 05.07.2018 07:51:08 | 18,000 | c29f7232e993758076db176dcab49ece4cccf82e | Add a few warnings for config overwrites | [
{
"change_type": "MODIFY",
"old_path": "src/Engines/Handlebars.js",
"new_path": "src/Engines/Handlebars.js",
"diff": "@@ -19,6 +19,7 @@ class Handlebars extends TemplateEngine {\nthis.handlebarsLib.registerPartial(name, partials[name]);\n}\n+ // TODO these all go to the same place (addHelper), add warnings for overwrites\nthis.addHelpers(this.config.handlebarsHelpers);\nthis.addShortcodes(this.config.handlebarsShortcodes);\nthis.addPairedShortcodes(this.config.handlebarsPairedShortcodes);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Engines/Liquid.js",
"new_path": "src/Engines/Liquid.js",
"diff": "@@ -23,6 +23,8 @@ class Liquid extends TemplateEngine {\nthis.setEngineLib(this.liquidLib);\nthis.addFilters(this.config.liquidFilters);\n+\n+ // TODO these all go to the same place (addTag), add warnings for overwrites\nthis.addCustomTags(this.config.liquidTags);\nthis.addAllShortcodes(this.config.liquidShortcodes);\nthis.addAllPairedShortcodes(this.config.liquidPairedShortcodes);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Engines/Nunjucks.js",
"new_path": "src/Engines/Nunjucks.js",
"diff": "@@ -20,6 +20,8 @@ class Nunjucks extends TemplateEngine {\nthis.addFilters(this.config.nunjucksFilters);\nthis.addFilters(this.config.nunjucksAsyncFilters, true);\n+\n+ // TODO these all go to the same place (addTag), add warnings for overwrites\nthis.addCustomTags(this.config.nunjucksTags);\nthis.addAllShortcodes(this.config.nunjucksShortcodes);\nthis.addAllPairedShortcodes(this.config.nunjucksPairedShortcodes);\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Add a few warnings for config overwrites |
699 | 05.07.2018 08:06:21 | 18,000 | 7c5001152f70bac590316c49b79a01a7c859f4b0 | Colliding shortcode names. | [
{
"change_type": "MODIFY",
"old_path": "test/TemplateRenderHandlebarsTest.js",
"new_path": "test/TemplateRenderHandlebarsTest.js",
"diff": "@@ -107,16 +107,33 @@ test(\"Handlebars Render Shortcode\", async t => {\nt.is(await fn({ name: \"Howdy\" }), \"<p>This is a HOWDY.</p>\");\n});\n+test(\"Handlebars Render Shortcode (Multiple args)\", async t => {\n+ let tr = new TemplateRender(\"hbs\");\n+ tr.engine.addShortcodes({\n+ shortcodename2: function(name, name2) {\n+ return name.toUpperCase() + name2.toUpperCase();\n+ }\n+ });\n+\n+ let fn = await tr.getCompiledTemplate(\n+ \"<p>This is a {{shortcodename2 name name2}}.</p>\"\n+ );\n+ t.is(\n+ await fn({ name: \"Howdy\", name2: \"Zach\" }),\n+ \"<p>This is a HOWDYZACH.</p>\"\n+ );\n+});\n+\ntest(\"Handlebars Render Paired Shortcode\", async t => {\nlet tr = new TemplateRender(\"hbs\");\ntr.engine.addPairedShortcodes({\n- shortcodename: function(content, name, options) {\n+ shortcodename3: function(content, name, options) {\nreturn (content + name).toUpperCase();\n}\n});\nlet fn = await tr.getCompiledTemplate(\n- \"<p>This is a {{#shortcodename name}}Testing{{/shortcodename}}.</p>\"\n+ \"<p>This is a {{#shortcodename3 name}}Testing{{/shortcodename3}}.</p>\"\n);\nt.is(await fn({ name: \"Howdy\" }), \"<p>This is a TESTINGHOWDY.</p>\");\n});\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Colliding shortcode names. |
699 | 05.07.2018 08:08:40 | 18,000 | 92b5adf746c75393d30448485d7c6da8903cb374 | Whitespace in shortcode syntax | [
{
"change_type": "MODIFY",
"old_path": "test/TemplateRenderHandlebarsTest.js",
"new_path": "test/TemplateRenderHandlebarsTest.js",
"diff": "@@ -137,3 +137,17 @@ test(\"Handlebars Render Paired Shortcode\", async t => {\n);\nt.is(await fn({ name: \"Howdy\" }), \"<p>This is a TESTINGHOWDY.</p>\");\n});\n+\n+test(\"Handlebars Render Paired Shortcode\", async t => {\n+ let tr = new TemplateRender(\"hbs\");\n+ tr.engine.addPairedShortcodes({\n+ shortcodename4: function(content, name, options) {\n+ return (content + name).toUpperCase();\n+ }\n+ });\n+\n+ let fn = await tr.getCompiledTemplate(\n+ \"<p>This is a {{# shortcodename4 name }}Testing{{/ shortcodename4 }}.</p>\"\n+ );\n+ t.is(await fn({ name: \"Howdy\" }), \"<p>This is a TESTINGHOWDY.</p>\");\n+});\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Whitespace in shortcode syntax |
699 | 05.07.2018 08:13:46 | 18,000 | 2567db384c022699dc49ea613f2bef7196dedb2b | Handlebars nesting test. | [
{
"change_type": "MODIFY",
"old_path": "test/TemplateRenderHandlebarsTest.js",
"new_path": "test/TemplateRenderHandlebarsTest.js",
"diff": "@@ -138,7 +138,7 @@ test(\"Handlebars Render Paired Shortcode\", async t => {\nt.is(await fn({ name: \"Howdy\" }), \"<p>This is a TESTINGHOWDY.</p>\");\n});\n-test(\"Handlebars Render Paired Shortcode\", async t => {\n+test(\"Handlebars Render Paired Shortcode (Spaces)\", async t => {\nlet tr = new TemplateRender(\"hbs\");\ntr.engine.addPairedShortcodes({\nshortcodename4: function(content, name, options) {\n@@ -151,3 +151,26 @@ test(\"Handlebars Render Paired Shortcode\", async t => {\n);\nt.is(await fn({ name: \"Howdy\" }), \"<p>This is a TESTINGHOWDY.</p>\");\n});\n+\n+test(\"Handlebars Render Paired Shortcode with a Nested Single Shortcode\", async t => {\n+ let tr = new TemplateRender(\"hbs\");\n+ tr.engine.addShortcodes({\n+ shortcodechild: function(txt, options) {\n+ return txt;\n+ }\n+ });\n+\n+ tr.engine.addPairedShortcodes({\n+ shortcodeparent: function(content, name, name2, options) {\n+ return (content + name + name2).toUpperCase();\n+ }\n+ });\n+\n+ let fn = await tr.getCompiledTemplate(\n+ \"<p>This is a {{# shortcodeparent name name2 }}{{shortcodechild 'CHILD CONTENT'}}{{/ shortcodeparent }}.</p>\"\n+ );\n+ t.is(\n+ await fn({ name: \"Howdy\", name2: \"Zach\" }),\n+ \"<p>This is a CHILD CONTENTHOWDYZACH.</p>\"\n+ );\n+});\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Handlebars nesting test. |
699 | 11.07.2018 08:38:44 | 18,000 | a1424a1e88b84c5c371c4f0529e7da3479aff00f | Fixes and adds a bunch more tests. | [
{
"change_type": "MODIFY",
"old_path": "src/Plugins/Pagination.js",
"new_path": "src/Plugins/Pagination.js",
"diff": "@@ -22,7 +22,6 @@ Pagination.prototype.hasPagination = function() {\nPagination.prototype.setData = function(data) {\nthis.data = data || {};\n- this.size = 1;\nthis.target = [];\nif (!this.hasPagination()) {\n@@ -31,7 +30,7 @@ Pagination.prototype.setData = function(data) {\nif (!data.pagination) {\nthrow new Error(\n- \"Misconfigured pagination data in template front matter (did you use tabs and not spaces?).\"\n+ \"Misconfigured pagination data in template front matter (YAML front matter precaution: did you use tabs and not spaces for indentation?).\"\n);\n} else if (!(\"size\" in data.pagination)) {\nthrow new Error(\"Missing pagination size in front matter data.\");\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateMap.js",
"new_path": "src/TemplateMap.js",
"diff": "@@ -34,7 +34,7 @@ class TemplateMap {\nthis.taggedCollectionsData = await this.getTaggedCollectionsData();\nObject.assign(this.collectionsData, this.taggedCollectionsData);\n- await this.populateUrlDataInMap();\n+ await this.populateUrlDataInMap(true);\nawait this.populateCollectionsWithOutputPaths(this.collectionsData);\nthis.userConfigCollectionsData = await this.getUserConfigCollectionsData();\n@@ -43,7 +43,7 @@ class TemplateMap {\nawait this.populateUrlDataInMap();\nawait this.populateCollectionsWithOutputPaths(this.collectionsData);\n- await this.populateContentDataInMap(this.collectionsData);\n+ await this.populateContentDataInMap();\nthis.populateCollectionsWithContent();\nthis.cached = true;\n}\n@@ -76,11 +76,14 @@ class TemplateMap {\n}\n}\n- async populateUrlDataInMap() {\n+ async populateUrlDataInMap(skipPagination) {\nfor (let map of this.map) {\nif (map._initialPage) {\ncontinue;\n}\n+ if (skipPagination && \"pagination\" in map.data) {\n+ continue;\n+ }\nlet pages = await map.template.getTemplates(map.data);\nif (pages.length) {\n@@ -94,7 +97,7 @@ class TemplateMap {\n}\n}\n- async populateContentDataInMap(collectionsData) {\n+ async populateContentDataInMap() {\nfor (let map of this.map) {\nif (map._initialPage) {\nObject.assign(\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateMapTest.js",
"new_path": "test/TemplateMapTest.js",
"diff": "@@ -353,3 +353,124 @@ test(\"Url should be available in user config collections API calls (test in call\nawait tm.add(tmpl2);\nawait tm.cache();\n});\n+\n+test(\"Should be able to paginate a tag generated collection\", async t => {\n+ let tm = new TemplateMap();\n+ await tm.add(tmpl1);\n+ await tm.add(tmpl2);\n+\n+ let pagedTmpl = new Template(\n+ \"./test/stubs/templateMapCollection/paged-tag.md\",\n+ \"./test/stubs/\",\n+ \"./test/stubs/_site\"\n+ );\n+ await tm.add(pagedTmpl);\n+\n+ let collections = await tm.getCollectionsData();\n+ t.truthy(collections.dog);\n+ t.truthy(collections.dog.length);\n+});\n+\n+test(\"Should be able to paginate a user config collection\", async t => {\n+ let tm = new TemplateMap();\n+ await tm.add(tmpl1);\n+ await tm.add(tmpl2);\n+\n+ let pagedTmpl = new Template(\n+ \"./test/stubs/templateMapCollection/paged-cfg.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.truthy(collections.userCollection);\n+ t.truthy(collections.userCollection.length);\n+});\n+\n+test(\"Should be able to paginate a user config collection (uses rendered permalink)\", async t => {\n+ let tm = new TemplateMap();\n+ await tm.add(tmpl1);\n+ await tm.add(tmpl2);\n+\n+ let pagedTmpl = new Template(\n+ \"./test/stubs/templateMapCollection/paged-cfg-permalink.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+ t.is(all[0].url, \"/templateMapCollection/test1/\");\n+ t.is(\n+ all[0].outputPath,\n+ \"./test/stubs/_site/templateMapCollection/test1/index.html\"\n+ );\n+ return all;\n+ }\n+ });\n+\n+ let collections = await tm.getCollectionsData();\n+ t.truthy(collections.userCollection);\n+ t.truthy(collections.userCollection.length);\n+ t.is(collections.all[2].url, \"/test-title/hello/\");\n+});\n+\n+test(\"Should be able to paginate a user config collection (paged template is also tagged)\", async t => {\n+ let tm = new TemplateMap();\n+ await tm.add(tmpl1);\n+ await tm.add(tmpl2);\n+\n+ let pagedTmpl = new Template(\n+ \"./test/stubs/templateMapCollection/paged-cfg-tagged.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.truthy(collections.haha);\n+ t.truthy(collections.haha.length);\n+ t.is(collections.haha[0].url, \"/templateMapCollection/paged-cfg-tagged/\");\n+});\n+\n+test(\"Should be able to paginate a user config collection (paged template is also tagged, uses custom rendered permalink)\", async t => {\n+ let tm = new TemplateMap();\n+ await tm.add(tmpl1);\n+ await tm.add(tmpl2);\n+\n+ let pagedTmpl = new Template(\n+ \"./test/stubs/templateMapCollection/paged-cfg-tagged-permalink.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.truthy(collections.haha);\n+ t.truthy(collections.haha.length);\n+ t.is(collections.haha[0].url, \"/test-title/goodbye/\");\n+});\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/templateMapCollection/paged-cfg-permalink.md",
"diff": "+---\n+title: Paged Test\n+pagination:\n+ data: collections.userCollection\n+ size: 1\n+ alias: item\n+permalink: /{{ item.data.title | slug}}/hello/\n+---\n+\n+# {{ title }}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/templateMapCollection/paged-cfg-tagged-permalink.md",
"diff": "+---\n+title: Paged Test\n+tags:\n+ - haha\n+pagination:\n+ data: collections.userCollection\n+ size: 1\n+ alias: item\n+permalink: /{{ item.data.title | slug}}/goodbye/\n+---\n+\n+# {{ title }}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/templateMapCollection/paged-cfg-tagged.md",
"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"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/templateMapCollection/paged-cfg.md",
"diff": "+---\n+title: Paged Test\n+pagination:\n+ data: collections.userCollection\n+ size: 1\n+---\n+\n+# {{ title }}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/templateMapCollection/paged-tag.md",
"diff": "+---\n+title: Paged Test\n+pagination:\n+ data: collections.dog\n+ size: 1\n+---\n+\n+# {{ title }}\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Fixes #171 and adds a bunch more tests. |
699 | 11.07.2018 08:53:01 | 18,000 | 10e3fef5afb2032a4b13015ad453de06b3d4131e | Ordering of collections not guaranteed in this test. | [
{
"change_type": "MODIFY",
"old_path": "test/TemplateMapTest.js",
"new_path": "test/TemplateMapTest.js",
"diff": "@@ -422,7 +422,12 @@ test(\"Should be able to paginate a user config collection (uses rendered permali\nlet collections = await tm.getCollectionsData();\nt.truthy(collections.userCollection);\nt.truthy(collections.userCollection.length);\n- t.is(collections.all[2].url, \"/test-title/hello/\");\n+\n+ let urls = [];\n+ for (let item of collections.all) {\n+ urls.push(item.url);\n+ }\n+ t.is(urls.indexOf(\"/test-title/hello/\") > -1, true);\n});\ntest(\"Should be able to paginate a user config collection (paged template is also tagged)\", async t => {\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Ordering of collections not guaranteed in this test. |
699 | 12.07.2018 08:39:29 | 18,000 | 22981c7186b3b9a0f2ef0a496153bbc02cfb0c0c | Adds prettier 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-[](https://travis-ci.org/11ty/eleventy) [](https://github.com/11ty/eleventy/issues)\n+[](https://travis-ci.org/11ty/eleventy) [](https://github.com/11ty/eleventy/issues) [](https://github.com/prettier/prettier)\n## Tests\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Adds prettier badge |
699 | 23.07.2018 22:42:54 | 18,000 | e4435f6ca1010eeae45d6ea9f3e23a48e5b6a33c | Remove template collection cache. We want to create new arrays here but not new templates. | [
{
"change_type": "MODIFY",
"old_path": "src/TemplateCollection.js",
"new_path": "src/TemplateCollection.js",
"diff": "@@ -14,19 +14,15 @@ class TemplateCollection extends Sortable {\n}\ngetAll() {\n- return this.items;\n+ return this.items.filter(() => true);\n}\ngetAllSorted() {\n- return this._cache(\"allSorted\", function() {\nreturn this.sort(Sortable.sortFunctionDateInputPath);\n- });\n}\ngetSortedByDate() {\n- return this._cache(\"sortedByDate\", function() {\nreturn this.sort(Sortable.sortFunctionDate);\n- });\n}\ngetGlobs(globs) {\n@@ -42,7 +38,6 @@ class TemplateCollection extends Sortable {\ngetFilteredByGlob(globs) {\nglobs = this.getGlobs(globs);\n- return this._cache(\"getFilteredByGlob:\" + globs.join(\",\"), function() {\nreturn this.getAllSorted().filter(item => {\nif (multimatch([item.inputPath], globs).length) {\nreturn true;\n@@ -50,7 +45,6 @@ class TemplateCollection extends Sortable {\nreturn false;\n});\n- });\n}\ngetFilteredByTag(tagName) {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Util/Sortable.js",
"new_path": "src/Util/Sortable.js",
"diff": "@@ -6,8 +6,6 @@ class Sortable {\nthis.sortNumeric = false;\nthis.items = [];\n- this.cache = {};\n-\nthis.sortFunctionStringMap = {\n\"A-Z\": \"Ascending\",\n\"Z-A\": \"Descending\",\n@@ -22,11 +20,6 @@ class Sortable {\nadd(item) {\nthis.items.push(item);\n-\n- // reset the caches!\n- for (let key in this.cache) {\n- this.cache[key] = false;\n- }\n}\nsort(sortFunction) {\n@@ -40,31 +33,15 @@ class Sortable {\nsortFunction = Sortable[\"sortFunction\" + capitalize(sortFunction)];\n}\n- return this._cache(sortFunction.toString(), function() {\n- return this.items.sort(sortFunction);\n- });\n- }\n-\n- _cache(key, callback) {\n- if (this.cache[key]) {\n- return this.cache[key];\n- }\n-\n- this.cache[key] = callback.call(this);\n-\n- return this.cache[key];\n+ return this.items.filter(() => true).sort(sortFunction);\n}\nsortAscending() {\n- return this._cache(\"ASC\", function() {\nreturn this.sort(this.getSortFunctionAscending);\n- });\n}\nsortDescending() {\n- return this._cache(\"DESC\", function() {\nreturn this.sort(this.getSortFunctionDescending);\n- });\n}\nisSortAscending() {\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Remove template collection cache. We want to create new arrays here but not new templates. |
699 | 23.07.2018 22:49:18 | 18,000 | 33df840a522eb9be9b055cd00bbc96fd2a93b098 | Rudimentary tests for | [
{
"change_type": "MODIFY",
"old_path": "test/TemplateRenderLiquidTest.js",
"new_path": "test/TemplateRenderLiquidTest.js",
"diff": "@@ -145,6 +145,18 @@ test(\"Liquid Shortcode\", async t => {\n);\n});\n+test(\"Liquid Shortcode Safe Output\", async t => {\n+ let tr = new TemplateRender(\"liquid\", \"./test/stubs/\");\n+ tr.engine.addShortcode(\"postfixWithZach\", function(str) {\n+ return `<span>${str}</span>`;\n+ });\n+\n+ t.is(\n+ await tr.render(\"{% postfixWithZach name %}\", { name: \"test\" }),\n+ \"<span>test</span>\"\n+ );\n+});\n+\ntest(\"Liquid Paired Shortcode\", async t => {\nlet tr = new TemplateRender(\"liquid\", \"./test/stubs/\");\ntr.engine.addPairedShortcode(\"postfixWithZach\", function(content, str) {\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateRenderNunjucksTest.js",
"new_path": "test/TemplateRenderNunjucksTest.js",
"diff": "@@ -92,6 +92,18 @@ test(\"Nunjucks Shortcode\", async t => {\n);\n});\n+test(\"Nunjucks Shortcode Safe Output\", async t => {\n+ let tr = new TemplateRender(\"njk\", \"./test/stubs/\");\n+ tr.engine.addShortcode(\"postfixWithZach\", function(str) {\n+ return `<span>${str}</span>`;\n+ });\n+\n+ t.is(\n+ await tr.render(\"{% postfixWithZach name %}\", { name: \"test\" }),\n+ \"<span>test</span>\"\n+ );\n+});\n+\ntest(\"Nunjucks Paired Shortcode\", async t => {\nlet tr = new TemplateRender(\"njk\", \"./test/stubs/\");\ntr.engine.addPairedShortcode(\"postfixWithZach\", function(content, str) {\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Rudimentary tests for #180 |
699 | 24.07.2018 08:59:46 | 18,000 | 480582627abd822717fbdbf1c98e28d6f16a00f9 | Test for for the 0.5.1 release. | [
{
"change_type": "MODIFY",
"old_path": "test/TemplateWriterTest.js",
"new_path": "test/TemplateWriterTest.js",
"diff": "import test from \"ava\";\n+import fs from \"fs-extra\";\nimport fastglob from \"fast-glob\";\nimport parsePath from \"parse-filepath\";\nimport TemplateWriter from \"../src/TemplateWriter\";\n@@ -515,3 +516,28 @@ test(\"Glob Watcher Files with Config Passthroughs\", async t => {\n\"./test/stubs/img/**\"\n]);\n});\n+\n+test(\"Pagination and TemplateContent\", async t => {\n+ let tw = new TemplateWriter(\n+ \"./test/stubs/pagination-templatecontent\",\n+ \"./test/stubs/pagination-templatecontent/_site\",\n+ [\"njk\", \"md\"]\n+ );\n+\n+ tw.setVerboseOutput(false);\n+ await tw.write();\n+\n+ let content = fs.readFileSync(\n+ \"./test/stubs/pagination-templatecontent/_site/index.html\",\n+ \"utf-8\"\n+ );\n+ t.is(\n+ content.trim(),\n+ `<h1>Post 1</h1>\n+<h1>Post 2</h1>`\n+ );\n+\n+ fs.unlink(\"./test/stubs/pagination-templatecontent/_site/index.html\");\n+ fs.unlink(\"./test/stubs/pagination-templatecontent/_site/post-1/index.html\");\n+ fs.unlink(\"./test/stubs/pagination-templatecontent/_site/post-2/index.html\");\n+});\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/pagination-templatecontent/index.njk",
"diff": "+---\n+pagination:\n+ data: collections.post\n+ size: 5\n+ alias: posts\n+---\n+{%- for post in posts -%}\n+{{ post.templateContent | safe }}\n+{%- endfor -%}\n\\ No newline at end of file\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/pagination-templatecontent/post-1.md",
"diff": "+---\n+tags:\n+ - post\n+---\n+\n+# Post 1\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/pagination-templatecontent/post-2.md",
"diff": "+---\n+tags:\n+ - post\n+---\n+\n+# Post 2\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Test for #179 for the 0.5.1 release. |
699 | 03.08.2018 22:23:43 | 18,000 | 34276f57d69bf121a32aab21bbaeff273adc69de | passthroughall option to copy everything in the input directory (template or not). Will only process templates though. Requested by | [
{
"change_type": "MODIFY",
"old_path": "cmd.js",
"new_path": "cmd.js",
"diff": "@@ -25,6 +25,7 @@ EleventyNodeVersionCheck().then(\nelev.setConfigPath(argv.config);\nelev.setPathPrefix(argv.pathprefix);\nelev.setDryRun(argv.dryrun);\n+ elev.setPassthroughAll(argv.passthroughall);\nelev.setFormats(argv.formats);\nlet isVerbose = process.env.DEBUG ? false : !argv.quiet;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Eleventy.js",
"new_path": "src/Eleventy.js",
"diff": "@@ -55,6 +55,10 @@ Eleventy.prototype.setDryRun = function(isDryRun) {\nthis.isDryRun = !!isDryRun;\n};\n+Eleventy.prototype.setPassthroughAll = function(isPassthroughAll) {\n+ this.isPassthroughAll = !!isPassthroughAll;\n+};\n+\nEleventy.prototype.setPathPrefix = function(pathPrefix) {\nif (pathPrefix || pathPrefix === \"\") {\nconfig.setPathPrefix(pathPrefix);\n@@ -137,7 +141,8 @@ Eleventy.prototype.init = async function() {\nthis.input,\nthis.outputDir,\nformats,\n- this.data\n+ this.data,\n+ this.isPassthroughAll\n);\n// TODO maybe isVerbose -> console.log?\n@@ -264,21 +269,15 @@ Eleventy.prototype.watch = async function() {\nignored: this.writer.getGlobWatcherIgnores()\n});\n- watcher.on(\n- \"change\",\n- async function(path, stat) {\n+ watcher.on(\"change\", async path => {\nconsole.log(\"File changed:\", path);\nthis._watch(path);\n- }.bind(this)\n- );\n+ });\n- watcher.on(\n- \"add\",\n- async function(path, stat) {\n+ watcher.on(\"add\", async path => {\nconsole.log(\"File added:\", path);\nthis._watch(path);\n- }.bind(this)\n- );\n+ });\n};\nEleventy.prototype.serve = function(port) {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/EleventyCommandCheck.js",
"new_path": "src/EleventyCommandCheck.js",
"diff": "@@ -11,7 +11,15 @@ class EleventyCommandCheck {\n\"port\"\n];\n- this.booleanArgs = [\"quiet\", \"version\", \"watch\", \"dryrun\", \"help\", \"serve\"];\n+ this.booleanArgs = [\n+ \"quiet\",\n+ \"version\",\n+ \"watch\",\n+ \"dryrun\",\n+ \"help\",\n+ \"serve\",\n+ \"passthroughall\"\n+ ];\nthis.args = argv;\nthis.argsMap = this.getArgumentLookupMap();\n"
},
{
"change_type": "MODIFY",
"old_path": "src/EleventyExtensionMap.js",
"new_path": "src/EleventyExtensionMap.js",
"diff": "@@ -9,16 +9,10 @@ class EleventyExtensionMap {\nreturn key.trim().toLowerCase();\n});\n- this.formats = this.unfilteredFormats.filter(\n- function(key) {\n- return this.hasExtension(key);\n- }.bind(this)\n- );\n+ this.formats = this.unfilteredFormats.filter(key => this.hasExtension(key));\nthis.prunedFormats = this.unfilteredFormats.filter(\n- function(key) {\n- return !this.hasExtension(key);\n- }.bind(this)\n+ key => !this.hasExtension(key)\n);\n}\n@@ -31,9 +25,7 @@ class EleventyExtensionMap {\nreturn [];\n}\nreturn this.formats.map(\n- function(key) {\n- return (dir ? dir + \"/\" : \"\") + path + \".\" + this.getExtension(key);\n- }.bind(this)\n+ key => (dir ? dir + \"/\" : \"\") + path + \".\" + this.getExtension(key)\n);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateWriter.js",
"new_path": "src/TemplateWriter.js",
"diff": "@@ -13,7 +13,13 @@ const config = require(\"./Config\");\nconst debug = require(\"debug\")(\"Eleventy:TemplateWriter\");\nconst debugDev = require(\"debug\")(\"Dev:Eleventy:TemplateWriter\");\n-function TemplateWriter(inputPath, outputDir, templateKeys, templateData) {\n+function TemplateWriter(\n+ inputPath,\n+ outputDir,\n+ templateKeys,\n+ templateData,\n+ isPassthroughAll\n+) {\nthis.config = config.getConfig();\nthis.input = inputPath;\nthis.inputDir = this._getInputPathDir(inputPath);\n@@ -29,6 +35,7 @@ function TemplateWriter(inputPath, outputDir, templateKeys, templateData) {\nthis.dataDir = this.inputDir + \"/\" + this.config.dir.data;\nthis.extensionMap = new EleventyExtensionMap(this.templateKeys);\n+ this.passthroughAll = isPassthroughAll;\nthis.setPassthroughManager();\nthis.setupGlobs();\n@@ -50,7 +57,15 @@ TemplateWriter.prototype.setupGlobs = function() {\n}\nthis.cachedIgnores = this.getIgnores();\n+\n+ if (this.passthroughAll) {\n+ this.watchedGlobs = TemplateGlob.map([\n+ TemplateGlob.normalizePath(this.input, \"/**\")\n+ ]).concat(this.cachedIgnores);\n+ } else {\nthis.watchedGlobs = this.templateGlobs.concat(this.cachedIgnores);\n+ }\n+\nthis.templateGlobsWithIgnores = this.watchedGlobs.concat(\nthis.getTemplateIgnores()\n);\n"
}
] | JavaScript | MIT License | 11ty/eleventy | --passthroughall option to copy everything in the input directory (template or not). Will only process templates though. Requested by #162 |
699 | 14.08.2018 09:01:34 | 18,000 | 200d1b6f812aaeea8513ab9291e3ac85f4b77510 | Exit with error code 1 on error. | [
{
"change_type": "MODIFY",
"old_path": "cmd.js",
"new_path": "cmd.js",
"diff": "@@ -22,6 +22,7 @@ try {\ncmdCheck.hasUnknownArguments();\n} catch (e) {\nconsole.log(chalk.red(\"Eleventy error:\"), chalk.red(e.toString()));\n+ process.exitCode = 1;\nreturn;\n}\n@@ -52,4 +53,5 @@ try {\n});\n} catch (e) {\nconsole.log(chalk.red(\"Eleventy error:\"), e);\n+ process.exitCode = 1;\n}\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Exit with error code 1 on error. |
699 | 14.08.2018 20:49:00 | 18,000 | 171d0c211d0dbdbbd04775b9b2df7f84d224ede0 | Log warnings with slow config callbacks (ignore when --quiet) | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Benchmark.js",
"diff": "+class Benchmark {\n+ constructor() {\n+ this.reset();\n+ }\n+\n+ reset() {\n+ this.timeSpent = 0;\n+ this.beforeDates = [];\n+ }\n+\n+ before() {\n+ this.beforeDates.push(new Date());\n+ }\n+\n+ after() {\n+ if (!this.beforeDates.length) {\n+ throw new Error(\"You called Benchmark after() without a before().\");\n+ }\n+\n+ let before = this.beforeDates.pop();\n+ if (!this.beforeDates.length) {\n+ this.timeSpent += new Date().getTime() - before.getTime();\n+ }\n+ }\n+\n+ getTotal() {\n+ return this.timeSpent;\n+ }\n+\n+ getTotalString() {\n+ return this.timeSpent > 0 ? ` (${this.timeSpent}ms)` : \"\";\n+ }\n+}\n+\n+module.exports = Benchmark;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Eleventy.js",
"new_path": "src/Eleventy.js",
"diff": "@@ -9,6 +9,7 @@ const EleventyServe = require(\"./EleventyServe\");\nconst templateCache = require(\"./TemplateCache\");\nconst EleventyError = require(\"./EleventyError\");\nconst simplePlural = require(\"./Util/Pluralize\");\n+const eleventyConfig = require(\"./EleventyConfig\");\nconst config = require(\"./Config\");\nconst debug = require(\"debug\")(\"Eleventy\");\n@@ -83,6 +84,8 @@ Eleventy.prototype.restart = async function() {\n};\nEleventy.prototype.finish = function() {\n+ eleventyConfig.logSlowConfigOptions(new Date() - this.start, this.isVerbose);\n+\nconsole.log(this.logFinished());\ndebug(\"Finished writing templates.\");\n};\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/BenchmarkTest.js",
"diff": "+import test from \"ava\";\n+import Benchmark from \"../src/Benchmark\";\n+\n+function between(t, value, lowerBound, upperBound) {\n+ t.truthy(value >= lowerBound);\n+ t.truthy(value <= upperBound);\n+}\n+\n+test.cb(\"Standard Benchmark\", t => {\n+ let b = new Benchmark();\n+ b.before();\n+ setTimeout(function() {\n+ b.after();\n+ t.truthy(b.getTotal() >= 10);\n+ t.end();\n+ }, 10);\n+});\n+\n+test.cb(\n+ \"Nested Benchmark (nested calls are ignored while a parent is measuring)\",\n+ t => {\n+ let b = new Benchmark();\n+ b.before();\n+\n+ setTimeout(function() {\n+ b.before();\n+ b.after();\n+ t.is(b.getTotal(), 0);\n+\n+ b.after();\n+ t.truthy(b.getTotal() >= 10);\n+ t.end();\n+ }, 10);\n+ }\n+);\n+\n+test.cb(\"Reset Benchmark\", t => {\n+ let b = new Benchmark();\n+ b.before();\n+ b.reset();\n+\n+ setTimeout(function() {\n+ b.before();\n+ b.after();\n+ t.is(b.getTotal(), 0);\n+\n+ t.throws(function() {\n+ // throws because we reset\n+ b.after();\n+ });\n+ t.end();\n+ }, 10);\n+});\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Log warnings with slow config callbacks (ignore when --quiet) |
699 | 14.08.2018 20:50:48 | 18,000 | 7d67b99080ef29ca3bc38ddf68ec13c87ec0d2cb | v0.5.1 coverage | [
{
"change_type": "MODIFY",
"old_path": "docs-src/_data/coverage.json",
"new_path": "docs-src/_data/coverage.json",
"diff": "-{\"total\": {\"lines\":{\"total\":1996,\"covered\":1697,\"skipped\":0,\"pct\":85.02},\"statements\":{\"total\":1998,\"covered\":1699,\"skipped\":0,\"pct\":85.04},\"functions\":{\"total\":459,\"covered\":382,\"skipped\":0,\"pct\":83.22},\"branches\":{\"total\":663,\"covered\":499,\"skipped\":0,\"pct\":75.26}}\n+{\"total\": {\"lines\":{\"total\":2082,\"covered\":1797,\"skipped\":0,\"pct\":86.31},\"statements\":{\"total\":2086,\"covered\":1801,\"skipped\":0,\"pct\":86.34},\"functions\":{\"total\":481,\"covered\":410,\"skipped\":0,\"pct\":85.24},\"branches\":{\"total\":681,\"covered\":513,\"skipped\":0,\"pct\":75.33}}\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/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\":172,\"covered\":91,\"skipped\":0,\"pct\":52.91},\"functions\":{\"total\":24,\"covered\":9,\"skipped\":0,\"pct\":37.5},\"statements\":{\"total\":172,\"covered\":91,\"skipped\":0,\"pct\":52.91},\"branches\":{\"total\":44,\"covered\":10,\"skipped\":0,\"pct\":22.73}}\n+,\"/Users/zachleat/Code/eleventy/src/Eleventy.js\": {\"lines\":{\"total\":174,\"covered\":92,\"skipped\":0,\"pct\":52.87},\"functions\":{\"total\":24,\"covered\":9,\"skipped\":0,\"pct\":37.5},\"statements\":{\"total\":174,\"covered\":92,\"skipped\":0,\"pct\":52.87},\"branches\":{\"total\":44,\"covered\":10,\"skipped\":0,\"pct\":22.73}}\n,\"/Users/zachleat/Code/eleventy/src/EleventyCommandCheck.js\": {\"lines\":{\"total\":27,\"covered\":27,\"skipped\":0,\"pct\":100},\"functions\":{\"total\":5,\"covered\":5,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":27,\"covered\":27,\"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/EleventyError.js\": {\"lines\":{\"total\":12,\"covered\":12,\"skipped\":0,\"pct\":100},\"functions\":{\"total\":5,\"covered\":5,\"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/EleventyExtensionMap.js\": {\"lines\":{\"total\":24,\"covered\":24,\"skipped\":0,\"pct\":100},\"functions\":{\"total\":14,\"covered\":14,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":24,\"covered\":24,\"skipped\":0,\"pct\":100},\"branches\":{\"total\":10,\"covered\":9,\"skipped\":0,\"pct\":90}}\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\":31,\"covered\":0,\"skipped\":0,\"pct\":0}}\n-,\"/Users/zachleat/Code/eleventy/src/Template.js\": {\"lines\":{\"total\":275,\"covered\":245,\"skipped\":0,\"pct\":89.09},\"functions\":{\"total\":48,\"covered\":40,\"skipped\":0,\"pct\":83.33},\"statements\":{\"total\":275,\"covered\":245,\"skipped\":0,\"pct\":89.09},\"branches\":{\"total\":107,\"covered\":86,\"skipped\":0,\"pct\":80.37}}\n+,\"/Users/zachleat/Code/eleventy/src/Template.js\": {\"lines\":{\"total\":222,\"covered\":202,\"skipped\":0,\"pct\":90.99},\"functions\":{\"total\":40,\"covered\":35,\"skipped\":0,\"pct\":87.5},\"statements\":{\"total\":222,\"covered\":202,\"skipped\":0,\"pct\":90.99},\"branches\":{\"total\":85,\"covered\":68,\"skipped\":0,\"pct\":80}}\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\":33,\"covered\":30,\"skipped\":0,\"pct\":90.91},\"functions\":{\"total\":15,\"covered\":13,\"skipped\":0,\"pct\":86.67},\"statements\":{\"total\":34,\"covered\":31,\"skipped\":0,\"pct\":91.18},\"branches\":{\"total\":12,\"covered\":10,\"skipped\":0,\"pct\":83.33}}\n+,\"/Users/zachleat/Code/eleventy/src/TemplateCollection.js\": {\"lines\":{\"total\":30,\"covered\":28,\"skipped\":0,\"pct\":93.33},\"functions\":{\"total\":13,\"covered\":12,\"skipped\":0,\"pct\":92.31},\"statements\":{\"total\":32,\"covered\":30,\"skipped\":0,\"pct\":93.75},\"branches\":{\"total\":12,\"covered\":10,\"skipped\":0,\"pct\":83.33}}\n,\"/Users/zachleat/Code/eleventy/src/TemplateConfig.js\": {\"lines\":{\"total\":54,\"covered\":46,\"skipped\":0,\"pct\":85.19},\"functions\":{\"total\":8,\"covered\":5,\"skipped\":0,\"pct\":62.5},\"statements\":{\"total\":54,\"covered\":46,\"skipped\":0,\"pct\":85.19},\"branches\":{\"total\":18,\"covered\":17,\"skipped\":0,\"pct\":94.44}}\n-,\"/Users/zachleat/Code/eleventy/src/TemplateData.js\": {\"lines\":{\"total\":122,\"covered\":119,\"skipped\":0,\"pct\":97.54},\"functions\":{\"total\":18,\"covered\":18,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":122,\"covered\":119,\"skipped\":0,\"pct\":97.54},\"branches\":{\"total\":32,\"covered\":25,\"skipped\":0,\"pct\":78.13}}\n+,\"/Users/zachleat/Code/eleventy/src/TemplateContent.js\": {\"lines\":{\"total\":49,\"covered\":46,\"skipped\":0,\"pct\":93.88},\"functions\":{\"total\":12,\"covered\":12,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":49,\"covered\":46,\"skipped\":0,\"pct\":93.88},\"branches\":{\"total\":12,\"covered\":9,\"skipped\":0,\"pct\":75}}\n+,\"/Users/zachleat/Code/eleventy/src/TemplateData.js\": {\"lines\":{\"total\":123,\"covered\":120,\"skipped\":0,\"pct\":97.56},\"functions\":{\"total\":18,\"covered\":18,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":123,\"covered\":120,\"skipped\":0,\"pct\":97.56},\"branches\":{\"total\":32,\"covered\":25,\"skipped\":0,\"pct\":78.13}}\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\":38,\"covered\":37,\"skipped\":0,\"pct\":97.37},\"functions\":{\"total\":6,\"covered\":6,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":38,\"covered\":37,\"skipped\":0,\"pct\":97.37},\"branches\":{\"total\":14,\"covered\":13,\"skipped\":0,\"pct\":92.86}}\n-,\"/Users/zachleat/Code/eleventy/src/TemplateMap.js\": {\"lines\":{\"total\":99,\"covered\":98,\"skipped\":0,\"pct\":98.99},\"functions\":{\"total\":19,\"covered\":19,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":99,\"covered\":98,\"skipped\":0,\"pct\":98.99},\"branches\":{\"total\":22,\"covered\":18,\"skipped\":0,\"pct\":81.82}}\n-,\"/Users/zachleat/Code/eleventy/src/TemplatePassthrough.js\": {\"lines\":{\"total\":12,\"covered\":10,\"skipped\":0,\"pct\":83.33},\"functions\":{\"total\":4,\"covered\":3,\"skipped\":0,\"pct\":75},\"statements\":{\"total\":12,\"covered\":10,\"skipped\":0,\"pct\":83.33},\"branches\":{\"total\":2,\"covered\":0,\"skipped\":0,\"pct\":0}}\n-,\"/Users/zachleat/Code/eleventy/src/TemplatePassthroughManager.js\": {\"lines\":{\"total\":52,\"covered\":33,\"skipped\":0,\"pct\":63.46},\"functions\":{\"total\":13,\"covered\":10,\"skipped\":0,\"pct\":76.92},\"statements\":{\"total\":52,\"covered\":33,\"skipped\":0,\"pct\":63.46},\"branches\":{\"total\":12,\"covered\":8,\"skipped\":0,\"pct\":66.67}}\n+,\"/Users/zachleat/Code/eleventy/src/TemplateLayout.js\": {\"lines\":{\"total\":65,\"covered\":65,\"skipped\":0,\"pct\":100},\"functions\":{\"total\":9,\"covered\":9,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":65,\"covered\":65,\"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\":101,\"covered\":100,\"skipped\":0,\"pct\":99.01},\"functions\":{\"total\":19,\"covered\":19,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":101,\"covered\":100,\"skipped\":0,\"pct\":99.01},\"branches\":{\"total\":26,\"covered\":22,\"skipped\":0,\"pct\":84.62}}\n+,\"/Users/zachleat/Code/eleventy/src/TemplatePassthrough.js\": {\"lines\":{\"total\":11,\"covered\":9,\"skipped\":0,\"pct\":81.82},\"functions\":{\"total\":4,\"covered\":3,\"skipped\":0,\"pct\":75},\"statements\":{\"total\":11,\"covered\":9,\"skipped\":0,\"pct\":81.82},\"branches\":{\"total\":2,\"covered\":0,\"skipped\":0,\"pct\":0}}\n+,\"/Users/zachleat/Code/eleventy/src/TemplatePassthroughManager.js\": {\"lines\":{\"total\":54,\"covered\":41,\"skipped\":0,\"pct\":75.93},\"functions\":{\"total\":15,\"covered\":12,\"skipped\":0,\"pct\":80},\"statements\":{\"total\":54,\"covered\":41,\"skipped\":0,\"pct\":75.93},\"branches\":{\"total\":12,\"covered\":9,\"skipped\":0,\"pct\":75}}\n,\"/Users/zachleat/Code/eleventy/src/TemplatePath.js\": {\"lines\":{\"total\":81,\"covered\":79,\"skipped\":0,\"pct\":97.53},\"functions\":{\"total\":18,\"covered\":17,\"skipped\":0,\"pct\":94.44},\"statements\":{\"total\":81,\"covered\":79,\"skipped\":0,\"pct\":97.53},\"branches\":{\"total\":54,\"covered\":52,\"skipped\":0,\"pct\":96.3}}\n,\"/Users/zachleat/Code/eleventy/src/TemplatePermalink.js\": {\"lines\":{\"total\":31,\"covered\":31,\"skipped\":0,\"pct\":100},\"functions\":{\"total\":7,\"covered\":7,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":31,\"covered\":31,\"skipped\":0,\"pct\":100},\"branches\":{\"total\":20,\"covered\":20,\"skipped\":0,\"pct\":100}}\n-,\"/Users/zachleat/Code/eleventy/src/TemplateRender.js\": {\"lines\":{\"total\":79,\"covered\":78,\"skipped\":0,\"pct\":98.73},\"functions\":{\"total\":17,\"covered\":17,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":79,\"covered\":78,\"skipped\":0,\"pct\":98.73},\"branches\":{\"total\":36,\"covered\":34,\"skipped\":0,\"pct\":94.44}}\n-,\"/Users/zachleat/Code/eleventy/src/TemplateWriter.js\": {\"lines\":{\"total\":156,\"covered\":130,\"skipped\":0,\"pct\":83.33},\"functions\":{\"total\":31,\"covered\":23,\"skipped\":0,\"pct\":74.19},\"statements\":{\"total\":156,\"covered\":130,\"skipped\":0,\"pct\":83.33},\"branches\":{\"total\":32,\"covered\":25,\"skipped\":0,\"pct\":78.13}}\n-,\"/Users/zachleat/Code/eleventy/src/UserConfig.js\": {\"lines\":{\"total\":127,\"covered\":82,\"skipped\":0,\"pct\":64.57},\"functions\":{\"total\":38,\"covered\":21,\"skipped\":0,\"pct\":55.26},\"statements\":{\"total\":128,\"covered\":83,\"skipped\":0,\"pct\":64.84},\"branches\":{\"total\":44,\"covered\":20,\"skipped\":0,\"pct\":45.45}}\n+,\"/Users/zachleat/Code/eleventy/src/TemplateRender.js\": {\"lines\":{\"total\":78,\"covered\":77,\"skipped\":0,\"pct\":98.72},\"functions\":{\"total\":17,\"covered\":17,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":78,\"covered\":77,\"skipped\":0,\"pct\":98.72},\"branches\":{\"total\":36,\"covered\":34,\"skipped\":0,\"pct\":94.44}}\n+,\"/Users/zachleat/Code/eleventy/src/TemplateWriter.js\": {\"lines\":{\"total\":162,\"covered\":147,\"skipped\":0,\"pct\":90.74},\"functions\":{\"total\":34,\"covered\":28,\"skipped\":0,\"pct\":82.35},\"statements\":{\"total\":162,\"covered\":147,\"skipped\":0,\"pct\":90.74},\"branches\":{\"total\":34,\"covered\":27,\"skipped\":0,\"pct\":79.41}}\n+,\"/Users/zachleat/Code/eleventy/src/UserConfig.js\": {\"lines\":{\"total\":150,\"covered\":93,\"skipped\":0,\"pct\":62},\"functions\":{\"total\":41,\"covered\":23,\"skipped\":0,\"pct\":56.1},\"statements\":{\"total\":151,\"covered\":94,\"skipped\":0,\"pct\":62.25},\"branches\":{\"total\":50,\"covered\":22,\"skipped\":0,\"pct\":44}}\n,\"/Users/zachleat/Code/eleventy/src/Engines/Ejs.js\": {\"lines\":{\"total\":22,\"covered\":21,\"skipped\":0,\"pct\":95.45},\"functions\":{\"total\":7,\"covered\":6,\"skipped\":0,\"pct\":85.71},\"statements\":{\"total\":22,\"covered\":21,\"skipped\":0,\"pct\":95.45},\"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/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\":57,\"skipped\":0,\"pct\":91.94},\"functions\":{\"total\":21,\"covered\":21,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":62,\"covered\":57,\"skipped\":0,\"pct\":91.94},\"branches\":{\"total\":6,\"covered\":4,\"skipped\":0,\"pct\":66.67}}\n,\"/Users/zachleat/Code/eleventy/src/Engines/Pug.js\": {\"lines\":{\"total\":17,\"covered\":17,\"skipped\":0,\"pct\":100},\"functions\":{\"total\":5,\"covered\":5,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":17,\"covered\":17,\"skipped\":0,\"pct\":100},\"branches\":{\"total\":4,\"covered\":3,\"skipped\":0,\"pct\":75}}\n-,\"/Users/zachleat/Code/eleventy/src/Engines/TemplateEngine.js\": {\"lines\":{\"total\":36,\"covered\":36,\"skipped\":0,\"pct\":100},\"functions\":{\"total\":11,\"covered\":11,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":36,\"covered\":36,\"skipped\":0,\"pct\":100},\"branches\":{\"total\":6,\"covered\":6,\"skipped\":0,\"pct\":100}}\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/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\":19,\"covered\":19,\"skipped\":0,\"pct\":100},\"functions\":{\"total\":1,\"covered\":1,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":19,\"covered\":19,\"skipped\":0,\"pct\":100},\"branches\":{\"total\":23,\"covered\":23,\"skipped\":0,\"pct\":100}}\n-,\"/Users/zachleat/Code/eleventy/src/Plugins/Pagination.js\": {\"lines\":{\"total\":95,\"covered\":87,\"skipped\":0,\"pct\":91.58},\"functions\":{\"total\":14,\"covered\":13,\"skipped\":0,\"pct\":92.86},\"statements\":{\"total\":95,\"covered\":87,\"skipped\":0,\"pct\":91.58},\"branches\":{\"total\":42,\"covered\":35,\"skipped\":0,\"pct\":83.33}}\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\":94,\"covered\":86,\"skipped\":0,\"pct\":91.49},\"functions\":{\"total\":14,\"covered\":13,\"skipped\":0,\"pct\":92.86},\"statements\":{\"total\":94,\"covered\":86,\"skipped\":0,\"pct\":91.49},\"branches\":{\"total\":42,\"covered\":35,\"skipped\":0,\"pct\":83.33}}\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/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-,\"/Users/zachleat/Code/eleventy/src/Util/Sortable.js\": {\"lines\":{\"total\":56,\"covered\":46,\"skipped\":0,\"pct\":82.14},\"functions\":{\"total\":26,\"covered\":18,\"skipped\":0,\"pct\":69.23},\"statements\":{\"total\":56,\"covered\":46,\"skipped\":0,\"pct\":82.14},\"branches\":{\"total\":20,\"covered\":19,\"skipped\":0,\"pct\":95}}\n+,\"/Users/zachleat/Code/eleventy/src/Util/Sortable.js\": {\"lines\":{\"total\":46,\"covered\":39,\"skipped\":0,\"pct\":84.78},\"functions\":{\"total\":23,\"covered\":17,\"skipped\":0,\"pct\":73.91},\"statements\":{\"total\":47,\"covered\":40,\"skipped\":0,\"pct\":85.11},\"branches\":{\"total\":18,\"covered\":17,\"skipped\":0,\"pct\":94.44}}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "docs/coverage.md",
"new_path": "docs/coverage.md",
"diff": "-# Code Coverage for Eleventy v0.5.0\n+# Code Coverage for Eleventy v0.5.1\n| Filename | % Lines | % Statements | % Functions | % Branches |\n| ------------------------------------------ | ------- | ------------ | ----------- | ---------- |\n-| `total` | 85.02% | 85.04% | 83.22% | 75.26% |\n+| `total` | 86.31% | 86.34% | 85.24% | 75.33% |\n| `config.js` | 100% | 100% | 100% | 100% |\n+| `src/Benchmark.js` | 91.67% | 91.67% | 83.33% | 66.67% |\n| `src/Config.js` | 100% | 100% | 100% | 100% |\n-| `src/Eleventy.js` | 52.91% | 52.91% | 37.5% | 22.73% |\n+| `src/Eleventy.js` | 52.87% | 52.87% | 37.5% | 22.73% |\n| `src/EleventyCommandCheck.js` | 100% | 100% | 100% | 87.5% |\n| `src/EleventyConfig.js` | 100% | 100% | 100% | 100% |\n| `src/EleventyError.js` | 100% | 100% | 100% | 100% |\n| `src/EleventyExtensionMap.js` | 100% | 100% | 100% | 90% |\n| `src/EleventyServe.js` | 19.64% | 19.64% | 46.15% | 0% |\n-| `src/Template.js` | 89.09% | 89.09% | 83.33% | 80.37% |\n+| `src/Template.js` | 90.99% | 90.99% | 87.5% | 80% |\n| `src/TemplateCache.js` | 100% | 100% | 100% | 100% |\n-| `src/TemplateCollection.js` | 90.91% | 91.18% | 86.67% | 83.33% |\n+| `src/TemplateCollection.js` | 93.33% | 93.75% | 92.31% | 83.33% |\n| `src/TemplateConfig.js` | 85.19% | 85.19% | 62.5% | 94.44% |\n-| `src/TemplateData.js` | 97.54% | 97.54% | 100% | 78.13% |\n+| `src/TemplateContent.js` | 93.88% | 93.88% | 100% | 75% |\n+| `src/TemplateData.js` | 97.56% | 97.56% | 100% | 78.13% |\n| `src/TemplateFileSlug.js` | 100% | 100% | 100% | 100% |\n| `src/TemplateGlob.js` | 93.33% | 93.33% | 100% | 87.5% |\n-| `src/TemplateLayout.js` | 97.37% | 97.37% | 100% | 92.86% |\n-| `src/TemplateMap.js` | 98.99% | 98.99% | 100% | 81.82% |\n-| `src/TemplatePassthrough.js` | 83.33% | 83.33% | 75% | 0% |\n-| `src/TemplatePassthroughManager.js` | 63.46% | 63.46% | 76.92% | 66.67% |\n+| `src/TemplateLayout.js` | 100% | 100% | 100% | 100% |\n+| `src/TemplateLayoutPathResolver.js` | 96.97% | 96.97% | 100% | 92.86% |\n+| `src/TemplateMap.js` | 99.01% | 99.01% | 100% | 84.62% |\n+| `src/TemplatePassthrough.js` | 81.82% | 81.82% | 75% | 0% |\n+| `src/TemplatePassthroughManager.js` | 75.93% | 75.93% | 80% | 75% |\n| `src/TemplatePath.js` | 97.53% | 97.53% | 94.44% | 96.3% |\n| `src/TemplatePermalink.js` | 100% | 100% | 100% | 100% |\n-| `src/TemplateRender.js` | 98.73% | 98.73% | 100% | 94.44% |\n-| `src/TemplateWriter.js` | 83.33% | 83.33% | 74.19% | 78.13% |\n-| `src/UserConfig.js` | 64.57% | 64.84% | 55.26% | 45.45% |\n+| `src/TemplateRender.js` | 98.72% | 98.72% | 100% | 94.44% |\n+| `src/TemplateWriter.js` | 90.74% | 90.74% | 82.35% | 79.41% |\n+| `src/UserConfig.js` | 62% | 62.25% | 56.1% | 44% |\n| `src/Engines/Ejs.js` | 95.45% | 95.45% | 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/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` | 91.58% | 91.58% | 92.86% | 83.33% |\n+| `src/Plugins/Pagination.js` | 91.49% | 91.49% | 92.86% | 83.33% |\n| `src/Util/Capitalize.js` | 100% | 100% | 100% | 100% |\n| `src/Util/Pluralize.js` | 100% | 100% | 100% | 100% |\n-| `src/Util/Sortable.js` | 82.14% | 82.14% | 69.23% | 95% |\n+| `src/Util/Sortable.js` | 84.78% | 85.11% | 73.91% | 94.44% |\n"
}
] | JavaScript | MIT License | 11ty/eleventy | v0.5.1 coverage |
699 | 15.08.2018 08:01:43 | 18,000 | 9e2acf7f4df1b6095507a42655a33bf60fe29dab | Hmm, slow config API call benchmarks were not resetting on watch. | [
{
"change_type": "MODIFY",
"old_path": "src/Eleventy.js",
"new_path": "src/Eleventy.js",
"diff": "@@ -229,6 +229,9 @@ Eleventy.prototype._watch = async function(path) {\n// reset and reload global configuration :O\nif (path === config.getLocalProjectConfigFile()) {\nthis.resetConfig();\n+ } else {\n+ // a lighter config reset (mostly benchmarks)\n+ config.resetOnWatch();\n}\nawait this.restart();\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateConfig.js",
"new_path": "src/TemplateConfig.js",
"diff": "@@ -30,6 +30,10 @@ class TemplateConfig {\nthis.config = this.mergeConfig(this.localProjectConfigPath);\n}\n+ resetOnWatch() {\n+ eleventyConfig.resetOnWatch();\n+ }\n+\ngetConfig() {\nreturn this.config;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/UserConfig.js",
"new_path": "src/UserConfig.js",
"diff": "@@ -47,6 +47,10 @@ class UserConfig {\nthis.benchmarks = {};\n}\n+ resetOnWatch() {\n+ this.benchmarks = {};\n+ }\n+\nversionCheck(expected) {\nif (!semver.satisfies(pkg.version, expected)) {\nthrow new Error(\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Hmm, slow config API call benchmarks were not resetting on watch. |
689 | 16.08.2018 09:53:17 | -7,200 | 9ee98773b7b4740b69eb139dec62b94a8dcd8ce9 | Fix incorrect debug log for TemplateEngine#cachePartialFiles
The `debug()` printed the keys of `this.partials`, but should instead print the local variable `partials`, which includes the found partials. | [
{
"change_type": "MODIFY",
"old_path": "src/Engines/TemplateEngine.js",
"new_path": "src/Engines/TemplateEngine.js",
"diff": "@@ -58,7 +58,7 @@ class TemplateEngine {\ndebug(\n`${this.inputDir}/*${this.extension} found partials for: %o`,\n- Object.keys(this.partials)\n+ Object.keys(partials)\n);\nreturn partials;\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Fix incorrect debug log for TemplateEngine#cachePartialFiles
The `debug()` printed the keys of `this.partials`, but should instead print the local variable `partials`, which includes the found partials. |
699 | 16.08.2018 23:52:34 | 18,000 | 7552633bae607de234385ec459a38e3c6c861291 | Use warnings debug log | [
{
"change_type": "MODIFY",
"old_path": "src/UserConfig.js",
"new_path": "src/UserConfig.js",
"diff": "@@ -3,6 +3,7 @@ const chalk = require(\"chalk\");\nconst semver = require(\"semver\");\nconst { DateTime } = require(\"luxon\");\nconst debug = require(\"debug\")(\"Eleventy:UserConfig\");\n+const debugWarn = require(\"debug\")(\"Eleventy:Warnings\");\nconst pkg = require(\"../package.json\");\nconst Benchmark = require(\"./Benchmark\");\n@@ -476,15 +477,15 @@ class UserConfig {\nlet percent = (totalForBenchmark * 100) / totalTimeSpent;\nif (percent > thresholdPercent) {\nlet str = chalk.yellow(\n- `Warning: a slow \"${name}\" ${type} was found in your config file (${bench.getTotal()}ms, ${percent.toFixed(\n+ `A slow \"${name}\" ${type} was found in your config file (${bench.getTotal()}ms, ${percent.toFixed(\n1\n)}%)`\n);\nif (isVerbose) {\n- console.log(str);\n- } else {\n- debug(str);\n+ console.log(\"Warning:\", str);\n}\n+\n+ debugWarn(str);\n}\n}\n}\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Use warnings debug log |
699 | 19.08.2018 14:03:19 | 18,000 | a56cdf3bacb93cf0a579d94f2b467a4a2fc3e0d4 | Fixes using configurable .11tydata.js files | [
{
"change_type": "MODIFY",
"old_path": "config.js",
"new_path": "config.js",
"diff": "@@ -25,6 +25,7 @@ module.exports = function(config) {\ndataTemplateEngine: \"liquid\",\npassthroughFileCopy: true,\nhtmlOutputSuffix: \"-o\",\n+ jsDataFileSuffix: \".11tydata.js\",\nkeys: {\npackage: \"pkg\",\nlayout: \"layout\",\n"
},
{
"change_type": "MODIFY",
"old_path": "src/EleventyExtensionMap.js",
"new_path": "src/EleventyExtensionMap.js",
"diff": "@@ -61,7 +61,19 @@ class EleventyExtensionMap {\nreturn this.keyMapToExtension[key];\n}\n- get keyMapToExtension() {\n+ static 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+ }\n+ }\n+ return path;\n+ }\n+\n+ static get keyMap() {\nreturn {\nejs: \"ejs\",\nmd: \"md\",\n@@ -76,6 +88,10 @@ class EleventyExtensionMap {\n\"11ty.js\": \"11ty.js\"\n};\n}\n+\n+ get keyMapToExtension() {\n+ return EleventyExtensionMap.keyMap;\n+ }\n}\nmodule.exports = EleventyExtensionMap;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateData.js",
"new_path": "src/TemplateData.js",
"diff": "@@ -7,6 +7,7 @@ const lodashUniq = require(\"lodash.uniq\");\nconst TemplateRender = require(\"./TemplateRender\");\nconst TemplatePath = require(\"./TemplatePath\");\nconst TemplateGlob = require(\"./TemplateGlob\");\n+const EleventyExtensionMap = require(\"./EleventyExtensionMap\");\nconst config = require(\"./Config\");\nconst debugWarn = require(\"debug\")(\"Eleventy:Warnings\");\nconst debug = require(\"debug\")(\"Eleventy:TemplateData\");\n@@ -237,9 +238,19 @@ TemplateData.prototype.getLocalDataPaths = async function(templatePath) {\ndebugDev(\"parsed.dir: %o\", parsed.dir);\nif (parsed.dir) {\n- let filePathNoExt = parsed.dir + \"/\" + parsed.name;\n+ let fileNameNoExt = EleventyExtensionMap.removeTemplateExtension(\n+ parsed.base\n+ );\n+ let filePathNoExt = parsed.dir + \"/\" + fileNameNoExt;\n+ let isFilenameMatch = parsed.base === fileNameNoExt + \".11tydata.js\";\n+ let dataSuffix = this.config.jsDataFileSuffix;\n+ debug(\"Using %o to find data files.\", dataSuffix);\npaths.push(filePathNoExt + \".json\");\n- paths.push(filePathNoExt + \".js\");\n+\n+ // ignore if any .js template (including .11ty.js) since the filenames will be the same\n+ if (!isFilenameMatch) {\n+ paths.push(filePathNoExt + dataSuffix);\n+ }\nlet allDirs = TemplatePath.getAllDirs(parsed.dir);\ndebugDev(\"allDirs: %o\", allDirs);\n@@ -249,12 +260,18 @@ TemplateData.prototype.getLocalDataPaths = async function(templatePath) {\nif (!inputDir) {\npaths.push(dirPathNoExt + \".json\");\n- paths.push(dirPathNoExt + \".js\");\n+\n+ if (!isFilenameMatch) {\n+ paths.push(dirPathNoExt + dataSuffix);\n+ }\n} else {\ndebugDev(\"dirStr: %o; inputDir: %o\", dir, inputDir);\nif (dir.indexOf(inputDir) === 0 && dir !== inputDir) {\npaths.push(dirPathNoExt + \".json\");\n- paths.push(dirPathNoExt + \".js\");\n+\n+ if (!isFilenameMatch) {\n+ paths.push(dirPathNoExt + dataSuffix);\n+ }\n}\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "test/EleventyExtensionMapTest.js",
"new_path": "test/EleventyExtensionMapTest.js",
"diff": "@@ -75,3 +75,21 @@ test(\"fileList with dir in path and dir\", t => {\n\"_includes/layouts/filename.pug\"\n]);\n});\n+\n+test(\"removeTemplateExtension\", t => {\n+ t.is(\n+ EleventyExtensionMap.removeTemplateExtension(\"component.njk\"),\n+ \"component\"\n+ );\n+ t.is(\n+ EleventyExtensionMap.removeTemplateExtension(\"component.11ty.js\"),\n+ \"component\"\n+ );\n+\n+ t.is(EleventyExtensionMap.removeTemplateExtension(\"\"), \"\");\n+ t.is(EleventyExtensionMap.removeTemplateExtension(\"component\"), \"component\");\n+ t.is(\n+ EleventyExtensionMap.removeTemplateExtension(\"component.js\"),\n+ \"component.js\"\n+ );\n+});\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateDataTest.js",
"new_path": "test/TemplateDataTest.js",
"diff": "@@ -43,7 +43,7 @@ test(\"Data dir does not exist\", async t => {\nawait t.throws(dataObj.getData());\n});\n-test(\"addLocalData()\", async t => {\n+test(\"Add local data\", async t => {\nlet dataObj = new TemplateData(\"./test/stubs/\");\nlet data = await dataObj.getData();\n@@ -191,7 +191,19 @@ test(\"getLocalDataPaths\", async t => {\n);\nt.deepEqual(paths, [\n- \"./test/stubs/component/component.js\",\n+ \"./test/stubs/component/component.11tydata.js\",\n+ \"./test/stubs/component/component.json\"\n+ ]);\n+});\n+\n+test(\"getLocalDataPaths with an 11ty js template\", async t => {\n+ let dataObj = new TemplateData(\"./test/stubs/\");\n+ let paths = await dataObj.getLocalDataPaths(\n+ \"./test/stubs/component/component.11ty.js\"\n+ );\n+\n+ t.deepEqual(paths, [\n+ \"./test/stubs/component/component.11tydata.js\",\n\"./test/stubs/component/component.json\"\n]);\n});\n@@ -203,7 +215,7 @@ test(\"getLocalDataPaths with inputDir passed in (trailing slash)\", async t => {\n);\nt.deepEqual(paths, [\n- \"./test/stubs/component/component.js\",\n+ \"./test/stubs/component/component.11tydata.js\",\n\"./test/stubs/component/component.json\"\n]);\n});\n@@ -215,7 +227,7 @@ test(\"getLocalDataPaths with inputDir passed in (no trailing slash)\", async t =>\n);\nt.deepEqual(paths, [\n- \"./test/stubs/component/component.js\",\n+ \"./test/stubs/component/component.11tydata.js\",\n\"./test/stubs/component/component.json\"\n]);\n});\n@@ -227,7 +239,7 @@ test(\"getLocalDataPaths with inputDir passed in (no leading slash)\", async t =>\n);\nt.deepEqual(paths, [\n- \"./test/stubs/component/component.js\",\n+ \"./test/stubs/component/component.11tydata.js\",\n\"./test/stubs/component/component.json\"\n]);\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateTest.js",
"new_path": "test/TemplateTest.js",
"diff": "@@ -448,7 +448,7 @@ test(\"Local template data file import (without a global data json)\", async t =>\nlet data = await tmpl.getData();\nt.deepEqual(await dataObj.getLocalDataPaths(tmpl.getInputPath()), [\n- \"./test/stubs/component/component.js\",\n+ \"./test/stubs/component/component.11tydata.js\",\n\"./test/stubs/component/component.json\"\n]);\nt.is(data.localdatakey1, \"localdatavalue1\");\n@@ -467,11 +467,11 @@ test(\"Local template data file import (two subdirectories deep)\", async t => {\n);\nt.deepEqual(await dataObj.getLocalDataPaths(tmpl.getInputPath()), [\n- \"./test/stubs/firstdir/firstdir.js\",\n+ \"./test/stubs/firstdir/firstdir.11tydata.js\",\n\"./test/stubs/firstdir/firstdir.json\",\n- \"./test/stubs/firstdir/seconddir/seconddir.js\",\n+ \"./test/stubs/firstdir/seconddir/seconddir.11tydata.js\",\n\"./test/stubs/firstdir/seconddir/seconddir.json\",\n- \"./test/stubs/firstdir/seconddir/component.js\",\n+ \"./test/stubs/firstdir/seconddir/component.11tydata.js\",\n\"./test/stubs/firstdir/seconddir/component.json\"\n]);\n});\n@@ -489,9 +489,9 @@ test(\"Posts inherits local JSON, layouts\", async t => {\nlet localDataPaths = await dataObj.getLocalDataPaths(tmpl.getInputPath());\nt.deepEqual(localDataPaths, [\n- \"./test/stubs/posts/posts.js\",\n+ \"./test/stubs/posts/posts.11tydata.js\",\n\"./test/stubs/posts/posts.json\",\n- \"./test/stubs/posts/post1.js\",\n+ \"./test/stubs/posts/post1.11tydata.js\",\n\"./test/stubs/posts/post1.json\"\n]);\n@@ -522,7 +522,7 @@ test(\"Template and folder name are the same, make sure data imports work ok\", as\nlet localDataPaths = await dataObj.getLocalDataPaths(tmpl.getInputPath());\nt.deepEqual(localDataPaths, [\n- \"./test/stubs/posts/posts.js\",\n+ \"./test/stubs/posts/posts.11tydata.js\",\n\"./test/stubs/posts/posts.json\"\n]);\n"
},
{
"change_type": "RENAME",
"old_path": "test/stubs/component/component.js",
"new_path": "test/stubs/component/component.11tydata.js",
"diff": ""
}
] | JavaScript | MIT License | 11ty/eleventy | Fixes #155 using configurable .11tydata.js files |
699 | 19.08.2018 16:02:42 | 18,000 | f7ae7aff782c4992d650093154dad4a3917ac1a1 | Switch to use `.11tydata` for suffix which now supports both .js and .json data files. Allows consistent use of the suffix across .js and .json data files for | [
{
"change_type": "MODIFY",
"old_path": "config.js",
"new_path": "config.js",
"diff": "@@ -25,7 +25,7 @@ module.exports = function(config) {\ndataTemplateEngine: \"liquid\",\npassthroughFileCopy: true,\nhtmlOutputSuffix: \"-o\",\n- jsDataFileSuffix: \".11tydata.js\",\n+ jsDataFileSuffix: \".11tydata\",\nkeys: {\npackage: \"pkg\",\nlayout: \"layout\",\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateData.js",
"new_path": "src/TemplateData.js",
"diff": "@@ -242,15 +242,11 @@ TemplateData.prototype.getLocalDataPaths = async function(templatePath) {\nparsed.base\n);\nlet filePathNoExt = parsed.dir + \"/\" + fileNameNoExt;\n- let isFilenameMatch = parsed.base === fileNameNoExt + \".11tydata.js\";\nlet dataSuffix = this.config.jsDataFileSuffix;\ndebug(\"Using %o to find data files.\", dataSuffix);\npaths.push(filePathNoExt + \".json\");\n-\n- // ignore if any .js template (including .11ty.js) since the filenames will be the same\n- if (!isFilenameMatch) {\n- paths.push(filePathNoExt + dataSuffix);\n- }\n+ paths.push(filePathNoExt + dataSuffix + \".js\");\n+ paths.push(filePathNoExt + dataSuffix + \".json\");\nlet allDirs = TemplatePath.getAllDirs(parsed.dir);\ndebugDev(\"allDirs: %o\", allDirs);\n@@ -260,18 +256,14 @@ TemplateData.prototype.getLocalDataPaths = async function(templatePath) {\nif (!inputDir) {\npaths.push(dirPathNoExt + \".json\");\n-\n- if (!isFilenameMatch) {\n- paths.push(dirPathNoExt + dataSuffix);\n- }\n+ paths.push(dirPathNoExt + dataSuffix + \".js\");\n+ paths.push(dirPathNoExt + dataSuffix + \".json\");\n} else {\ndebugDev(\"dirStr: %o; inputDir: %o\", dir, inputDir);\nif (dir.indexOf(inputDir) === 0 && dir !== inputDir) {\npaths.push(dirPathNoExt + \".json\");\n-\n- if (!isFilenameMatch) {\n- paths.push(dirPathNoExt + dataSuffix);\n- }\n+ paths.push(dirPathNoExt + dataSuffix + \".js\");\n+ paths.push(dirPathNoExt + dataSuffix + \".json\");\n}\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateDataTest.js",
"new_path": "test/TemplateDataTest.js",
"diff": "@@ -191,6 +191,7 @@ test(\"getLocalDataPaths\", async t => {\n);\nt.deepEqual(paths, [\n+ \"./test/stubs/component/component.11tydata.json\",\n\"./test/stubs/component/component.11tydata.js\",\n\"./test/stubs/component/component.json\"\n]);\n@@ -203,6 +204,7 @@ test(\"getLocalDataPaths with an 11ty js template\", async t => {\n);\nt.deepEqual(paths, [\n+ \"./test/stubs/component/component.11tydata.json\",\n\"./test/stubs/component/component.11tydata.js\",\n\"./test/stubs/component/component.json\"\n]);\n@@ -215,6 +217,7 @@ test(\"getLocalDataPaths with inputDir passed in (trailing slash)\", async t => {\n);\nt.deepEqual(paths, [\n+ \"./test/stubs/component/component.11tydata.json\",\n\"./test/stubs/component/component.11tydata.js\",\n\"./test/stubs/component/component.json\"\n]);\n@@ -227,6 +230,7 @@ test(\"getLocalDataPaths with inputDir passed in (no trailing slash)\", async t =>\n);\nt.deepEqual(paths, [\n+ \"./test/stubs/component/component.11tydata.json\",\n\"./test/stubs/component/component.11tydata.js\",\n\"./test/stubs/component/component.json\"\n]);\n@@ -239,6 +243,7 @@ test(\"getLocalDataPaths with inputDir passed in (no leading slash)\", async t =>\n);\nt.deepEqual(paths, [\n+ \"./test/stubs/component/component.11tydata.json\",\n\"./test/stubs/component/component.11tydata.js\",\n\"./test/stubs/component/component.json\"\n]);\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateTest.js",
"new_path": "test/TemplateTest.js",
"diff": "@@ -448,6 +448,7 @@ test(\"Local template data file import (without a global data json)\", async t =>\nlet data = await tmpl.getData();\nt.deepEqual(await dataObj.getLocalDataPaths(tmpl.getInputPath()), [\n+ \"./test/stubs/component/component.11tydata.json\",\n\"./test/stubs/component/component.11tydata.js\",\n\"./test/stubs/component/component.json\"\n]);\n@@ -467,10 +468,13 @@ test(\"Local template data file import (two subdirectories deep)\", async t => {\n);\nt.deepEqual(await dataObj.getLocalDataPaths(tmpl.getInputPath()), [\n+ \"./test/stubs/firstdir/firstdir.11tydata.json\",\n\"./test/stubs/firstdir/firstdir.11tydata.js\",\n\"./test/stubs/firstdir/firstdir.json\",\n+ \"./test/stubs/firstdir/seconddir/seconddir.11tydata.json\",\n\"./test/stubs/firstdir/seconddir/seconddir.11tydata.js\",\n\"./test/stubs/firstdir/seconddir/seconddir.json\",\n+ \"./test/stubs/firstdir/seconddir/component.11tydata.json\",\n\"./test/stubs/firstdir/seconddir/component.11tydata.js\",\n\"./test/stubs/firstdir/seconddir/component.json\"\n]);\n@@ -489,8 +493,10 @@ test(\"Posts inherits local JSON, layouts\", async t => {\nlet localDataPaths = await dataObj.getLocalDataPaths(tmpl.getInputPath());\nt.deepEqual(localDataPaths, [\n+ \"./test/stubs/posts/posts.11tydata.json\",\n\"./test/stubs/posts/posts.11tydata.js\",\n\"./test/stubs/posts/posts.json\",\n+ \"./test/stubs/posts/post1.11tydata.json\",\n\"./test/stubs/posts/post1.11tydata.js\",\n\"./test/stubs/posts/post1.json\"\n]);\n@@ -522,6 +528,7 @@ test(\"Template and folder name are the same, make sure data imports work ok\", as\nlet localDataPaths = await dataObj.getLocalDataPaths(tmpl.getInputPath());\nt.deepEqual(localDataPaths, [\n+ \"./test/stubs/posts/posts.11tydata.json\",\n\"./test/stubs/posts/posts.11tydata.js\",\n\"./test/stubs/posts/posts.json\"\n]);\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Switch to use `.11tydata` for suffix which now supports both .js and .json data files. Allows consistent use of the suffix across .js and .json data files for #155 |
699 | 19.08.2018 16:24:33 | 18,000 | 0f4793d84e9a20cda9699b27c6bcdc89dfb37409 | Change order of inclusion so that the .11tydata.js > .11tydata.json > .json data files | [
{
"change_type": "MODIFY",
"old_path": "src/TemplateData.js",
"new_path": "src/TemplateData.js",
"diff": "@@ -244,9 +244,9 @@ TemplateData.prototype.getLocalDataPaths = async function(templatePath) {\nlet filePathNoExt = parsed.dir + \"/\" + fileNameNoExt;\nlet dataSuffix = this.config.jsDataFileSuffix;\ndebug(\"Using %o to find data files.\", dataSuffix);\n- paths.push(filePathNoExt + \".json\");\npaths.push(filePathNoExt + dataSuffix + \".js\");\npaths.push(filePathNoExt + dataSuffix + \".json\");\n+ paths.push(filePathNoExt + \".json\");\nlet allDirs = TemplatePath.getAllDirs(parsed.dir);\ndebugDev(\"allDirs: %o\", allDirs);\n@@ -255,15 +255,15 @@ TemplateData.prototype.getLocalDataPaths = async function(templatePath) {\nlet dirPathNoExt = dir + \"/\" + lastDir;\nif (!inputDir) {\n- paths.push(dirPathNoExt + \".json\");\npaths.push(dirPathNoExt + dataSuffix + \".js\");\npaths.push(dirPathNoExt + dataSuffix + \".json\");\n+ paths.push(dirPathNoExt + \".json\");\n} else {\ndebugDev(\"dirStr: %o; inputDir: %o\", dir, inputDir);\nif (dir.indexOf(inputDir) === 0 && dir !== inputDir) {\n- paths.push(dirPathNoExt + \".json\");\npaths.push(dirPathNoExt + dataSuffix + \".js\");\npaths.push(dirPathNoExt + dataSuffix + \".json\");\n+ paths.push(dirPathNoExt + \".json\");\n}\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateTest.js",
"new_path": "test/TemplateTest.js",
"diff": "@@ -448,9 +448,9 @@ test(\"Local template data file import (without a global data json)\", async t =>\nlet data = await tmpl.getData();\nt.deepEqual(await dataObj.getLocalDataPaths(tmpl.getInputPath()), [\n+ \"./test/stubs/component/component.json\",\n\"./test/stubs/component/component.11tydata.json\",\n- \"./test/stubs/component/component.11tydata.js\",\n- \"./test/stubs/component/component.json\"\n+ \"./test/stubs/component/component.11tydata.js\"\n]);\nt.is(data.localdatakey1, \"localdatavalue1\");\nt.is(await tmpl.render(), \"localdatavalue1\");\n@@ -468,15 +468,15 @@ 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/firstdir.json\",\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/seconddir.json\",\n+ \"./test/stubs/firstdir/seconddir/component.json\",\n\"./test/stubs/firstdir/seconddir/component.11tydata.json\",\n- \"./test/stubs/firstdir/seconddir/component.11tydata.js\",\n- \"./test/stubs/firstdir/seconddir/component.json\"\n+ \"./test/stubs/firstdir/seconddir/component.11tydata.js\"\n]);\n});\n@@ -493,12 +493,12 @@ test(\"Posts inherits local JSON, layouts\", async t => {\nlet localDataPaths = await dataObj.getLocalDataPaths(tmpl.getInputPath());\nt.deepEqual(localDataPaths, [\n+ \"./test/stubs/posts/posts.json\",\n\"./test/stubs/posts/posts.11tydata.json\",\n\"./test/stubs/posts/posts.11tydata.js\",\n- \"./test/stubs/posts/posts.json\",\n+ \"./test/stubs/posts/post1.json\",\n\"./test/stubs/posts/post1.11tydata.json\",\n- \"./test/stubs/posts/post1.11tydata.js\",\n- \"./test/stubs/posts/post1.json\"\n+ \"./test/stubs/posts/post1.11tydata.js\"\n]);\nlet localData = await dataObj.getLocalData(tmpl.getInputPath());\n@@ -528,9 +528,9 @@ test(\"Template and folder name are the same, make sure data imports work ok\", as\nlet localDataPaths = await dataObj.getLocalDataPaths(tmpl.getInputPath());\nt.deepEqual(localDataPaths, [\n+ \"./test/stubs/posts/posts.json\",\n\"./test/stubs/posts/posts.11tydata.json\",\n- \"./test/stubs/posts/posts.11tydata.js\",\n- \"./test/stubs/posts/posts.json\"\n+ \"./test/stubs/posts/posts.11tydata.js\"\n]);\nlet localData = await dataObj.getLocalData(tmpl.getInputPath());\n"
},
{
"change_type": "MODIFY",
"old_path": "test/stubs/component/component.11tydata.js",
"new_path": "test/stubs/component/component.11tydata.js",
"diff": "module.exports = {\n- localdatakeyfromjs: \"howdy\"\n+ localdatakeyfromjs: \"howdydoody\"\n};\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/component/component.11tydata.json",
"diff": "+{\n+ \"localdatakeyfromjs\": \"this_is_overridden\",\n+ \"localdatakeyfromjs2\": \"howdy2\"\n+}\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "test/stubs/component/component.json",
"new_path": "test/stubs/component/component.json",
"diff": "{\n- \"localdatakey1\": \"localdatavalue1\"\n+ \"localdatakey1\": \"localdatavalue1\",\n+ \"localdatakeyfromjs\": \"this_is_also_overridden\"\n}\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Change order of inclusion so that the .11tydata.js > .11tydata.json > .json data files |
699 | 19.08.2018 16:43:19 | 18,000 | 4c19ed880449a852bfdb640c8f087231c366a745 | Add support for async data files | [
{
"change_type": "MODIFY",
"old_path": "src/TemplateData.js",
"new_path": "src/TemplateData.js",
"diff": "@@ -199,7 +199,7 @@ TemplateData.prototype.getDataValue = async function(\nif (await fs.pathExists(localPath)) {\nlet returnValue = require(localPath);\nif (typeof returnValue === \"function\") {\n- return returnValue();\n+ return await returnValue();\n}\nreturn returnValue;\n} else {\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/component-async/component.11tydata.js",
"diff": "+module.exports = async function() {\n+ return new Promise(resolve => {\n+ setTimeout(function() {\n+ resolve({\n+ localdatakeyfromjs: \"howdydoody\"\n+ });\n+ }, 1);\n+ });\n+};\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/component-async/component.njk",
"diff": "+{{localdatakey1}}\n\\ No newline at end of file\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Add support for async data files #155 |
699 | 20.08.2018 08:40:34 | 18,000 | 3bfbe65687fb4283a26b4e4db1e9cc8a5b14cf4c | Class syntax | [
{
"change_type": "MODIFY",
"old_path": "src/TemplateData.js",
"new_path": "src/TemplateData.js",
"diff": "@@ -13,7 +13,8 @@ const debugWarn = require(\"debug\")(\"Eleventy:Warnings\");\nconst debug = require(\"debug\")(\"Eleventy:TemplateData\");\nconst debugDev = require(\"debug\")(\"Dev:Eleventy:TemplateData\");\n-function TemplateData(inputDir) {\n+class TemplateData {\n+ constructor(inputDir) {\nthis.config = config.getConfig();\nthis.dataTemplateEngine = this.config.dataTemplateEngine;\n@@ -24,18 +25,20 @@ function TemplateData(inputDir) {\nthis.globalData = null;\n}\n-TemplateData.prototype.setInputDir = function(inputDir) {\n+ setInputDir(inputDir) {\nthis.inputDirNeedsCheck = true;\nthis.inputDir = inputDir;\nthis.dataDir =\n- inputDir + \"/\" + (this.config.dir.data !== \".\" ? this.config.dir.data : \"\");\n-};\n+ inputDir +\n+ \"/\" +\n+ (this.config.dir.data !== \".\" ? this.config.dir.data : \"\");\n+ }\n-TemplateData.prototype.setDataTemplateEngine = function(engineName) {\n+ setDataTemplateEngine(engineName) {\nthis.dataTemplateEngine = engineName;\n-};\n+ }\n-TemplateData.prototype.getRawImports = function() {\n+ getRawImports() {\nlet pkgPath = TemplatePath.localPath(\"package.json\");\ntry {\n@@ -48,35 +51,32 @@ TemplateData.prototype.getRawImports = function() {\n}\nreturn this.rawImports;\n-};\n+ }\n-TemplateData.prototype.getDataDir = function() {\n+ getDataDir() {\nreturn this.dataDir;\n-};\n+ }\n-TemplateData.prototype.clearData = function() {\n+ clearData() {\nthis.globalData = null;\n-};\n+ }\n-TemplateData.prototype.cacheData = async function() {\n+ async cacheData() {\nthis.clearData();\nreturn this.getData();\n-};\n+ }\n-TemplateData.prototype._getGlobalDataGlobByExtension = async function(\n- dir,\n- extension\n-) {\n+ async _getGlobalDataGlobByExtension(dir, extension) {\nreturn TemplateGlob.normalizePath(\ndir,\n\"/\",\nthis.config.dir.data !== \".\" ? this.config.dir.data : \"\",\n`/**/*.${extension}`\n);\n-};\n+ }\n-TemplateData.prototype._checkInputDir = async function() {\n+ async _checkInputDir() {\nif (this.inputDirNeedsCheck) {\nlet globalPathStat = await fs.stat(this.inputDir);\n@@ -86,9 +86,9 @@ TemplateData.prototype._checkInputDir = async function() {\nthis.inputDirNeedsCheck = false;\n}\n-};\n+ }\n-TemplateData.prototype.getGlobalDataGlob = async function() {\n+ async getGlobalDataGlob() {\nlet dir = \".\";\nif (this.inputDir) {\n@@ -97,22 +97,22 @@ TemplateData.prototype.getGlobalDataGlob = async function() {\n}\nreturn [await this._getGlobalDataGlobByExtension(dir, \"(json|js)\")];\n-};\n+ }\n-TemplateData.prototype.getGlobalDataFiles = async function() {\n+ async getGlobalDataFiles() {\nreturn fastglob.async(await this.getGlobalDataGlob());\n-};\n+ }\n-TemplateData.prototype.getObjectPathForDataFile = function(path) {\n+ getObjectPathForDataFile(path) {\nlet reducedPath = TemplatePath.stripPathFromDir(path, this.dataDir);\nlet parsed = parsePath(reducedPath);\nlet folders = parsed.dir ? parsed.dir.split(\"/\") : [];\nfolders.push(parsed.name);\nreturn folders.join(\".\");\n-};\n+ }\n-TemplateData.prototype.getAllGlobalData = async function() {\n+ async getAllGlobalData() {\nlet rawImports = this.getRawImports();\nlet globalData = {};\nlet files = TemplatePath.addLeadingDotSlashArray(\n@@ -141,9 +141,9 @@ TemplateData.prototype.getAllGlobalData = async function() {\n}\nreturn globalData;\n-};\n+ }\n-TemplateData.prototype.getData = async function() {\n+ async getData() {\nlet rawImports = this.getRawImports();\nif (!this.globalData) {\n@@ -153,9 +153,9 @@ TemplateData.prototype.getData = async function() {\n}\nreturn this.globalData;\n-};\n+ }\n-TemplateData.prototype.combineLocalData = async function(localDataPaths) {\n+ async combineLocalData(localDataPaths) {\nlet rawImports = this.getRawImports();\nlet localData = {};\nif (!Array.isArray(localDataPaths)) {\n@@ -167,9 +167,9 @@ TemplateData.prototype.combineLocalData = async function(localDataPaths) {\n// debug(\"`combineLocalData` (iterating) for %o: %O\", path, localData);\n}\nreturn localData;\n-};\n+ }\n-TemplateData.prototype.getLocalData = async function(templatePath) {\n+ async getLocalData(templatePath) {\nlet localDataPaths = await this.getLocalDataPaths(templatePath);\nlet importedData = await this.combineLocalData(localDataPaths);\nlet globalData = await this.getData();\n@@ -177,9 +177,9 @@ TemplateData.prototype.getLocalData = async function(templatePath) {\nlet localData = Object.assign({}, globalData, importedData);\n// debug(\"`getLocalData` for %o: %O\", templatePath, localData);\nreturn localData;\n-};\n+ }\n-TemplateData.prototype._getLocalJsonString = async function(path) {\n+ async _getLocalJsonString(path) {\nlet rawInput;\ntry {\nrawInput = await fs.readFile(path, \"utf-8\");\n@@ -187,13 +187,9 @@ TemplateData.prototype._getLocalJsonString = async function(path) {\n// if file does not exist, return nothing\n}\nreturn rawInput;\n-};\n+ }\n-TemplateData.prototype.getDataValue = async function(\n- path,\n- rawImports,\n- ignoreProcessing\n-) {\n+ async getDataValue(path, rawImports, ignoreProcessing) {\nif (ignoreProcessing || TemplatePath.getExtension(path) === \"js\") {\nlet localPath = TemplatePath.localPath(path);\nif (await fs.pathExists(localPath)) {\n@@ -226,9 +222,9 @@ TemplateData.prototype.getDataValue = async function(\n}\nreturn {};\n-};\n+ }\n-TemplateData.prototype.getLocalDataPaths = async function(templatePath) {\n+ async getLocalDataPaths(templatePath) {\nlet paths = [];\nlet parsed = parsePath(templatePath);\nlet inputDir = TemplatePath.addLeadingDotSlash(\n@@ -271,6 +267,7 @@ TemplateData.prototype.getLocalDataPaths = async function(templatePath) {\ndebug(\"getLocalDataPaths(%o): %o\", templatePath, paths);\nreturn lodashUniq(paths).reverse();\n-};\n+ }\n+}\nmodule.exports = TemplateData;\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Class syntax |
664 | 20.08.2018 15:39:29 | 21,600 | 280deced29235c9b97676544b497e956a098cebc | update liquid to ^5.1.0 | [
{
"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.11\",\n- \"liquidjs\": \"^4.0.0\",\n+ \"liquidjs\": \"^5.1.0\",\n\"lodash.chunk\": \"^4.2.0\",\n\"lodash.clone\": \"^4.5.0\",\n\"lodash.get\": \"^4.4.2\",\n"
}
] | JavaScript | MIT License | 11ty/eleventy | update liquid to ^5.1.0
https://github.com/harttle/liquidjs/issues/72 |
699 | 20.08.2018 17:55:09 | 18,000 | 4c9c0f0cfc169cd9fa657fbf9abbe0c171c31054 | Adds benchmark code to template data JavaScript files | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/BenchmarkGroup.js",
"diff": "+const chalk = require(\"chalk\");\n+\n+const Benchmark = require(\"./Benchmark\");\n+const debugWarn = require(\"debug\")(\"Eleventy:Warnings\");\n+\n+class BenchmarkGroup {\n+ constructor() {\n+ this.benchmarks = {};\n+ this.start = new Date();\n+ this.isVerbose = true;\n+ }\n+\n+ reset() {\n+ this.start = new Date();\n+\n+ for (var type in this.benchmarks) {\n+ this.benchmarks[type].reset();\n+ }\n+ }\n+\n+ // TODO make this async\n+ add(type, callback) {\n+ let benchmark = (this.benchmarks[type] = new Benchmark());\n+\n+ return function(...args) {\n+ benchmark.before();\n+ let ret = callback.call(this, ...args);\n+ benchmark.after();\n+ return ret;\n+ };\n+ }\n+\n+ get(type) {\n+ this.benchmarks[type] = new Benchmark();\n+ return this.benchmarks[type];\n+ }\n+\n+ finish(location, thresholdPercent, isVerbose) {\n+ let totalTimeSpent = new Date().getTime() - this.start.getTime();\n+ thresholdPercent = thresholdPercent || 10;\n+ for (var type in this.benchmarks) {\n+ let bench = this.benchmarks[type];\n+ let totalForBenchmark = bench.getTotal();\n+ let percent = (totalForBenchmark * 100) / totalTimeSpent;\n+ if (percent > thresholdPercent) {\n+ let str = chalk.yellow(\n+ `${location}: Found a slow ${type} (${bench.getTotal()}ms, ${percent.toFixed(\n+ 1\n+ )}%)`\n+ );\n+ if (isVerbose) {\n+ console.log(str);\n+ }\n+\n+ debugWarn(str);\n+ }\n+ }\n+ }\n+}\n+\n+module.exports = BenchmarkGroup;\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/BenchmarkManager.js",
"diff": "+const BenchmarkGroup = require(\"./BenchmarkGroup\");\n+\n+class BenchmarkManager {\n+ constructor() {\n+ this.benches = {};\n+ this.isVerbose = true;\n+ }\n+\n+ reset() {\n+ for (var j in this.benches) {\n+ this.benches[j].reset();\n+ }\n+ }\n+\n+ setVerboseOutput(isVerbose) {\n+ this.isVerbose = !!isVerbose;\n+ }\n+\n+ getBenchmarkGroup(name) {\n+ if (!this.benches[name]) {\n+ this.benches[name] = new BenchmarkGroup();\n+ }\n+\n+ return this.benches[name];\n+ }\n+\n+ getAll() {\n+ return this.benches;\n+ }\n+\n+ get(name) {\n+ if (name) {\n+ return this.getBenchmarkGroup(name);\n+ }\n+\n+ return this.getAll();\n+ }\n+\n+ finish(thresholdPercent) {\n+ for (var j in this.benches) {\n+ this.benches[j].finish(j, thresholdPercent, this.isVerbose);\n+ }\n+ }\n+}\n+\n+let manager = new BenchmarkManager();\n+module.exports = manager;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Eleventy.js",
"new_path": "src/Eleventy.js",
"diff": "@@ -9,8 +9,8 @@ const EleventyServe = require(\"./EleventyServe\");\nconst templateCache = require(\"./TemplateCache\");\nconst EleventyError = require(\"./EleventyError\");\nconst simplePlural = require(\"./Util/Pluralize\");\n-const eleventyConfig = require(\"./EleventyConfig\");\nconst config = require(\"./Config\");\n+const bench = require(\"./BenchmarkManager\");\nconst debug = require(\"debug\")(\"Eleventy\");\nfunction Eleventy(input, output) {\n@@ -82,13 +82,14 @@ Eleventy.prototype.restart = async function() {\ndebug(\"Restarting\");\nthis.start = new Date();\ntemplateCache.clear();\n+ bench.reset();\nthis.initDirs();\nawait this.init();\n};\nEleventy.prototype.finish = function() {\n- eleventyConfig.logSlowConfigOptions(new Date() - this.start, this.isVerbose);\n+ bench.finish();\nconsole.log(this.logFinished());\ndebug(\"Finished writing templates.\");\n@@ -172,6 +173,9 @@ Eleventy.prototype.setIsVerbose = function(isVerbose) {\nif (this.writer) {\nthis.writer.setVerboseOutput(this.isVerbose);\n}\n+ if (bench) {\n+ bench.setVerboseOutput(this.isVerbose);\n+ }\n};\nEleventy.prototype.setFormats = function(formats) {\n@@ -234,10 +238,8 @@ Eleventy.prototype._watch = async function(path) {\n// reset and reload global configuration :O\nif (path === config.getLocalProjectConfigFile()) {\nthis.resetConfig();\n- } else {\n- // a lighter config reset (mostly benchmarks)\n- config.resetOnWatch();\n}\n+ config.resetOnWatch();\nawait this.restart();\nawait this.write();\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateConfig.js",
"new_path": "src/TemplateConfig.js",
"diff": "@@ -31,7 +31,7 @@ class TemplateConfig {\n}\nresetOnWatch() {\n- eleventyConfig.resetOnWatch();\n+ // nothing yet\n}\ngetConfig() {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateData.js",
"new_path": "src/TemplateData.js",
"diff": "@@ -8,6 +8,7 @@ const TemplateRender = require(\"./TemplateRender\");\nconst TemplatePath = require(\"./TemplatePath\");\nconst TemplateGlob = require(\"./TemplateGlob\");\nconst EleventyExtensionMap = require(\"./EleventyExtensionMap\");\n+const bench = require(\"./BenchmarkManager\").get(\"Data\");\nconst config = require(\"./Config\");\nconst debugWarn = require(\"debug\")(\"Eleventy:Warnings\");\nconst debug = require(\"debug\")(\"Eleventy:TemplateData\");\n@@ -193,10 +194,15 @@ class TemplateData {\nif (ignoreProcessing || TemplatePath.getExtension(path) === \"js\") {\nlet localPath = TemplatePath.localPath(path);\nif (await fs.pathExists(localPath)) {\n+ let dataBench = bench.get(`data file \"${path}\"`);\n+ dataBench.before();\n+\nlet returnValue = require(localPath);\nif (typeof returnValue === \"function\") {\n- return await returnValue();\n+ returnValue = await returnValue();\n}\n+\n+ dataBench.after();\nreturn returnValue;\n} else {\nreturn {};\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Adds benchmark code to template data JavaScript files |
699 | 20.08.2018 21:27:23 | 18,000 | 30cc5107a6a42d20b7cfc4c0dd1152d1b2f577d7 | Change some copy | [
{
"change_type": "MODIFY",
"old_path": "src/BenchmarkGroup.js",
"new_path": "src/BenchmarkGroup.js",
"diff": "@@ -44,7 +44,7 @@ class BenchmarkGroup {\nlet percent = (totalForBenchmark * 100) / totalTimeSpent;\nif (percent > thresholdPercent) {\nlet str = chalk.yellow(\n- `${location}: Found a slow ${type} (${bench.getTotal()}ms, ${percent.toFixed(\n+ `Benchmark (${location}): ${type} took ${bench.getTotal()}ms (${percent.toFixed(\n1\n)}%)`\n);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateData.js",
"new_path": "src/TemplateData.js",
"diff": "@@ -194,7 +194,7 @@ class TemplateData {\nif (ignoreProcessing || TemplatePath.getExtension(path) === \"js\") {\nlet localPath = TemplatePath.localPath(path);\nif (await fs.pathExists(localPath)) {\n- let dataBench = bench.get(`data file \"${path}\"`);\n+ let dataBench = bench.get(`\\`${path}\\``);\ndataBench.before();\nlet returnValue = require(localPath);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/UserConfig.js",
"new_path": "src/UserConfig.js",
"diff": "@@ -2,7 +2,7 @@ const EventEmitter = require(\"events\");\nconst chalk = require(\"chalk\");\nconst semver = require(\"semver\");\nconst { DateTime } = require(\"luxon\");\n-const bench = require(\"./BenchmarkManager\").get(\".eleventy.js\");\n+const bench = require(\"./BenchmarkManager\").get(\"Configuration\");\nconst debug = require(\"debug\")(\"Eleventy:UserConfig\");\nconst pkg = require(\"../package.json\");\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Change some copy |
699 | 20.08.2018 21:42:10 | 18,000 | a229d22487b811d9ac120948f2053b853543dcde | Clear require cache for JavaScript data files (if they change) | [
{
"change_type": "MODIFY",
"old_path": "src/Eleventy.js",
"new_path": "src/Eleventy.js",
"diff": "@@ -84,6 +84,9 @@ Eleventy.prototype.restart = async function() {\ntemplateCache.clear();\nbench.reset();\n+ // reload package.json values (if applicable)\n+ delete require.cache[TemplatePath.localPath(\"package.json\")];\n+\nthis.initDirs();\nawait this.init();\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateData.js",
"new_path": "src/TemplateData.js",
"diff": "@@ -196,7 +196,7 @@ class TemplateData {\nif (await fs.pathExists(localPath)) {\nlet dataBench = bench.get(`\\`${path}\\``);\ndataBench.before();\n-\n+ delete require.cache[localPath];\nlet returnValue = require(localPath);\nif (typeof returnValue === \"function\") {\nreturnValue = await returnValue();\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Clear require cache for JavaScript data files (if they change) |
699 | 24.08.2018 07:26:07 | 18,000 | d8552e56b692792ac394cfd2e55d1f284fa47833 | Scope leaking liquid test cc | [
{
"change_type": "MODIFY",
"old_path": "test/TemplateRenderLiquidTest.js",
"new_path": "test/TemplateRenderLiquidTest.js",
"diff": "@@ -390,3 +390,13 @@ test(\"Liquid Shortcode Multiple Args\", async t => {\n\"testhowdyZach\"\n);\n});\n+\n+test.skip(\"Liquid Include Scope Leak\", async t => {\n+ t.is(new TemplateRender(\"liquid\", \"./test/stubs/\").getEngineName(), \"liquid\");\n+\n+ let fn = await new TemplateRender(\n+ \"liquid\",\n+ \"./test/stubs/\"\n+ ).getCompiledTemplate(\"<p>{% include scopeleak %}{{ test }}</p>\");\n+ t.is(await fn({ test: 1 }), \"<p>21</p>\");\n+});\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/_includes/scopeleak.liquid",
"diff": "+{% assign test = 2 %}{{ test }}\n\\ No newline at end of file\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Scope leaking liquid test https://twitter.com/zachleat/status/1032397185005051904 cc @eduardoboucas |
699 | 24.08.2018 17:28:36 | 18,000 | 202f6f41af239eda824f7dec0a612c711f1bf1db | Fix to allow Eleventy to return things from addCollection that are not arrays of template objects. Think: arbitrary arrays, arbitrary objects, arbitrary strings, etc. | [
{
"change_type": "MODIFY",
"old_path": "src/TemplateMap.js",
"new_path": "src/TemplateMap.js",
"diff": "@@ -167,9 +167,20 @@ class TemplateMap {\nlet configCollections =\nthis.configCollections || eleventyConfig.getCollections();\nfor (let name in configCollections) {\n- collections[name] = this.createTemplateMapCopy(\n- configCollections[name](this.collection)\n- );\n+ let ret = configCollections[name](this.collection);\n+\n+ // work with arrays and strings returned from UserConfig.addCollection\n+ if (\n+ Array.isArray(ret) &&\n+ ret.length &&\n+ ret[0].inputPath &&\n+ ret[0].outputPath\n+ ) {\n+ collections[name] = this.createTemplateMapCopy(ret);\n+ } else {\n+ collections[name] = ret;\n+ }\n+\ndebug(\n`Collection: collections.${name} size: ${collections[name].length}`\n);\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Fix to allow Eleventy to return things from addCollection that are not arrays of template objects. Think: arbitrary arrays, arbitrary objects, arbitrary strings, etc. |
699 | 24.08.2018 17:34:23 | 18,000 | f744627f4fd1a10428c639f3a40a37bc10f26a9e | Tests for (return arbitrary types from UserConfig.addCollection) | [
{
"change_type": "MODIFY",
"old_path": "test/TemplateWriterTest.js",
"new_path": "test/TemplateWriterTest.js",
"diff": "@@ -105,6 +105,7 @@ test(\"_getCollectionsData with custom collection (ascending)\", async t => {\n[\"md\"]\n);\n+ /* Careful here, eleventyConfig is a global */\neleventyConfig.addCollection(\"customPostsAsc\", function(collection) {\nreturn collection.getFilteredByTag(\"post\").sort(function(a, b) {\nreturn a.date - b.date;\n@@ -126,6 +127,7 @@ test(\"_getCollectionsData with custom collection (descending)\", async t => {\n[\"md\"]\n);\n+ /* Careful here, eleventyConfig is a global */\neleventyConfig.addCollection(\"customPosts\", function(collection) {\nreturn collection.getFilteredByTag(\"post\").sort(function(a, b) {\nreturn b.date - a.date;\n@@ -147,6 +149,7 @@ test(\"_getCollectionsData with custom collection (filter only to markdown input)\n[\"md\"]\n);\n+ /* Careful here, eleventyConfig is a global */\neleventyConfig.addCollection(\"onlyMarkdown\", function(collection) {\nreturn collection.getAllSorted().filter(function(item) {\nlet extension = item.inputPath.split(\".\").pop();\n@@ -325,3 +328,43 @@ test(\"Pagination and TemplateContent\", async t => {\n\"./test/stubs/pagination-templatecontent/_site/post-2/index.html\"\n);\n});\n+\n+test(\"Custom collection returns array\", async t => {\n+ let tw = new TemplateWriter(\n+ \"./test/stubs/collection2\",\n+ \"./test/stubs/_site\",\n+ [\"md\"]\n+ );\n+\n+ /* Careful here, eleventyConfig is a global */\n+ eleventyConfig.addCollection(\"returnAllInputPaths\", function(collection) {\n+ return collection.getAllSorted().map(function(item) {\n+ return item.inputPath;\n+ });\n+ });\n+\n+ let paths = await tw._getAllPaths();\n+ let templateMap = await tw._createTemplateMap(paths);\n+ let collectionsData = await templateMap.getCollectionsData();\n+ t.is(collectionsData.returnAllInputPaths.length, 2);\n+ t.is(parsePath(collectionsData.returnAllInputPaths[0]).base, \"test1.md\");\n+ t.is(parsePath(collectionsData.returnAllInputPaths[1]).base, \"test2.md\");\n+});\n+\n+test(\"Custom collection returns a string\", async t => {\n+ let tw = new TemplateWriter(\n+ \"./test/stubs/collection2\",\n+ \"./test/stubs/_site\",\n+ [\"md\"]\n+ );\n+\n+ /* Careful here, eleventyConfig is a global */\n+ eleventyConfig.addCollection(\"returnATestString\", function(collection) {\n+ return \"test\";\n+ });\n+\n+ let paths = await tw._getAllPaths();\n+ let templateMap = await tw._createTemplateMap(paths);\n+ let collectionsData = await templateMap.getCollectionsData();\n+ t.is(collectionsData.returnATestString, \"test\");\n+});\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Tests for 202f6f41af239eda824f7dec0a612c711f1bf1db (return arbitrary types from UserConfig.addCollection) |
699 | 28.08.2018 17:39:24 | 18,000 | 882d007d20ca8d8044754f13c7faf0091edd2b77 | Fixes adds transforms to paginated templates | [
{
"change_type": "MODIFY",
"old_path": "src/Template.js",
"new_path": "src/Template.js",
"diff": "@@ -448,6 +448,9 @@ class Template extends TemplateContent {\nthis.templateData\n);\n+ for (let transform of this.transforms) {\n+ tmpl.addTransform(transform);\n+ }\ntmpl.setIsVerbose(this.isVerbose);\ntmpl.setDryRun(this.isDryRun);\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateTest.js",
"new_path": "test/TemplateTest.js",
"diff": "@@ -1061,3 +1061,36 @@ test(\"renderContent on a markdown file, permalink should not render markdown (ha\nt.is(await tmpl.getOutputLink(), \"/news/my-test-file/index.html\");\n});\n+\n+/* Transforms */\n+test(\"Test a transform\", async t => {\n+ let tmpl = new Template(\n+ \"./test/stubs/template.ejs\",\n+ \"./test/stubs/\",\n+ \"./test/stubs/_site\"\n+ );\n+\n+ tmpl.addTransform(function() {\n+ return \"OVERRIDE BY A TRANSFORM\";\n+ });\n+\n+ let data = await tmpl.getData();\n+ let rendered = await tmpl.getRenderedTemplates(data);\n+ t.is(rendered[0].templateContent, \"OVERRIDE BY A TRANSFORM\");\n+});\n+\n+test(\"Test a transform with pages\", async t => {\n+ let tmpl = new Template(\n+ \"./test/stubs/transform-pages/template.njk\",\n+ \"./test/stubs/\",\n+ \"./test/stubs/_site\"\n+ );\n+\n+ tmpl.addTransform(function() {\n+ return \"OVERRIDE BY A TRANSFORM\";\n+ });\n+\n+ let data = await tmpl.getData();\n+ let rendered = await tmpl.getRenderedTemplates(data);\n+ t.is(rendered[0].templateContent, \"OVERRIDE BY A TRANSFORM\");\n+});\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/transform-pages/template.njk",
"diff": "+---\n+pagination:\n+ data: testdata\n+ size: 4\n+testdata:\n+ - item1\n+ - item2\n+ - item3\n+ - item4\n+ - item5\n+ - item6\n+ - item7\n+ - item8\n+---\n+<ol>{% for item in pagination.items %}<li>{{ item }}</li>{% endfor %}</ol>\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Fixes #199, adds transforms to paginated templates |
699 | 07.09.2018 21:53:32 | 18,000 | 3671ba1fff033338a320e1fca017efde260e0022 | Fixes adds test for passthroughall.
Fixes by switching to `recursive-copy` instead of `fs-extra` | [
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"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.0\",\n\"slugify\": \"^1.3.0\",\n\"time-require\": \"^0.1.2\",\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Eleventy.js",
"new_path": "src/Eleventy.js",
"diff": "@@ -3,10 +3,10 @@ const chalk = require(\"chalk\");\nconst TemplatePath = require(\"./TemplatePath\");\nconst TemplateData = require(\"./TemplateData\");\nconst TemplateWriter = require(\"./TemplateWriter\");\n+const EleventyErrorHandler = require(\"./EleventyErrorHandler\");\nconst EleventyServe = require(\"./EleventyServe\");\nconst EleventyFiles = require(\"./EleventyFiles\");\nconst templateCache = require(\"./TemplateCache\");\n-const EleventyError = require(\"./EleventyError\");\nconst simplePlural = require(\"./Util/Pluralize\");\nconst config = require(\"./Config\");\nconst bench = require(\"./BenchmarkManager\");\n@@ -126,7 +126,12 @@ Eleventy.prototype.logFinished = function() {\nEleventy.prototype.init = async function() {\nlet formats = this.formatsOverride || this.config.templateFormats;\n- this.eleventyFiles = new EleventyFiles(this.input, this.outputDir, formats);\n+ this.eleventyFiles = new EleventyFiles(\n+ this.input,\n+ this.outputDir,\n+ formats,\n+ this.isPassthroughAll\n+ );\nthis.templateData = new TemplateData(this.inputDir);\nthis.eleventyFiles.setTemplateData(this.templateData);\n@@ -284,31 +289,29 @@ Eleventy.prototype.serve = function(port) {\n};\nEleventy.prototype.write = async function() {\n+ let ret;\ntry {\n- let ret = await this.writer.write();\n- this.finish();\n+ let promise = this.writer.write();\n- debug(`\n-Getting frustrated? Have a suggestion/feature request/feedback?\n-I want to hear it! Open an issue: https://github.com/11ty/eleventy/issues/new`);\n-\n- return ret;\n+ ret = await promise;\n} catch (e) {\nconsole.log(\n\"\\n\" +\nchalk.red(\n- \"Problem writing eleventy templates (more info in DEBUG output): \"\n+ \"Problem writing Eleventy templates (more info in DEBUG output): \"\n)\n);\n- if (e instanceof EleventyError) {\n- console.log(chalk.red(e.log()));\n- for (let err of e.getAll()) {\n- debug(\"%o\", err);\n- }\n- } else {\n- console.log(e);\n- }\n+\n+ EleventyErrorHandler.log(e);\n}\n+\n+ this.finish();\n+\n+ debug(`\n+Getting frustrated? Have a suggestion/feature request/feedback?\n+I want to hear it! Open an issue: https://github.com/11ty/eleventy/issues/new`);\n+\n+ return ret;\n};\nmodule.exports = Eleventy;\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/EleventyBaseError.js",
"diff": "+class EleventyBaseError extends Error {\n+ constructor(message, originalError) {\n+ super(message);\n+ Error.captureStackTrace(this, this.constructor);\n+ this.name = this.constructor.name;\n+\n+ this.originalError = originalError;\n+ }\n+}\n+module.exports = EleventyBaseError;\n"
},
{
"change_type": "DELETE",
"old_path": "src/EleventyError.js",
"new_path": null,
"diff": "-class EleventyError {\n- constructor(newErrorObj, oldErrorObj) {\n- this.errors = [newErrorObj, oldErrorObj];\n- }\n-\n- // if already an existing EleventyError, will push on to stack instead of creating a new EleventyError obj\n- static make(newErrorObj, oldErrorObj) {\n- if (oldErrorObj instanceof EleventyError) {\n- oldErrorObj.add(newErrorObj);\n- return oldErrorObj;\n- } else {\n- return new EleventyError(newErrorObj, oldErrorObj);\n- }\n- }\n-\n- add(errorObj) {\n- this.errors.push(errorObj);\n- }\n-\n- getAll() {\n- return this.errors;\n- }\n-\n- log() {\n- let str = [];\n- for (let err of this.errors) {\n- str.push(` * ${err}`);\n- }\n- return str.join(\"\\n\");\n- }\n-}\n-\n-module.exports = EleventyError;\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/EleventyErrorHandler.js",
"diff": "+const chalk = require(\"chalk\");\n+const debug = require(\"debug\")(\"Eleventy:EleventyErrorHandler\");\n+\n+class EleventyErrorHandler {\n+ static warn(e, msg) {\n+ EleventyErrorHandler.message(msg, \"warn\", \"yellow\");\n+ EleventyErrorHandler.log(e, \"warn\");\n+ }\n+\n+ static fatal(e, msg) {\n+ EleventyErrorHandler.error(e, msg);\n+ process.exitCode = 1;\n+ }\n+\n+ static error(e, msg) {\n+ EleventyErrorHandler.message(msg, \"error\", \"red\");\n+ EleventyErrorHandler.log(e, \"error\");\n+ }\n+\n+ static message(message, type = \"log\", chalkColor = \"blue\") {\n+ if (message) {\n+ console[type](\n+ chalk[chalkColor](message + \": (full stack in DEBUG output)\")\n+ );\n+ }\n+ }\n+\n+ static log(e, type = \"log\", prefix = \">\") {\n+ let ref = e;\n+ while (ref) {\n+ console[type](`${prefix} ${ref.message} (${ref.name})`);\n+ debug(`(${type}): %O`, ref.stack);\n+ ref = ref.originalError;\n+ }\n+ }\n+}\n+\n+module.exports = EleventyErrorHandler;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/EleventyFiles.js",
"new_path": "src/EleventyFiles.js",
"diff": "@@ -12,13 +12,14 @@ const debug = require(\"debug\")(\"Eleventy:EleventyFiles\");\n// const debugDev = require(\"debug\")(\"Dev:Eleventy:EleventyFiles\");\nclass EleventyFiles {\n- constructor(input, outputDir, formats) {\n+ constructor(input, outputDir, formats, passthroughAll) {\nthis.config = config.getConfig();\nthis.input = input;\nthis.inputDir = TemplatePath.getDir(this.input);\nthis.outputDir = outputDir;\nthis.includesDir = this.inputDir + \"/\" + this.config.dir.includes;\n+ this.passthroughAll = !!passthroughAll;\nthis.setFormats(formats);\nthis.setPassthroughManager();\n@@ -35,6 +36,10 @@ class EleventyFiles {\nthis.config = config;\n}\n+ setPassthroughAll(passthroughAll) {\n+ this.passthroughAll = !!passthroughAll;\n+ }\n+\nsetFormats(formats) {\nthis.formats = formats;\nthis.extensionMap = new EleventyExtensionMap(formats);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Engines/JavaScriptTemplateLiteral.js",
"new_path": "src/Engines/JavaScriptTemplateLiteral.js",
"diff": "const TemplateEngine = require(\"./TemplateEngine\");\n-const EleventyError = require(\"../EleventyError\");\n+const EleventyBaseError = require(\"../EleventyBaseError\");\n+\n+class JavaScriptTemplateLiteralCompileError extends EleventyBaseError {}\nclass JavaScriptTemplateLiteral extends TemplateEngine {\nasync compile(str, inputPath) {\n@@ -23,7 +25,10 @@ class JavaScriptTemplateLiteral extends TemplateEngine {\nlet val = eval(evalStr);\nreturn val;\n} catch (e) {\n- EleventyError.make(`Broken ES6 template:\\n${evalStr}`, e);\n+ throw new JavaScriptTemplateLiteralCompileError(\n+ `Broken ES6 template:\\n${evalStr}`,\n+ e\n+ );\n}\n};\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateContent.js",
"new_path": "src/TemplateContent.js",
"diff": "@@ -3,11 +3,14 @@ const normalize = require(\"normalize-path\");\nconst matter = require(\"gray-matter\");\nconst TemplateRender = require(\"./TemplateRender\");\n-const EleventyError = require(\"./EleventyError\");\n+const EleventyBaseError = require(\"./EleventyBaseError\");\nconst config = require(\"./Config\");\nconst debug = require(\"debug\")(\"Eleventy:TemplateContent\");\nconst debugDev = require(\"debug\")(\"Dev:Eleventy:TemplateContent\");\n+class TemplateContentCompileError extends EleventyBaseError {}\n+class TemplateContentRenderError extends EleventyBaseError {}\n+\nclass TemplateContent {\nconstructor(inputPath, inputDir) {\nthis.config = config.getConfig();\n@@ -97,10 +100,9 @@ class TemplateContent {\ndebugDev(\"%o getCompiledTemplate function created\", this.inputPath);\nreturn fn;\n} catch (e) {\n- throw EleventyError.make(\n- new Error(\n- `Having trouble compiling template ${this.inputPath}: ${str}`\n- ),\n+ debug(`Having trouble compiling template ${this.inputPath}: %O`, str);\n+ throw new TemplateContentRenderError(\n+ `Having trouble compiling template ${this.inputPath}`,\ne\n);\n}\n@@ -116,10 +118,9 @@ class TemplateContent {\n);\nreturn rendered;\n} catch (e) {\n- throw EleventyError.make(\n- new Error(\n- `Having trouble rendering template ${this.inputPath}: ${str}`\n- ),\n+ debug(`Having trouble rendering template ${this.inputPath}: %O`, str);\n+ throw new TemplateContentRenderError(\n+ `Having trouble rendering template ${this.inputPath}`,\ne\n);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplatePassthrough.js",
"new_path": "src/TemplatePassthrough.js",
"diff": "-const fs = require(\"fs-extra\");\n+const copy = require(\"recursive-copy\");\nconst TemplatePath = require(\"./TemplatePath\");\n// const debug = require(\"debug\")(\"Eleventy:TemplatePassthrough\");\n@@ -29,7 +29,12 @@ class TemplatePassthrough {\n// );\nif (!this.isDryRun) {\n- return fs.copy(this.path, this.getOutputPath());\n+ return copy(this.path, this.getOutputPath(), {\n+ overwrite: true,\n+ dot: true,\n+ junk: false,\n+ results: false\n+ });\n}\n}\n}\n"
},
{
"change_type": "DELETE",
"old_path": "test/EleventyErrorTest.js",
"new_path": null,
"diff": "-import test from \"ava\";\n-import EleventyError from \"../src/EleventyError\";\n-\n-test(\"Constructor\", t => {\n- let oldError = new Error();\n- let newError = new Error();\n- let ee = new EleventyError(newError, oldError);\n-\n- t.is(ee.errors.length, 2);\n-});\n-\n-test(\"Static Constructor\", t => {\n- let oldError = new Error();\n- let newError = new Error();\n- let ee = EleventyError.make(newError, oldError);\n-\n- t.is(ee.errors.length, 2);\n-});\n-\n-test(\"Static Constructor with already existing EleventyError\", t => {\n- let oldError = new Error();\n- let newError = new Error();\n- let ee1 = EleventyError.make(newError, oldError);\n-\n- let newError2 = new Error();\n- let ee2 = EleventyError.make(newError2, ee1);\n-\n- t.is(ee1.errors.length, 3);\n- t.is(ee2.errors.length, 3);\n-});\n-\n-test(\"getAll\", t => {\n- let oldError = new Error();\n- let newError = new Error();\n- let ee = EleventyError.make(newError, oldError);\n-\n- t.is(ee.getAll().length, 2);\n-});\n-\n-test(\"log\", t => {\n- let oldError = new Error();\n- let newError = new Error();\n- let ee = EleventyError.make(newError, oldError);\n-\n- t.truthy(ee.log());\n-});\n"
},
{
"change_type": "MODIFY",
"old_path": "test/EleventyFilesTest.js",
"new_path": "test/EleventyFilesTest.js",
"diff": "@@ -249,3 +249,9 @@ test(\"Glob Watcher Files with Config Passthroughs\", async t => {\n\"./test/stubs/**/*.11tydata.js\"\n]);\n});\n+\n+test(\"Glob Watcher Files with passthroughAll\", async t => {\n+ let tw = new EleventyFiles(\"test/stubs\", \"test/stubs/_site\", [], true);\n+\n+ t.is((await tw.getFileGlobs())[0], \"./test/stubs/**\");\n+});\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Fixes #205, adds test for passthroughall.
Fixes #208 by switching to `recursive-copy` instead of `fs-extra` |
699 | 12.09.2018 21:10:30 | 18,000 | 1b8ab3f271a66815ed6295b25647fb2bb52ea42f | A little refactor for | [
{
"change_type": "MODIFY",
"old_path": "cmd.js",
"new_path": "cmd.js",
"diff": "@@ -10,13 +10,15 @@ require(\"please-upgrade-node\")(pkg, {\n});\nif (process.env.DEBUG) {\n- require(\"time-require\");\n+ let timeRequire = require(\"time-require\");\n}\n+const EleventyErrorHandler = require(\"./src/EleventyErrorHandler\");\n+\n+try {\nconst argv = require(\"minimist\")(process.argv.slice(2));\nconst Eleventy = require(\"./src/Eleventy\");\nconst EleventyCommandCheck = require(\"./src/EleventyCommandCheck\");\n-const EleventyErrorHandler = require(\"./src/EleventyErrorHandler\");\nprocess.on(\"unhandledRejection\", (error, promise) => {\nEleventyErrorHandler.error(promise, \"Unhandled rejection in promise\");\n@@ -31,7 +33,6 @@ process.on(\"rejectionHandled\", promise => {\n);\n});\n-try {\nlet cmdCheck = new EleventyCommandCheck(argv);\ncmdCheck.hasUnknownArguments();\n@@ -66,5 +67,5 @@ try {\n})\n.catch(EleventyErrorHandler.fatal);\n} catch (e) {\n- EleventyErrorHandler.fatal(e);\n+ EleventyErrorHandler.fatal(e, \"Eleventy fatal error\");\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Config.js",
"new_path": "src/Config.js",
"diff": "-const chalk = require(\"chalk\");\nconst TemplateConfig = require(\"./TemplateConfig\");\n-const EleventyErrorHandler = require(\"./EleventyErrorHandler\");\nconst debug = require(\"debug\")(\"Eleventy:Config\");\ndebug(\"Setting up global TemplateConfig.\");\n-let config;\n-try {\n- config = new TemplateConfig();\n-} catch (e) {\n- console.log(\"\\n\" + chalk.red(\"Problem with Eleventy configuration: \"));\n-\n- EleventyErrorHandler.log(e);\n-}\n+let config = new TemplateConfig();\nmodule.exports = config;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/EleventyErrorHandler.js",
"new_path": "src/EleventyErrorHandler.js",
"diff": "@@ -3,7 +3,7 @@ const debug = require(\"debug\")(\"Eleventy:EleventyErrorHandler\");\nclass EleventyErrorHandler {\nstatic warn(e, msg) {\n- EleventyErrorHandler.message(msg, \"warn\", \"yellow\");\n+ EleventyErrorHandler.initialMessage(msg, \"warn\", \"yellow\");\nEleventyErrorHandler.log(e, \"warn\");\n}\n@@ -13,24 +13,42 @@ class EleventyErrorHandler {\n}\nstatic error(e, msg) {\n- EleventyErrorHandler.message(msg, \"error\", \"red\");\n+ EleventyErrorHandler.initialMessage(msg, \"error\", \"red\");\nEleventyErrorHandler.log(e, \"error\");\n}\n- static message(message, type = \"log\", chalkColor = \"blue\") {\n+ static log(e, type = \"log\", prefix = \">\") {\n+ let ref = e;\n+ while (ref) {\n+ EleventyErrorHandler.message(\n+ (process.env.DEBUG ? \"\" : `${prefix} `) +\n+ `${ref.message} (${ref.name})`,\n+ type\n+ );\n+ debug(`(${type} stack): %O`, ref.stack);\n+ ref = ref.originalError;\n+ }\n+ }\n+\n+ static initialMessage(message, type = \"log\", chalkColor = \"blue\") {\nif (message) {\n- console[type](\n- chalk[chalkColor](message + \": (full stack in DEBUG output)\")\n+ EleventyErrorHandler.message(\n+ message + \": (full stack in DEBUG output)\",\n+ type,\n+ chalkColor\n);\n}\n}\n- static log(e, type = \"log\", prefix = \">\") {\n- let ref = e;\n- while (ref) {\n- console[type](`${prefix} ${ref.message} (${ref.name})`);\n- debug(`(${type}): %O`, ref.stack);\n- ref = ref.originalError;\n+ static message(message, type = \"log\", chalkColor) {\n+ if (process.env.DEBUG) {\n+ debug(`(${type}): ${message}`);\n+ } else {\n+ if (chalkColor) {\n+ console[type](chalk[chalkColor](message));\n+ } else {\n+ console[type](message);\n+ }\n}\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateConfig.js",
"new_path": "src/TemplateConfig.js",
"diff": "-const chalk = require(\"chalk\");\nconst fs = require(\"fs-extra\");\nconst lodashMerge = require(\"lodash.merge\");\nconst TemplatePath = require(\"./TemplatePath\");\nconst EleventyBaseError = require(\"./EleventyBaseError\");\n-const EleventyErrorHandler = require(\"./EleventyErrorHandler\");\nconst eleventyConfig = require(\"./EleventyConfig\");\nconst debug = require(\"debug\")(\"Eleventy:TemplateConfig\");\n"
}
] | JavaScript | MIT License | 11ty/eleventy | A little refactor for #182 |
699 | 13.09.2018 08:31:40 | 18,000 | c207644d14e1b3eb65bd136afc4312fbcb2760f2 | Working implementation of `permalink: false` to fix | [
{
"change_type": "MODIFY",
"old_path": "src/Template.js",
"new_path": "src/Template.js",
"diff": "@@ -6,6 +6,7 @@ const { DateTime } = require(\"luxon\");\nconst TemplateContent = require(\"./TemplateContent\");\nconst TemplatePath = require(\"./TemplatePath\");\nconst TemplatePermalink = require(\"./TemplatePermalink\");\n+const TemplatePermalinkNoWrite = require(\"./TemplatePermalinkNoWrite\");\nconst TemplateLayout = require(\"./TemplateLayout\");\nconst TemplateFileSlug = require(\"./TemplateFileSlug\");\nconst Pagination = require(\"./Plugins/Pagination\");\n@@ -100,6 +101,8 @@ class Template extends TemplateContent {\n);\nreturn perm;\n+ } else if (permalink === false) {\n+ return new TemplatePermalinkNoWrite();\n}\nreturn TemplatePermalink.generate(\n@@ -124,8 +127,12 @@ class Template extends TemplateContent {\n// TODO check for conflicts, see if file already exists?\nasync getOutputPath(data) {\nlet uri = await this.getOutputLink(data);\n+ if (uri === false) {\n+ return false;\n+ } else if (\n+ (await this.getFrontMatterData())[this.config.keys.permalinkRoot]\n+ ) {\n// TODO this only works with immediate front matter and not data files\n- if ((await this.getFrontMatterData())[this.config.keys.permalinkRoot]) {\nreturn normalize(uri);\n} else {\nreturn normalize(this.outputDir + \"/\" + uri);\n@@ -136,10 +143,6 @@ class Template extends TemplateContent {\nthis.paginationData = paginationData;\n}\n- isIgnored() {\n- return this.outputDir === false;\n- }\n-\nasync mapDataAsRenderedTemplates(data, templateData) {\nif (Array.isArray(data)) {\nlet arr = [];\n@@ -417,22 +420,38 @@ class Template extends TemplateContent {\n}\nasync _write(outputPath, finalContent) {\n+ if (outputPath === false) {\n+ debug(\n+ \"Ignored %o from %o (permalink: false).\",\n+ outputPath,\n+ this.inputPath\n+ );\n+ return;\n+ }\n+\nthis.writeCount++;\n- let writeDesc = this.isDryRun ? \"Pretending to write\" : \"Writing\";\n+ let lang = {\n+ start: \"Writing\",\n+ finished: \"written.\"\n+ };\n+\n+ if (this.isDryRun) {\n+ lang = {\n+ start: \"Pretending to write\",\n+ finished: \"\" // not used\n+ };\n+ }\n+\nif (this.isVerbose) {\n- console.log(`${writeDesc} ${outputPath} from ${this.inputPath}.`);\n+ console.log(`${lang.start} ${outputPath} from ${this.inputPath}.`);\n} else {\n- debug(`${writeDesc} %o from %o.`, outputPath, this.inputPath);\n+ debug(`${lang.start} %o from %o.`, outputPath, this.inputPath);\n}\nif (!this.isDryRun) {\nreturn fs.outputFile(outputPath, finalContent).then(() => {\n- debug(\n- `${outputPath} ${\n- !this.isDryRun ? \"written\" : \"pretended to be written\"\n- }.`\n- );\n+ debug(`${outputPath} ${lang.finished}.`);\n});\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplatePermalink.js",
"new_path": "src/TemplatePermalink.js",
"diff": "const parsePath = require(\"parse-filepath\");\n-const normalize = require(\"normalize-path\");\nconst TemplatePath = require(\"./TemplatePath\");\nfunction TemplatePermalink(link, extraSubdir) {\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/TemplatePermalinkNoWrite.js",
"diff": "+class TemplatePermalinkNoWrite {\n+ toString() {\n+ return false;\n+ }\n+\n+ toHref() {\n+ return false;\n+ }\n+}\n+\n+module.exports = TemplatePermalinkNoWrite;\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/TemplatePermalinkNoWriteTest.js",
"diff": "+import test from \"ava\";\n+import TemplatePermalinkNoWrite from \"../src/TemplatePermalinkNoWrite\";\n+\n+test(\"Test standard method signature\", t => {\n+ let perm = new TemplatePermalinkNoWrite();\n+ t.is(perm.toHref(), false);\n+ t.is(perm.toString(), false);\n+});\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateTest.js",
"new_path": "test/TemplateTest.js",
"diff": "import test from \"ava\";\n+import fs from \"fs-extra\";\nimport TemplateData from \"../src/TemplateData\";\nimport Template from \"../src/Template\";\nimport pretty from \"pretty\";\n@@ -1114,3 +1115,29 @@ test(\"Test a linter\", async t => {\nt.pass(\"Threw an error:\" + e);\n}\n});\n+\n+test(\"permalink: false\", async t => {\n+ let tmpl = new Template(\n+ \"./test/stubs/permalink-false/test.md\",\n+ \"./test/stubs/\",\n+ \"./test/stubs/_site\"\n+ );\n+\n+ t.is(await tmpl.getOutputLink(), false);\n+ t.is(await tmpl.getOutputHref(), false);\n+\n+ let data = await tmpl.getData();\n+ await tmpl.write(false, data);\n+\n+ // Input file exists (sanity check for paths)\n+ t.is(fs.existsSync(\"./test/stubs/permalink-false/\"), true);\n+ t.is(fs.existsSync(\"./test/stubs/permalink-false/test.md\"), true);\n+\n+ // Output does not exist\n+ t.is(fs.existsSync(\"./test/stubs/_site/permalink-false/\"), false);\n+ t.is(fs.existsSync(\"./test/stubs/_site/permalink-false/test/\"), false);\n+ t.is(\n+ fs.existsSync(\"./test/stubs/_site/permalink-false/test/index.html\"),\n+ false\n+ );\n+});\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Working implementation of `permalink: false` to fix #61 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.