lib/render.js
function render(content) {
  var deferred = q.defer();

  var blockType = "normal";
  var lines = content.split("\n");
  var blocks = {};
  for (var i=0; i<lines.length; i++) {
    var line = lines[i];

    if (line.substr(0,1) == "@") {
      blockType = line.substr(1).trim();
      if (blockType === "end") blockType = "normal";
      continue;
    }
    if (blocks[blockType])
      blocks[blockType] += line + "\n";
    else
      blocks[blockType] = line + "\n";
  }

  for (var key in blocks) {
    if (blocks.hasOwnProperty(key)) {
      try {
        blocks[key] = metaMarked(blocks[key]);
      } catch(err) {
        return deferred.reject(new Error(err));
      }
    }
    deferred.resolve(blocks);
  }

  return deferred.promise;
}
function render(content) {
  var deferred = q.defer();

  var blockType = "normal";
  var lines = content.split("\n");
  var blocks = {};
  for (var i=0; i<lines.length; i++) {
    var line = lines[i];

    if (line.substr(0,1) == "@") {
      blockType = line.substr(1).trim();
      if (blockType === "end") blockType = "normal";
      continue;
    }
    if (blocks[blockType])
      blocks[blockType] += line + "\n";
    else
      blocks[blockType] = line + "\n";
  }

  for (var key in blocks) {
    if (blocks.hasOwnProperty(key)) {
      try {
        blocks[key] = metaMarked(blocks[key]);
      } catch(err) {
        return deferred.reject(new Error(err));
      }
    }
    deferred.resolve(blocks);
  }

  return deferred.promise;
}
function render ( content ) { var deferred = q . defer ( ) ; var blockType = "normal" ; var lines = content . split ( "\n" ) ; var blocks = { } ; for ( var i = 0 ; i < lines . length ; i ++ ) { var line = lines [ i ] ; if ( line . substr ( 0 , 1 ) == "@" ) { blockType = line . substr ( 1 ) . trim ( ) ; if ( blockType === "end" ) blockType = "normal" ; continue ; } if ( blocks [ blockType ] ) blocks [ blockType ] += line + "\n" ; else blocks [ blockType ] = line + "\n" ; } for ( var key in blocks ) { if ( blocks . hasOwnProperty ( key ) ) { try { blocks [ key ] = metaMarked ( blocks [ key ] ) ; } catch ( err ) { return deferred . reject ( new Error ( err ) ) ; } } deferred . resolve ( blocks ) ; } return deferred . promise ; }
Catch all the blocks encapsulated in blocks with `key` as key. and make an object based on this to be used in the templates. ``` @ key # Normal Markdown content @ end ```
Catch all the blocks encapsulated in blocks with key as key . and make an object based on this to be used in the templates .