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.
132 lines (128 loc) • 5.6 kB
HTML
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Custom sep hash</title>
<link rel="stylesheet" href="http://getbootstrap.com/dist/css/bootstrap.min.css">
</head>
<body>
<div class="container bs-docs-container">
<p>Here we are passing any explicit context, <code>blog</code>, to the helper.</p>
<!-- sep -->
<!-- test/fixtures/book/before-another-chapter-2.md -->
<p class="title">My Brilliant Blog</p>
<p class="description">Custom separator defined in the options hash.</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 Brilliant Blog</h1>
</p>
<p class="intro">Chapter 2</p>
<p class="chapter">Chapter: 2</p>
</p>
<div class="root-context">
<span class="filename">filename: context-explicit.html</span>
<span class="pagename">pagename: context-explicit.html</span>
<span class="basename">basename: context-explicit</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 Brilliant Blog</p>
<p class="description">Custom separator defined in the options hash.</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 Brilliant Blog</h1>
</p>
<p class="intro">Chapter 3</p>
<p class="chapter">Chapter: 3</p>
</p>
<div class="root-context">
<span class="filename">filename: context-explicit.html</span>
<span class="pagename">pagename: context-explicit.html</span>
<span class="basename">basename: context-explicit</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 Brilliant Blog</p>
<p class="description">Custom separator defined in the options hash.</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 Brilliant Blog</h1>
</p>
<p class="intro">Chapter 1</p>
<p class="chapter">Chapter: 1</p>
</p>
<div class="root-context">
<span class="filename">filename: context-explicit.html</span>
<span class="pagename">pagename: context-explicit.html</span>
<span class="basename">basename: context-explicit</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><li class="link">a</li>
<li class="link">b</li>
<li class="link">c</li></code></pre>
<p>
</ul>
</p>
</div>
</body>
</html>