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.

109 lines (105 loc) 4.07 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Table of Contents</title> <link rel="stylesheet" href="http://getbootstrap.com/dist/css/bootstrap.min.css"> </head> <body> <div class="container bs-docs-container"> <h1>Table of Contents</h1> <!-- post --> <p> <a class="anchor" href="#something-random-chapter-1"></a> <h2 class="blog-title">My Brilliant Blog</h2> <h3 class="post-title" id="something-random-chapter-1">Post title: My Amazing Book</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: toc.html</span> <span class="pagename">pagename: toc.html</span> <span class="basename">basename: toc</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> <ul class="tags"> <li>a</li> <li>b</li> <li>c</li> </ul> <!-- chapter --> <a class="anchor" href="#middle-file-chapter-3"></a> <h2 class="blog-title">My Brilliant Blog</h2> <h3 class="post-title" id="middle-file-chapter-3">Post title: My Amazing Book</h3> <p class="post-content"> <h1>Content from My Amazing Book</h1> <p class="intro">Chapter 3</p> <p class="chapter">Chapter: 3</p> </p> <div class="root-context"> <span class="filename">filename: toc.html</span> <span class="pagename">pagename: toc.html</span> <span class="basename">basename: toc</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> <ul class="tags"> <li>d</li> <li>e</li> <li>f</li> </ul> <!-- chapter --> <a class="anchor" href="#before-another-chapter-2"></a> <h2 class="blog-title">My Brilliant Blog</h2> <h3 class="post-title" id="before-another-chapter-2">Post title: My Amazing Book</h3> <p class="post-content"> <h1>Content from My Amazing Book</h1> <p class="intro">Chapter 2</p> <p class="chapter">Chapter: 2</p> </p> <div class="root-context"> <span class="filename">filename: toc.html</span> <span class="pagename">pagename: toc.html</span> <span class="basename">basename: toc</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> <ul class="tags"> <li>a</li> <li>e</li> <li>c</li> </ul> </div> </body> </html>