-
Notifications
You must be signed in to change notification settings - Fork 2
Variable
Jacob Chirayil edited this page Feb 13, 2019
·
2 revisions
Variable Support
Advantage - variables declared as part of yaml and can be referenced multiple time within the document.
file: file1.md
---
title: File1
user1: John Smith
user2: Jane Smith
---
File with variable.
The two authorized users are {#var user1} and {#var user2}. The primary user - {#var user1} - can enable/disable the account of {#var user2}.
output: file1.html
<p>File with variable.</p>
<p>The two authorized users are John Smith and Jane Smith. The primary user - John Smith - can enable/disable the account of Jane Smith.</p>
Advantage - variables can be shared between multiple files
config setting
...
var varreplace = require('metalsmith-var-replace');
...
.use(varreplace({
actions:[{
type:'var',
varValues: {
'adminuser':'John Smith',
'fruit':'apple'
}
}]
})
...
file: file1.md
---
title: File1
---
File with variable (values defined about config level).
The name of the administrator is {#var adminuser} and his/her favorite fruit is {#var user2}.
output: file1.html
<p>File with variable (values defined about config level).</p>
<p>The name of the administrator is John Smith and his/her favorite fruit is apple.</p>