tasks/template.js
function getSourceCode(filepath) {
      // The current folder
      var dir = filepath.substring(0, filepath.lastIndexOf("/") + 1);

      // Regex for file import
      var fileRegex = /(?:["'])<!=\s*(.+)\b\s*!>(?:["'])?;?/;
      // Regex for file extension
      var fileExtRegex = /\..+$/;

      // Read the file and check if anything should be imported into it; loop through them
      return grunt.file.read(filepath).replace(new RegExp(fileRegex.source, "g"), function(match) {
        // Log the number of imports we did
        files += 1;

        // Get the filename
        var file = match.match(fileRegex)[1];

        // Check if it has an extension
        if(file.match(fileExtRegex) === null) {
          file += options.defaultExtension; // Add it
        }

        var source = "";

        // Loop through files
        glob.sync(dir + file).forEach(function(filename) {
          // Read file
          var src = grunt.file.read(filename);

          // Check if it has imports too
          source += (function() {
                return fileRegex.test(src) ? getSourceCode(filename) : src;
              })() + options.separator; // Add separator
        });
        return source;
      });
    }
function getSourceCode(filepath) {
      // The current folder
      var dir = filepath.substring(0, filepath.lastIndexOf("/") + 1);

      // Regex for file import
      var fileRegex = /(?:["'])<!=\s*(.+)\b\s*!>(?:["'])?;?/;
      // Regex for file extension
      var fileExtRegex = /\..+$/;

      // Read the file and check if anything should be imported into it; loop through them
      return grunt.file.read(filepath).replace(new RegExp(fileRegex.source, "g"), function(match) {
        // Log the number of imports we did
        files += 1;

        // Get the filename
        var file = match.match(fileRegex)[1];

        // Check if it has an extension
        if(file.match(fileExtRegex) === null) {
          file += options.defaultExtension; // Add it
        }

        var source = "";

        // Loop through files
        glob.sync(dir + file).forEach(function(filename) {
          // Read file
          var src = grunt.file.read(filename);

          // Check if it has imports too
          source += (function() {
                return fileRegex.test(src) ? getSourceCode(filename) : src;
              })() + options.separator; // Add separator
        });
        return source;
      });
    }
function getSourceCode ( filepath ) { // The current folder var dir = filepath . substring ( 0 , filepath . lastIndexOf ( "/" ) + 1 ) ; // Regex for file import var fileRegex = / (?:["'])<!=\s*(.+)\b\s*!>(?:["'])?;? / ; // Regex for file extension var fileExtRegex = / \..+$ / ; // Read the file and check if anything should be imported into it; loop through them return grunt . file . read ( filepath ) . replace ( new RegExp ( fileRegex . source , "g" ) , function ( match ) { // Log the number of imports we did files += 1 ; // Get the filename var file = match . match ( fileRegex ) [ 1 ] ; // Check if it has an extension if ( file . match ( fileExtRegex ) === null ) { file += options . defaultExtension ; // Add it } var source = "" ; // Loop through files glob . sync ( dir + file ) . forEach ( function ( filename ) { // Read file var src = grunt . file . read ( filename ) ; // Check if it has imports too source += ( function ( ) { return fileRegex . test ( src ) ? getSourceCode ( filename ) : src ; } ) ( ) + options . separator ; // Add separator } ) ; return source ; } ) ; }
Recursively resolve the template
Recursively resolve the template