UNPKG

handlebars-helper-compose

Version:

{{compose}} handlebars helper. Inlines content from multiple files optionally using wildcard (globbing/minimatch) patterns, extracts YAML front matter to pass to context for each file. Accepts compare function as 3rd parameter for sorting inlined files. Good for blog posts, chapters, etc.

133 lines (129 loc) 5.88 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title></title> <link rel="stylesheet" href="http://getbootstrap.com/dist/css/bootstrap.min.css"> </head> <body> <div class="container bs-docs-container"> <p>Context for <code>description</code> should be from an external data file matching this page: <code>context-page-data-file.yml</code>. The <code>title</code> will come from context of the inlined files. This is because the inlined files don&#39;t have a <code>description</code> field, but they do have a <code>title</code> field.</p> <!-- sep --> <!-- test/fixtures/book/before-another-chapter-2.md --> <p class="title">My Amazing Book</p> <p class="description">description from CONTEXT-PAGE-DATA-FILE.yml</p> <p> <a class="anchor" href="#before-another-chapter-2"></a> <h2 class="blog-title">My Brilliant Blog</h2> <h3 class="post-title" id="My Amazing Book">My Amazing Book</h3> <h3 class="post-slug" id="before-another-chapter-2">before-another-chapter-2</h3> <p class="post-content"> <h1>Content from My Amazing Book</h1> </p> <p class="intro">Chapter 2</p> <p class="chapter">Chapter: 2</p> </p> <div class="root-context"> <span class="filename">filename: context-page-data-file.html</span> <span class="pagename">pagename: context-page-data-file.html</span> <span class="basename">basename: context-page-data-file</span> <span class="ext">ext: .html</span> </div> <div class="data-object"> <span class="id">id: before-another-chapter-2</span> <span class="filepath">filepath: test/fixtures/book/before-another-chapter-2.md</span> <span class="index">index: 1</span> <span class="number">number: 2</span> <span class="first">first:</span> <span class="prev">prev: 0</span> <span class="next">next: 2</span> <span class="last">last:</span> </div> <p class="origin">Content from test/fixtures/book/before-another-chapter-2.md.</p> <ul class="tags"> <li class="link">a</li> <li class="link">e</li> <li class="link">c</li> </ul> <!-- sep --> <!-- test/fixtures/book/middle-file-chapter-3.md --> <p class="title">My Amazing Book</p> <p class="description">description from CONTEXT-PAGE-DATA-FILE.yml</p> <p> <a class="anchor" href="#middle-file-chapter-3"></a> <h2 class="blog-title">My Brilliant Blog</h2> <h3 class="post-title" id="My Amazing Book">My Amazing Book</h3> <h3 class="post-slug" id="middle-file-chapter-3">middle-file-chapter-3</h3> <p class="post-content"> <h1>Content from My Amazing Book</h1> </p> <p class="intro">Chapter 3</p> <p class="chapter">Chapter: 3</p> </p> <div class="root-context"> <span class="filename">filename: context-page-data-file.html</span> <span class="pagename">pagename: context-page-data-file.html</span> <span class="basename">basename: context-page-data-file</span> <span class="ext">ext: .html</span> </div> <div class="data-object"> <span class="id">id: middle-file-chapter-3</span> <span class="filepath">filepath: test/fixtures/book/middle-file-chapter-3.md</span> <span class="index">index: 2</span> <span class="number">number: 3</span> <span class="first">first:</span> <span class="prev">prev: 1</span> <span class="next">next: 3</span> <span class="last">last: true</span> </div> <p class="origin">Content from test/fixtures/book/middle-file-chapter-3.md.</p> <ul class="tags"> <li class="link">d</li> <li class="link">e</li> <li class="link">f</li> </ul> <!-- sep --> <!-- test/fixtures/book/something-random-chapter-1.md --> <p class="title">My Amazing Book</p> <p class="description">description from CONTEXT-PAGE-DATA-FILE.yml</p> <p> <a class="anchor" href="#something-random-chapter-1"></a> <h2 class="blog-title">My Brilliant Blog</h2> <h3 class="post-title" id="My Amazing Book">My Amazing Book</h3> <h3 class="post-slug" id="something-random-chapter-1">something-random-chapter-1</h3> <p class="post-content"> <h1>Content from My Amazing Book</h1> </p> <p class="intro">Chapter 1</p> <p class="chapter">Chapter: 1</p> </p> <div class="root-context"> <span class="filename">filename: context-page-data-file.html</span> <span class="pagename">pagename: context-page-data-file.html</span> <span class="basename">basename: context-page-data-file</span> <span class="ext">ext: .html</span> </div> <div class="data-object"> <span class="id">id: something-random-chapter-1</span> <span class="filepath">filepath: test/fixtures/book/something-random-chapter-1.md</span> <span class="index">index: 3</span> <span class="number">number: 4</span> <span class="first">first:</span> <span class="prev">prev: 2</span> <span class="next">next: 4</span> <span class="last">last:</span> </div> <p> <p class="origin">Content from test/fixtures/book/something-random-chapter-1.md.</p> <ul class="tags"> </p> <pre><code>&lt;li class=&quot;link&quot;&gt;a&lt;/li&gt; &lt;li class=&quot;link&quot;&gt;b&lt;/li&gt; &lt;li class=&quot;link&quot;&gt;c&lt;/li&gt;</code></pre> <p> </ul> </p> </div> </body> </html>