Loading lib/patternlibrary.js +36 −36 Original line number Diff line number Diff line Loading @@ -97,7 +97,8 @@ class Patternlibrary { * Retrieves (handlebars) page template * * if no page template is set yet, returns the default * gui doc-page template * gui doc-page templateto be used in a series of similar * pages with iterating data * * it retrieves a compiled Handlebars template and * returns the rendred page content when invoked Loading @@ -118,6 +119,8 @@ class Patternlibrary { /** * Sets and compiles (handlebars) page by page filename * for a *Patternlibrary* page template to be used in a * series of similar pages with iterating data * * if `page` is a '.md' or '.markdown' file, it is also * passed through the markdown renderer Loading @@ -128,6 +131,14 @@ class Patternlibrary { * var rendered = P.pagetemplate(pagevars); * ``` * * if the parameter does not correspond to a readable file * the parameter's string value is assigned as page template * * look-up order: * - project's doc pages dir (pages src dir + basepath) * - project's `gui` pages dir * - module's `gui` pages dir * - file path * * @param {string} page - the file basename of the page-file * @var {function} pagetemplate - a precompiled (handlebars) template Loading @@ -142,7 +153,6 @@ class Patternlibrary { var pagefile = path.join(this.options.root, this.options.basepath, page); var guipage = resolvePath(path.join(this.options.gui.pages, this.options.basepath, page)); try { if ( !fs.existsSync(pagefile) ) { if ( fs.existsSync(guipage) ) { // file from gui pages Loading @@ -157,16 +167,10 @@ class Patternlibrary { // file from pages pageSource = fs.readFileSync(pagefile).toString(); } } catch (e) { this.log.warn('Error loading Patternlibrary pagefile "'+pagefile+'"'); throw new Error(e.message); } } // strip yml data in the beginning pageSource = fm(pageSource).body; try { // finally compile Markdown content, if we have a markdown file here... if (markdown) { Loading @@ -175,14 +179,10 @@ class Patternlibrary { // and renders some special characters useless for to be interpreted by // Handlebars, like `{{> ...`, so we wrap it with Handlebars and let its // MarkdownIt helper there do it... pageSource = '{{#md}}'+pageSource+'{{/md}}'; pageSource = '{{#markdown}}'+pageSource+'{{/markdown}}'; } } catch (e) { this.log.warn('Error rendering Markdown content'); throw new Error(e.message); } this._pageTemplate = this.handlebars.compile(pageSource, {noEscape: true}); } Loading test/fixtures.core/basic/layouts/default.html→test/fixtures.templating/layout/layouts/default.html +0 −0 File moved. View file test/fixtures.core/basic/layouts/mylayout.html→test/fixtures.templating/layout/layouts/mylayout.html +0 −0 File moved. View file test/fixtures.core/basic/pages/mypage.html→test/fixtures.templating/layout/pages/mypage.html +0 −0 File moved. View file test/fixtures.core/basic/partials/.gitkeep→test/fixtures.templating/layout/partials/.gitkeep +0 −0 File moved. Loading
lib/patternlibrary.js +36 −36 Original line number Diff line number Diff line Loading @@ -97,7 +97,8 @@ class Patternlibrary { * Retrieves (handlebars) page template * * if no page template is set yet, returns the default * gui doc-page template * gui doc-page templateto be used in a series of similar * pages with iterating data * * it retrieves a compiled Handlebars template and * returns the rendred page content when invoked Loading @@ -118,6 +119,8 @@ class Patternlibrary { /** * Sets and compiles (handlebars) page by page filename * for a *Patternlibrary* page template to be used in a * series of similar pages with iterating data * * if `page` is a '.md' or '.markdown' file, it is also * passed through the markdown renderer Loading @@ -128,6 +131,14 @@ class Patternlibrary { * var rendered = P.pagetemplate(pagevars); * ``` * * if the parameter does not correspond to a readable file * the parameter's string value is assigned as page template * * look-up order: * - project's doc pages dir (pages src dir + basepath) * - project's `gui` pages dir * - module's `gui` pages dir * - file path * * @param {string} page - the file basename of the page-file * @var {function} pagetemplate - a precompiled (handlebars) template Loading @@ -142,7 +153,6 @@ class Patternlibrary { var pagefile = path.join(this.options.root, this.options.basepath, page); var guipage = resolvePath(path.join(this.options.gui.pages, this.options.basepath, page)); try { if ( !fs.existsSync(pagefile) ) { if ( fs.existsSync(guipage) ) { // file from gui pages Loading @@ -157,16 +167,10 @@ class Patternlibrary { // file from pages pageSource = fs.readFileSync(pagefile).toString(); } } catch (e) { this.log.warn('Error loading Patternlibrary pagefile "'+pagefile+'"'); throw new Error(e.message); } } // strip yml data in the beginning pageSource = fm(pageSource).body; try { // finally compile Markdown content, if we have a markdown file here... if (markdown) { Loading @@ -175,14 +179,10 @@ class Patternlibrary { // and renders some special characters useless for to be interpreted by // Handlebars, like `{{> ...`, so we wrap it with Handlebars and let its // MarkdownIt helper there do it... pageSource = '{{#md}}'+pageSource+'{{/md}}'; pageSource = '{{#markdown}}'+pageSource+'{{/markdown}}'; } } catch (e) { this.log.warn('Error rendering Markdown content'); throw new Error(e.message); } this._pageTemplate = this.handlebars.compile(pageSource, {noEscape: true}); } Loading
test/fixtures.core/basic/layouts/default.html→test/fixtures.templating/layout/layouts/default.html +0 −0 File moved. View file
test/fixtures.core/basic/layouts/mylayout.html→test/fixtures.templating/layout/layouts/mylayout.html +0 −0 File moved. View file
test/fixtures.core/basic/pages/mypage.html→test/fixtures.templating/layout/pages/mypage.html +0 −0 File moved. View file
test/fixtures.core/basic/partials/.gitkeep→test/fixtures.templating/layout/partials/.gitkeep +0 −0 File moved.