gray-matter
Advanced tools
Comparing version 0.2.3 to 0.2.4
{ | ||
"name": "matter", | ||
"version": "0.2.3", | ||
"name": "gray-matter", | ||
"version": "0.2.4", | ||
"main": [ | ||
@@ -5,0 +5,0 @@ "index.js" |
12
index.js
@@ -10,2 +10,3 @@ /** | ||
// node_modules | ||
var YAML = require('js-yaml'); | ||
var delims = require('delims'); | ||
@@ -64,2 +65,13 @@ var file = require('fs-utils'); | ||
// Stringify to jSON | ||
matter.stringifyJSON = function(src, options) { | ||
return matter(src, options).context; | ||
}; | ||
// Stringify to YAML | ||
matter.stringifyYAML = function(src, options) { | ||
var front = matter(src, options).context; | ||
return YAML.dump(front); | ||
}; | ||
module.exports = matter; |
{ | ||
"name": "gray-matter", | ||
"description": "A simple to use YAML, JSON or Coffee Front-Matter parsing and extraction library, with options to set custom delimiters.", | ||
"version": "0.2.3", | ||
"version": "0.2.4", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "Jon Schlinkert", |
@@ -85,2 +85,19 @@ /** | ||
describe('Stringify YAML:', function () { | ||
it('should stringify JSON.', function (done) { | ||
var fixture = file.readFileSync('./test/fixtures/alpha.hbs'); | ||
var actual = matter.stringifyJSON(fixture); | ||
expect(actual).to.deep.equal({foo: 'bar', version: 2}); | ||
done(); | ||
}); | ||
it('should stringify YAML.', function (done) { | ||
var fixture = file.readFileSync('./test/fixtures/alpha.hbs'); | ||
var actual = matter.stringifyYAML(fixture); | ||
expect(actual).to.deep.equal('foo: bar\nversion: 2\n'); | ||
done(); | ||
}); | ||
}); | ||
describe('Read from file system:', function () { | ||
@@ -87,0 +104,0 @@ it('should extract YAML front matter from files with content.', function (done) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
49114
543