From fbaad21413e813352e979d677f6643af1f5d5774 Mon Sep 17 00:00:00 2001
From: Dem Pilafian
Date: Tue, 28 Mar 2017 14:26:11 -0700
Subject: [PATCH 1/3] Create built-in webRoot variable
Provides a way to create relative URLs in a template.
Example usage:
Note:
Value is safely set (will not override value if already set in
"context" option)
---
lib/index.js | 3 +++
1 file changed, 3 insertions(+)
diff --git a/lib/index.js b/lib/index.js
index b2fb1d1..c198280 100644
--- a/lib/index.js
+++ b/lib/index.js
@@ -66,6 +66,9 @@ module.exports = function(opts) {
var filebase = opts.basepath === '@file' ? path.dirname(file.path) : opts.basepath;
var currentFilename = path.resolve(file.base, file.path);
+ // built-in webRoot variable, example usage:
+ opts.context.webRoot = opts.context.webRoot || path.relative(currentFilename, file.base);
+
data = extend(true, {}, opts.context, data || {});
data.content = text;
From 6c8de10e07ec210d54625504c18fdd1c4ac70349 Mon Sep 17 00:00:00 2001
From: Dem Pilafian
Date: Thu, 30 Mar 2017 22:18:57 -0700
Subject: [PATCH 2/3] Instructions for webRoot feature
---
Readme.md | 39 +++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/Readme.md b/Readme.md
index 91cbe8f..a6b9faa 100644
--- a/Readme.md
+++ b/Readme.md
@@ -227,6 +227,45 @@ data.json
+
Support Contact Info
+
+
```
+### `webRoot` built-in context variable
+
+The `webRoot` field of the context contains the relative path from the source document to
+the source root (unless the value is already set in the context options).
+
+### example
+
+support/contact/index.html
+
+```html
+
+
+