Ejemplo n.º 1
0
'use strict';

var fs = require('fs');
var path = require('path');
var gutil = require('gulp-util');
var stripAnsi = require('strip-ansi');
var istanbul = require('gulp-istanbul');
var jshint = require('gulp-jshint');
var mocha = require('gulp-mocha');
var verb = require('verb');


// helper for including coverage report
verb.helper('coverage', function (fp) {
  var str = fs.readFileSync(fp, 'utf8');
  return stripAnsi(str).replace(/^=.*/gm, '').trim();
});

function toSections(fp) {
  var str = fs.readFileSync(fp, 'utf8');
  var arr = str.split(/^##\s/gm);
  var len = arr.length, sections = {};
  while (len--) {
    var section = arr[len].trim();
    var lines = section.split('\n');
    if (lines.length > 1) {
      var heading = lines[0].trim();
      lines = lines.slice(1);
      section = '\n' + lines.join('\n').trim();
      sections[heading] = {path: heading, content: section};
    }
Ejemplo n.º 2
0
'use strict';

var path = require('path');
var verb = require('verb');

verb.helper('example', require('./'));

verb.helper('template', function (delims, name) {
  if (!Array.isArray(delims)) {
    name = delims; delims = ['<%=', '%>']
  }
  verb.partial.apply(verb, arguments);
  var name = arguments[0];
  var partial = verb.views.partials[name];
  partial.content = format(partial.content, delims);
  verb.views.partials[name] = partial;
});

verb.helper('results', function (name) {
  console.log(this.context.partials)
  // var template = this.app.views.partials[name];
  // var res = this.app.renderTemplate(template);
  console.log(verb.cache.data)
  console.log(verb.views.partials)
});

function format(str, delims) {
  str = str.split(delims[0]).join('{%=');
  str = str.split(delims[1]).join('%}');
  return str;
}