lib/snippet.js
function (val, opts) {
    if (typeof val === 'function') {
      return new Snippet(val(this));
    }
    if (typeof val === 'string') {
      var str = utils.tryRead(val);
      var res = {content: null, options: opts || {}};
      if (str) {
        res.path = val;
        res.content = str.toString();
      } else {
        res.content = val;
      }
      return new Snippet(res);
    }
    if (val instanceof Snippet) {
      val.option(opts);
      return val;
    }
    if (typeof val === 'object') {
      val.options = extend({}, val.options, opts);
      return new Snippet(val);
    }
  }
function (val, opts) {
    if (typeof val === 'function') {
      return new Snippet(val(this));
    }
    if (typeof val === 'string') {
      var str = utils.tryRead(val);
      var res = {content: null, options: opts || {}};
      if (str) {
        res.path = val;
        res.content = str.toString();
      } else {
        res.content = val;
      }
      return new Snippet(res);
    }
    if (val instanceof Snippet) {
      val.option(opts);
      return val;
    }
    if (typeof val === 'object') {
      val.options = extend({}, val.options, opts);
      return new Snippet(val);
    }
  }
function ( val , opts ) { if ( typeof val === 'function' ) { return new Snippet ( val ( this ) ) ; } if ( typeof val === 'string' ) { var str = utils . tryRead ( val ) ; var res = { content : null , options : opts || { } } ; if ( str ) { res . path = val ; res . content = str . toString ( ) ; } else { res . content = val ; } return new Snippet ( res ) ; } if ( val instanceof Snippet ) { val . option ( opts ) ; return val ; } if ( typeof val === 'object' ) { val . options = extend ( { } , val . options , opts ) ; return new Snippet ( val ) ; } }
Attempts to return a snippet object from the given `value`.

@name .toSnippet
@param  {String|Object} `val` Can be a filepath, content string, object or instance of `Snippet`.
@param  {Object} `opts`
@api public
Attempts to return a snippet object from the given value .