Coder Social home page Coder Social logo

assemble-front-matter's Introduction

assemble-front-matter NPM version Build Status

Utilities for extracting front matter from source files.

Visit Assemble's documentation for many more examples and pointers on getting started.

Getting Started

npm install assemble-front-matter --save

and use it as follows:

var yfm = require('assemble-front-matter');

Methods

extract

Extract YAML front matter and content from files.

var raw = yfm.extract("./file.hbs", opts);

Parameters:

  • String: The file to read.
  • Object: The options object to pass to js-yaml

Returns:

Object with three properties

{
 "context": {}         // Object. YAML front matter returned as a JSON object.
 "content": ""         // String. File content, stripped of YAML front matter
 "originalContent": "" // String. Both content and YAML front matter.
}

context

Return YAML front matter as a JSON object.

var data = yfm.extract("./file.hbs").context;

Alias:

var data = yfm.extractJSON("./file.hbs");

content

Return the content of a file, with YAML front matter removed.

var content = yfm.extract("./file.hbs").content;

Alias:

var data = yfm.stripYFM("./file.hbs");

Release History

  • 2013-09-22   v0.1.2   Adds grunt-readme and grunt-pkg-sync
  • 2013-09-02   v0.1.1   Updates tests and example files
  • 2013-08-11   v0.1.0   Initial setup

Author

License

Copyright (c) 2013 Brian Woodward, contributors. Released under the MIT license


This file was generated on Mon Sep 02 2013 09:44:51.

assemble-front-matter's People

Contributors

doowb avatar jonschlinkert avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

doowb

assemble-front-matter's Issues

Should we use repos or internal modules for different languages?

@jonschlinkert When I created this repo and the assemble-yaml repo, my initial thoughts were to have a repo to handle the specifics for each type of language we'll support for frontmatter (yaml, coffeescript, etc...).

Right now, the parsing of the header from the body is done in the assemble-yaml repo, but I think it should be moved to this repo so we can auto-detect the language if needed...

---coffee

---

Then select the correct library to handle parsing the actual front-matter.

When thinking of this, it occurred to me that the assemble-'lang' repos would just be wrappers around other libraries like js-yaml. So instead of having the other libraries, do you think it would be better to just include everything in this repo?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.