CLI and API for easily creating, reusing, sharing and generating snippets of code from the command line.
- CLI
- API (75% done)
- expand emmet snippets
- expand emmet snippets in the command line.
- set, get, and delete snippets of code or data that can easily be reused in any project
- fetch snippets from github or other remotes using
presets
- render snippets using data from
json
oryaml
files, or using expand-object - inject snippets into other files using customizable markers
- prepend files/strings with snippets
- append files/strings with snippets
- Add expanded snippets to the clipboard so you can paste them wherever you want!
More to come!
Install with npm
$ npm i snippet --save
var snippet = require('snippet');
(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>
Create an instance of Snippets
with the given options.
Params
options
{Object}
Example
var Snippets = require('snippets');
var snippets = new Snippets();
Cache a snippet or arbitrary value in memory.
Params
name
{String}: The snippet nameval
{any}returns
{Object}: Returns theSnippet
instance for chaining
Cache a snippet in memory. Creates a Snippet
instance
with the given value
.
Params
name
{String}: The snippet nameval
{any}returns
{Object}: Returns theSnippet
instance for chaining
Create a new Snippet()
from a snippet object,
or array of snippet objects.
Params
snippets
{Object|Array}
Persist a snippet or arbitrary value to disk.
Params
name
{String}val
{any}returns
{Object}: Returns theSnippet
instance for chaining
Get a snippet or arbitrary value by name
. Cached,
local, or remote.
Params
name
{String}preset
{Object}: Preset to use if a URL is passed.returns
{Object}: Returns the requested snippet.
Delete snippet name
from memory and/or snippet-store.
This will not delete actual snippet files saved on disk, only
cached snippets.
Params
name
{String}: The name of the snippet to deletereturns
{Object}Snippets
: instance, for chaining
Load a glob of snippets.
Params
- {String|Array}: `snippets
options
{Object}returns
{Object}Snippets
: for chaining
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
- {Object|String}: snippet
returns
{Object}
Set a preset config
for downloading snippets from a remote URL.
Params
name
{String}config
{Object}returns
{Object}
Queue a remote snippet to be downloaded from the given URL, and
optional preset
.
Params
url
{String}preset
{Object}: The namereturns
{Object}: Returns a snippet object.
Fetch a remote snippet from the given URL.
Params
url
{String}preset
{Object}returns
{Object}: Returns a snippet object.
Expand a snippet of code or data.
Params
str
{String}- {Object}: `data
Install dev dependencies:
$ npm i -d && npm test
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue
Jon Schlinkert
Copyright © 2015 Jon Schlinkert Released under the MIT license.
This file was generated by verb-cli on August 13, 2015.