Skip to content

Commit

Permalink
Superfluous debug statements for 11ty#44. Adds "commonmark" markdown …
Browse files Browse the repository at this point in the history
…standards.
  • Loading branch information
zachleat committed Jan 23, 2018
1 parent 46c4c55 commit ddb8d0d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 21 deletions.
11 changes: 6 additions & 5 deletions src/Engines/Markdown.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const mdlib = require("markdown-it")({
html: true
});
const mdlib = require("markdown-it")("commonmark");
const TemplateEngine = require("./TemplateEngine");
const debug = require("debug")("Eleventy:Markdown");

class Markdown extends TemplateEngine {
async compile(str, preTemplateEngine, bypassMarkdown) {
Expand All @@ -18,11 +17,13 @@ class Markdown extends TemplateEngine {
};
} else {
return async function(data) {
return mdlib.render(await fn(data));
let preTemplateEngineRender = await fn(data);
let finishedRender = mdlib.render(preTemplateEngineRender);
return finishedRender;
};
}
} else {
return function(data) {
return function() {
// throw away data if preTemplateEngine is falsy
return mdlib.render(str);
};
Expand Down
33 changes: 17 additions & 16 deletions src/Template.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class Template {
let permalink = this.getFrontMatterData()[this.config.keys.permalink];
if (permalink) {
let data = await this.getData();
debug("Rendering permalink for %o", this.inputPath);
// debug("Rendering permalink for %o", this.inputPath);
let perm = new TemplatePermalink(
// render variables inside permalink front matter
await this.renderContent(permalink, data, {
Expand Down Expand Up @@ -138,11 +138,11 @@ class Template {

getLayoutTemplate(layoutPath) {
let path = new TemplateLayout(layoutPath, this.layoutsDir).getFullPath();
debug(
"creating new Template %o in getLayoutTemplate for %o",
path,
this.inputPath
);
// debug(
// "creating new Template %o in getLayoutTemplate for %o",
// path,
// this.inputPath
// );
return new Template(path, this.inputDir, this.outputDir);
}

Expand Down Expand Up @@ -190,7 +190,7 @@ class Template {
}
return obj;
} else if (typeof data === "string") {
debug("rendering renderData variables for %o", this.inputPath);
debug("rendering data.renderData for %o", this.inputPath);
let str = await this.renderContent(data, templateData, {
bypassMarkdown: true
});
Expand Down Expand Up @@ -247,13 +247,13 @@ class Template {
}

async renderLayout(tmpl, tmplData, forcedLayoutPath) {
debug(`${tmpl.inputPath} renderLayout()`);
// debug(`${tmpl.inputPath} renderLayout()`);
let layoutPath = forcedLayoutPath || tmplData[tmpl.config.keys.layout];
// debug("Template %o is using layout: %o", this.inputPath, layoutPath);

if (!this.initialLayout) {
this.initialLayout = tmplData[tmpl.config.keys.layout];
debug("Saved layout: %o for %o", this.initialLayout, this.inputPath);
// debug("Saved layout: %o for %o", this.initialLayout, this.inputPath);
}
// TODO make layout key to be available to templates (without it causing issues with merge below)
delete tmplData[tmpl.config.keys.layout];
Expand All @@ -262,9 +262,9 @@ class Template {
let layoutData = await layout.getData(tmplData);
// debug("layoutData: %O", layoutData)
// debug("tmplData (passed to layoutContent = renderContent(): %O", tmplData);
debug("renderLayout -> renderContent(%o)", tmpl.getPreRender());
// debug("renderLayout -> renderContent(%o)", tmpl.getPreRender());
let layoutContent = await tmpl.renderContent(tmpl.getPreRender(), tmplData);
debug("renderLayout -> layoutContent %o", layoutContent);
// debug("renderLayout -> layoutContent %o", layoutContent);
layoutData.content = layoutContent;
layoutData.layoutContent = layoutContent;
// Deprecated
Expand All @@ -291,9 +291,10 @@ class Template {
this.templateRender.engineName
}`
);
if (data.layoutContent) {
debug("renderContent -> layoutContent %o", data.layoutContent);
}

// if (data.layoutContent) {
// debug("renderContent -> layoutContent %o", data.layoutContent);
// }
let fn = await this.templateRender.getCompiledTemplate(str, options);
return fn(data);
}
Expand All @@ -306,7 +307,7 @@ class Template {
}

async render(data) {
debug(`${this.inputPath} render()`);
// debug(`${this.inputPath} render()`);
if (!data) {
data = await this.getRenderedData();
}
Expand All @@ -324,7 +325,7 @@ class Template {
) {
return this.renderLayout(this, data, this.initialLayout);
} else {
debug("Template.render renderContent for %o", this.inputPath);
// debug("Template.render renderContent for %o", this.inputPath);
return this.renderContent(this.getPreRender(), data);
}
}
Expand Down

0 comments on commit ddb8d0d

Please sign in to comment.