index.js
function addPartial(filename, done) {
      // Create a copy of the file and delete it from the database.
      const file = clone(files[filename])
      delete files[filename]

      // Compile the partial.
      const info = path.parse(filename)
      const transform = info.ext ? info.ext.substring(1) : null
      const transformer = getTransformer(transform)
      if (transformer) {
        // Construct the options.
        const options = extend({}, metalsmith.metadata(), file, {
          filename: path.join(metalsmith.source(), filename)
        })

        // Compile the partial.
        transformer.compileAsync(file.contents.toString(), options).then(template => {
          /**
           * Define the partial as a function.
           */
          metalsmith.metadata().partials[info.name] = locals => {
            const opt = extend({}, options, locals)
            return template.fn.apply(file, [opt])
          }
          metalsmith.metadata().partials[info.name].file = file
          done()
        }, done)
      } else {
        // Do not error out when the Transformer is not found.
        done()
      }
    }
function addPartial(filename, done) {
      // Create a copy of the file and delete it from the database.
      const file = clone(files[filename])
      delete files[filename]

      // Compile the partial.
      const info = path.parse(filename)
      const transform = info.ext ? info.ext.substring(1) : null
      const transformer = getTransformer(transform)
      if (transformer) {
        // Construct the options.
        const options = extend({}, metalsmith.metadata(), file, {
          filename: path.join(metalsmith.source(), filename)
        })

        // Compile the partial.
        transformer.compileAsync(file.contents.toString(), options).then(template => {
          /**
           * Define the partial as a function.
           */
          metalsmith.metadata().partials[info.name] = locals => {
            const opt = extend({}, options, locals)
            return template.fn.apply(file, [opt])
          }
          metalsmith.metadata().partials[info.name].file = file
          done()
        }, done)
      } else {
        // Do not error out when the Transformer is not found.
        done()
      }
    }
function addPartial ( filename , done ) { // Create a copy of the file and delete it from the database. const file = clone ( files [ filename ] ) delete files [ filename ] // Compile the partial. const info = path . parse ( filename ) const transform = info . ext ? info . ext . substring ( 1 ) : null const transformer = getTransformer ( transform ) if ( transformer ) { // Construct the options. const options = extend ( { } , metalsmith . metadata ( ) , file , { filename : path . join ( metalsmith . source ( ) , filename ) } ) // Compile the partial. transformer . compileAsync ( file . contents . toString ( ) , options ) . then ( template => { /**
           * Define the partial as a function.
           */ metalsmith . metadata ( ) . partials [ info . name ] = locals => { const opt = extend ( { } , options , locals ) return template . fn . apply ( file , [ opt ] ) } metalsmith . metadata ( ) . partials [ info . name ] . file = file done ( ) } , done ) } else { // Do not error out when the Transformer is not found. done ( ) } }
Add the given file in as a partial.
Add the given file in as a partial .