Home

Awesome

snippet NPM version

CLI and API for easily creating, reusing, sharing and generating snippets of code from the command line.

More to come!

Install

Install with npm

$ npm i snippet --save

Usage

var snippet = require('snippet');

Emmet

(WIP! This is just one feature of Snippet! A lot more is on the way!)

Expand emmet snippets

snippets.expand('ul>li.item$*3');

Results in:

<ul>
  <li class="item1"><%= param0 %></li>
  <li class="item2"><%= param1 %></li>
  <li class="item3"><%= param2 %></li>
</ul>

Expand emmet snippets with custom placehoders

snippets.expand('ul>li.item$*3', ['a', 'b', 'c']);

Results in:

<ul>
  <li class="item1"><%= a %></li>
  <li class="item2"><%= b %></li>
  <li class="item3"><%= c %></li>
</ul>

API

Snippets

Create an instance of Snippets with the given options.

Params

Example

var Snippets = require('snippets');
var snippets = new Snippets();

.set

Cache a snippet or arbitrary value in memory.

Params

.addSnippet

Cache a snippet in memory. Creates a Snippet instance with the given value.

Params

.addSnippets

Create a new Snippet() from a snippet object, or array of snippet objects.

Params

.save

Persist a snippet or arbitrary value to disk.

Params

.get

Get a snippet or arbitrary value by name. Cached, local, or remote.

Params

.del

Delete snippet name from memory and/or snippet-store. This will not delete actual snippet files saved on disk, only cached snippets.

Params

.load

Load a glob of snippets.

Params

.read

Read a snippet from the file system. If the snippet is already in memory and is an instance of Snippet, the .read() method is called on the snippet. Otherwise, a new Snippet() is created first before calling the .read() method on the snippet.

Params

.preset

Set a preset config for downloading snippets from a remote URL.

Params

.queue

Queue a remote snippet to be downloaded from the given URL, and optional preset.

Params

.fetch

Fetch a remote snippet from the given URL.

Params

.expand

Expand a snippet of code or data.

Params

Running tests

Install dev dependencies:

$ npm i -d && npm test

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue

Author

Jon Schlinkert

License

Copyright © 2015 Jon Schlinkert Released under the MIT license.


This file was generated by verb-cli on August 13, 2015.