tasks/mustatic.js
function(path, partials)
    {
      var templates = { };

      grunt.file.recurse(path, function (absPath, rootDir, subDir, filename)
      {
        // ignore non-template files
        if (!filename.match(matcher)) {
          return;
        }

        // read template source and data
        var relPath  = absPath.substr(rootDir.length + 1),
          tmpData  = absPath.replace(matcher, '.json'),
          tmpSrc   = grunt.file.read(absPath),

          // template name based on path (e.g. "index", "guide/index", etc)
          name     = relPath.replace(matcher, ''),

          // set-up template specific locals
          locals   = mustatic.merge({}, globals);

        // add template URL to locals
        locals.url = name + '.html';

        // load template data and merge into locals
        if (grunt.file.exists(tmpData)) {
          locals = mustatic.merge(locals, JSON.parse(grunt.file.read(tmpData)));
        }

        // store locals
        data[name] = locals;

        templates[name] = hogan.compile(tmpSrc);
      });

      return templates;
    }
function(path, partials)
    {
      var templates = { };

      grunt.file.recurse(path, function (absPath, rootDir, subDir, filename)
      {
        // ignore non-template files
        if (!filename.match(matcher)) {
          return;
        }

        // read template source and data
        var relPath  = absPath.substr(rootDir.length + 1),
          tmpData  = absPath.replace(matcher, '.json'),
          tmpSrc   = grunt.file.read(absPath),

          // template name based on path (e.g. "index", "guide/index", etc)
          name     = relPath.replace(matcher, ''),

          // set-up template specific locals
          locals   = mustatic.merge({}, globals);

        // add template URL to locals
        locals.url = name + '.html';

        // load template data and merge into locals
        if (grunt.file.exists(tmpData)) {
          locals = mustatic.merge(locals, JSON.parse(grunt.file.read(tmpData)));
        }

        // store locals
        data[name] = locals;

        templates[name] = hogan.compile(tmpSrc);
      });

      return templates;
    }
function ( path , partials ) { var templates = { } ; grunt . file . recurse ( path , function ( absPath , rootDir , subDir , filename ) { // ignore non-template files if ( ! filename . match ( matcher ) ) { return ; } // read template source and data var relPath = absPath . substr ( rootDir . length + 1 ) , tmpData = absPath . replace ( matcher , '.json' ) , tmpSrc = grunt . file . read ( absPath ) , // template name based on path (e.g. "index", "guide/index", etc) name = relPath . replace ( matcher , '' ) , // set-up template specific locals locals = mustatic . merge ( { } , globals ) ; // add template URL to locals locals . url = name + '.html' ; // load template data and merge into locals if ( grunt . file . exists ( tmpData ) ) { locals = mustatic . merge ( locals , JSON . parse ( grunt . file . read ( tmpData ) ) ) ; } // store locals data [ name ] = locals ; templates [ name ] = hogan . compile ( tmpSrc ) ; } ) ; return templates ; }
compile templates from a given directory
compile templates from a given directory