Example application using load-templates

```js
var Engine = require('engine');
var engine = new Engine();
```

@param {[type]} options
180003
function Engine(options) {
  Options.call(this, options);
  this.views = {};
  this.defaultTemplates();
  this.defaultOptions();

  if (this.enabled('debug')) {
    this.debug();
  }
}
1104512
function loadJS(src, callback, attrs, timeout, fail, complete) {
    if ($.isObject(src)) {
        callback = src.callback;
        attrs = src.attrs;
        timeout = src.timeout;
        fail = src.fail;
        complete = src.complete;
        src = src.src;
        return loadJS(src, callback, attrs, timeout, fail, complete);
    }
    var script = document.createElement('script');
    var done = false;
    if ($.isObject(attrs)) {
        for (var i in attrs) {
            script.setAttribute(i, attrs[i]);
        }
    }
    var urls = getPath(src);
    src = script.src = urls[0];
    script.async = true;
    script.type = 'text/javascript';
    script.charset = defaultConfig.charset;
    complete = $.isFunction(complete) ? complete : emptyFn;
    script.onload = script.onreadystatechange = function(e) {
        e = e || cleanObj
        if (!done && (e.type === 'load' || /loaded|complete|undefined/.test(script.readyState))) {
            done = true;
            removeNode(script);
            mapLoaded[src] = 'loaded';
            $.isFunction(callback) && callback();
            complete('load');
        }
    };
    script.onerror = function() {
        done = true;
        mapLoaded[src] = 'error';
        $.isFunction(fail) && fail();
        complete('error');
    };
    timeout = $.isNumber(timeout) ? timeout : defaultConfig.timeout;
    if (timeout) {
        setTimeout(function() {
            if (!done) {
                done = true;
                mapLoaded[src] = 'timeout';
                complete('timeout');
            }
        }, timeout);
    }
    mapLoaded[src] = 'pending';
    head.insertBefore(script, base);
    return _;
}
1139300
function load(method, config) {
  return function(patterns, options) {
    var opts = mergeOptions(this, config, options);
    var loader = createLoader(opts, this[method]);
    return loader.apply(this, arguments);
  };
}
860730
function template(
  { template, types: t },
  opts,
  { imports, componentName, props, jsx, exports },
) {
  const name = componentName.name.replace('Svg', '');

  jsx
    .openingElement
    .attributes = [
      t.jsxAttribute(
        t.jsxIdentifier('aria-label'),
        t.stringLiteral(`icon_${name}`)
      ),
      ...jsx.openingElement.attributes
    ];

  const titleElement = t.jsxElement(
    t.jsxOpeningElement(t.jsxIdentifier('title'), []),
    t.jsxClosingElement(t.jsxIdentifier('title')),
    [t.jsxText(`${name}`)],
  )

  jsx.children = [titleElement, ...jsx.children];

  return template.ast`
    ${imports}
    import withIcon from './withIcon';
    const ${name} = (${props}) => ${jsx}
    export default withIcon(${name});
  `
}
1022326
function ex2engine (fullpath) {
	let extension = extname(fullpath).slice(1);
	let file = fullpath.replace(extname(fullpath), '');
	let engine;
	if (!extension && !cacher[fullpath] && !exists(fullpath)) {
		for (const engineExt of testedEngines) {
			/* istanbul ignore else */
			if (exists(`${file}.${engineExt}`)) {
				extension = engineExt;
				break;
			}
		}
	}
	if (!cacher[fullpath]) {
		engine = extMapper[extension] || extension;
		let path = `${file}.${extension}`;
		if (testedEngines.indexOf(engine) === -1 && avaliableEngines.indexOf(engine) > -1 && engine !== 'html') {
			console.warn(`${engine} engine is avaliable but not tested`);
		} else if (avaliableEngines.indexOf(engine) === -1 && engine !== 'html') {
			throw Error(`${engine} engine is not supported`);
		}
		cacher[fullpath] = [engine, path];
	}
	return cacher[fullpath];
}
858372
function require(names, callback, errback, referer) {
      // in amd, first arg can be a config object... we just ignore
      if (typeof names == 'object' && !(names instanceof Array))
        return require.apply(null, Array.prototype.splice.call(arguments, 1, arguments.length - 1));

      // amd require
      if (typeof names == 'string' && typeof callback == 'function')
        names = [names];
      if (names instanceof Array) {
        var dynamicRequires = [];
        for (var i = 0; i < names.length; i++)
          dynamicRequires.push(loader['import'](names[i], referer));
        Promise.all(dynamicRequires).then(function(modules) {
          if (callback)
            callback.apply(null, modules);
        }, errback);
      }

      // commonjs require
      else if (typeof names == 'string') {
        var defaultJSExtension = loader.defaultJSExtensions && names.substr(names.length - 3, 3) != '.js';
        var normalized = loader.decanonicalize(names, referer);
        if (defaultJSExtension && normalized.substr(normalized.length - 3, 3) == '.js')
          normalized = normalized.substr(0, normalized.length - 3);
        var module = loader.get(normalized);
        if (!module)
          throw new Error('Module not already loaded loading "' + names + '" as ' + normalized + (referer ? ' from "' + referer + '".' : '.'));
        return module.__useDefault ? module['default'] : module;
      }

      else
        throw new TypeError('Invalid require');
    }
1005507
function loadTemplate(templatePath, identifier) {
  return plugin.myrmex.fire('beforeTemplateLoad', templatePath, identifier)
  .spread((templatePath, name) => {
    const templateDoc = _.cloneDeep(require(path.join(templatePath)));

    // Lasy loading because the plugin has to be registered in a Myrmex instance before requiring the document
    const Template = require('./template');
    const template = new Template(templateDoc, identifier);

    // This event allows to inject code to alter the template configuration
    return plugin.myrmex.fire('afterTemplateLoad', template);
  })
  .spread(template => {
    return Promise.resolve(template);
  });
}
882923
function Templates(options) {
  if (!(this instanceof Templates)) {
    return new Templates(options);
  }

  Base.call(this, null, options);
  this.is('templates');
  this.define('isApp', true);
  this.use(utils.option());
  this.use(utils.plugin());
  this.initTemplates();
}
569029
function Plugin(options) {

  options = options || {};

  var reactOptions = {
    harmony: typeof options.harmony === 'undefined' ? true : options.harmony,
    stripTypes: typeof options.stripTypes === 'undefined' ? true : options.stripTypes
  };

  if (options.template && options.template.indexOf('<') === -1) {
    options.template = fs.readFileSync(options.template, {encoding: 'utf8'});
  }

  var originalJsTransform = require.extensions['.js'];

  var reactTransform = function(module, filename) {
    if (filename.indexOf('node_modules') === -1) {
      var src = fs.readFileSync(filename, {encoding: 'utf8'});
      src = appendJsxPragma(filename, src);
      src = ReactTools.transform(src, reactOptions);
      module._compile(src, filename);
    } else {
      originalJsTransform(module, filename);
    }
  };

  require.extensions['.js'] = reactTransform;
  require.extensions['.jsx'] = reactTransform;

  // Creates a stream through which each file will pass
  var stream = through.obj(function(file, enc, cb) {

    if (!file.isNull()) {

      if (file.isStream()) {
        this.emit('error', new PluginError(PLUGIN_NAME, 'Streams are not supported!'));
        return cb();
      }

      if (file.isBuffer()) {

        try {
          var contents = file.contents.toString('utf8');
          contents = appendJsxPragma(file.path, contents);
          contents = ReactTools.transform(contents, reactOptions);
          var m = new Module();
          m.id = file.path;
          m.filename = file.path;
          m.paths = module.paths.slice(1);
          m._compile(contents, file.path);
          var Component = m.exports;
          var markup = options.staticMarkup ? renderToStaticMarkup(Component) : renderToString(Component);

          if (options.template) {
            var data = _.extend({}, (typeof(options.data) == 'function' ? options.data(file) : options.data));
            data.body = markup;

            // Set default values to avoid null-reference exceptions
            data.title = data.title || '';
            data.description = data.description || '';
            data.keywords = data.keywords || '';

            markup = template(options.template, data);
          }

          file.contents = new Buffer(markup);
          var filename = gutil.replaceExtension(file.path, '.html');

          if (typeof options.hyphenate === 'undefined' || options.hyphenate) {
            filename = hyphenate(path.basename(filename));
            filename = filename.lastIndexOf('-', 0) === 0 ? filename.substring(1) : filename;
            filename = path.join(path.dirname(file.path), filename);
          }

          file.path = filename;
        } catch (err) {
          this.emit('error', new PluginError(PLUGIN_NAME, err));
          return cb();
        }
      }
    }

    // Make sure the file goes through the next gulp plugin
    this.push(file);
    // Tell the stream engine that we are done with this file
    return cb();
  });

  // Return the file stream
  return stream;
}
1270839
function createApplication(options) {
    options = options || {};
    var sapp = new Application();
    sapp.sycle = sycle;

    if (options.loadBuiltinModels) {
        sapp.phase(require('./boot/builtin-models')());
    }

    return sapp;

}
666198
function use(plugin, options){
  utils.assertString(plugin, 'plugin');

  if (options) {
    utils.assertType(options, 'object', 'options');
    options = parseObject(options);
  }

  // lookup
  plugin = plugin.string;
  var found = utils.lookup(plugin, this.options.paths, this.options.filename);
  if (!found) throw new Error('failed to locate plugin file "' + plugin + '"');

  // use
  var fn = require(path.resolve(found));
  if ('function' != typeof fn) {
    throw new Error('plugin "' + plugin + '" does not export a function');
  }
  this.renderer.use(fn(options || this.options));
}
398271
function renderTemplate(engine, filePath, content, context) {
    context = context || {};

    // Mutable objects to contains all blocks requiring post-processing
    var blocks = {};

    // Create nunjucks environment
    var env = engine.toNunjucks(blocks);

    // Replace shortcuts from plugin's blocks
    content = replaceShortcuts(engine.getBlocks(), filePath, content);

    return timing.measure(
        'template.render',

        Promise.nfcall(
            env.renderString.bind(env),
            content,
            context,
            {
                path: filePath
            }
        )
        .then(function(content) {
            return TemplateOutput.create(content, blocks);
        })
    );
}
253686
function Engines(engines, options) {
  this.options = options || {};
  this.cache = engines || {};
  this.AsyncHelpers = this.options.AsyncHelpers || AsyncHelpers;
  this.Helpers = this.options.Helpers || Helpers;
}
1014901
function template(pattern) {
    return app.src(pattern, { cwd: path.join(__dirname, 'templates') })
      .pipe(app.renderFile('*')).on('error', console.error)
      .pipe(app.conflicts(app.cwd))
      .pipe(app.dest(app.options.dest || app.cwd));
  }
1136483
function injectTemplate(template) {
  let js = [
    '',
    'var __vue__options__ = (module.exports.__esModule) ?',
    'module.exports.default : module.exports;',
    '__vue__options__.template = ' + JSON.stringify(template) + ';',
    '',
  ];

  return js.join(os.EOL);
}
1153410
function load(string, options) {

  var theRequire = (options && options.require) || require

  try {
    return theRequire(string)
  } catch (error) {
    return {
      error: 'Unable to require plugin with string: ' + string,
      reason: error
    }
  }
}
1223616
function Loader(options) {
  if (!(this instanceof Loader)) {
    return new Loader(options);
  }
  this.options = options || {};
  this.cache = this.options.helpers || {};
}