```js nikita.file.render({ source:'./file', if: function({options}, callback){ fs.stat(options.source, function(err, stats){ # Render the file if we own it callback(err, stats.uid == process.getuid()) }); } }, fonction(err, rendered){}); ```
519951
function({options}, succeed, skip) {
    var ok;
    if (!Array.isArray(options.if)) {
      options.if = [options.if];
    }
    ok = true;
    return each(options.if).call((si, next) => {
      var err, type;
      if (!ok) {
        return next();
      }
      type = typeof si;
      if (si === null || type === 'undefined') {
        ok = false;
        return next();
      } else if (type === 'boolean' || type === 'number') {
        if (!si) {
          ok = false;
        }
        return next();
      } else if (type === 'function') {
        if (si.length < 2) {
          try {
            if (!si.call(this, {
              options: options
            })) {
              ok = false;
            }
            return next();
          } catch (error) {
            err = error;
            return next(err);
          }
        } else if (si.length === 2) {
          try {
            return si.call(this, {
              options: options
            }, (err, is_ok) => {
              if (err) {
                return next(err);
              }
              if (!is_ok) {
                ok = false;
              }
              return next();
            });
          } catch (error) {
            err = error;
            return next(err);
          }
        } else {
          return next(Error(`Invalid argument length, expecting 2 or less, got ${si.length}`));
        }
      } else if (type === 'string' || (type === 'object' && Buffer.isBuffer(si))) {
        si = template(si.toString(), {
          options: options
        });
        if (si.length === 0) {
          ok = false;
        }
        return next();
      } else {
        return next(Error(`Invalid condition "if": ${JSON.stringify(si)}`));
      }
    }).next(function(err) {
      if (err || !ok) {
        return skip(err);
      } else {
        return succeed();
      }
    });
  }
283270
def render_reaction(self, glob_ref, tag, data):
        '''
        
        '''
        react = {}

        if glob_ref.startswith('salt://'):
            glob_ref = self.minion.functions['cp.cache_file'](glob_ref) or ''
        globbed_ref = glob.glob(glob_ref)
        if not globbed_ref:
            log.error('Can not render SLS %s for tag %s. File missing or not found.', glob_ref, tag)
        for fn_ in globbed_ref:
            try:
                res = self.render_template(
                    fn_,
                    tag=tag,
                    data=data)

                # for #20841, inject the sls name here since verify_high()
                # assumes it exists in case there are any errors
                for name in res:
                    res[name]['__sls__'] = fn_

                react.update(res)
            except Exception:
                log.exception('Failed to render "%s": ', fn_)
        return react
779254
function () {
    var start = Date.now();
    bundler.bundle()
      .on('error', gutil.log)
      .pipe(source(options.name))
      .pipe(gulpif(options.uglify, streamify(uglify())))
      .pipe(gulp.dest(options.dest))
      .pipe(notify(function () {

        // Fix for requirejs
        var fs = require('fs');
        var file = fs.readFileSync(options.dest + '/' + options.name).toString();
        file = file.replace('define([],e)', 'define(["react"],e)');
        fs.writeFileSync(options.dest + '/' + options.name, file);

        console.log('Built in ' + (Date.now() - start) + 'ms');

      }));

  }
234284
function (options, file, callback) {
  options.logger('Generating template from ' + file)

  async.waterfall([
    async.apply(fs.readFile, file),
    function (template, callback) {
      var result = _.template(template)(options)
      options.logger('Generated template from ' + file + '\n' + result)
      callback(null, result)
    }
  ], callback)
}
632866
function(next) {
          async.map([src,dest], function(path, done) {
            fs.stat(path, function(err, stat) {
              done(null, stat); // Ignore error
            });
          },
          function(err, results) {
            statSrc  = results[0];
            statDest = results[1];
            if(!statSrc) {
              // src is needed
              next(new Error('File not found: ' + src));
            }
            // Ignore anything that is not directory or file
            if(!(statSrc.isFile() || statSrc.isDirectory())) {
              grunt.verbose.writeln('  Ignore:'+' Source is not a file or a directory.'.grey);
              return done(null, false);
            }

            // Add stat to options for user defined transform & process
            options.statSrc  = statSrc;
            options.statDest = statDest;

            next();
          });
        }
639717
function processFile() {
  return (file, callback) => {
    let parsed;
    if (file.meta !== undefined && file.meta.layout !== undefined) {
      const ext = path.extname(file.meta.layout);
      parsed = path.parse(`${trimExtension(file.path)}${ext}`);
    } else {
      parsed = path.parse(file.path);
    }

    const filePath = {
      dir: parsed.dir,
      name: parsed.name,
      ext: parsed.ext,
    };
    const meta = Object.assign({}, file.meta, { filePath });
    async.nextTick(callback, null, Object.assign({}, file, { meta }));
  };
}
1208256
function render_file(locals, cb) {
    // cached?
    var template = cache[filename];
    if (template) {
      return cb(null, template(locals, handlebarsOpts));
    }

    fs.readFile(filename, 'utf8', function(err, str){
      if (err) {
        return cb(err);
      }

      var template = handlebars.compile(str);
      if (locals.cache) {
        cache[filename] = template;
      }

      try {
        var res = template(locals, handlebarsOpts);
        self.async.done(function(values) {
          Object.keys(values).forEach(function(id) {
            res = res.replace(id, values[id]);
          });

          cb(null, res);
        });
      } catch (err) {
        err.message = filename + ': ' + err.message;
        cb(err);
      }
    });
  }
985552
function previewfile(file) {
    if (false && tests.filereader === true) {
      var reader = new FileReader();
      reader.onload = function (event) {
        var image = new Image();
        image.src = event.target.result;
        image.width = 250; // a fake resize
        holder.appendChild(image);
      };

      reader.readAsDataURL(file);
    }  else {
      holder.innerHTML += '<p>Uploaded ' + file.name + ' ' + (file.size ? (file.size/1024|0) + 'K' : '');
//      console.log(file);
    }
  }
277189
function renderSASS(input, output) {
    var d = Q.defer();

    sass.render({
        file: input
    }, function (e, out) {
        if (e) return d.reject(e);

        fs.writeFileSync(output, out.css);
        d.resolve();
    });

    return d.promise;
}
1142047
function render(engine, str, locals, engineOptions) {
  try {
    var output = engine.render(engine.engine, str, locals, engineOptions)
  } catch(e) {
    throw new Error(
      NAME + ': there was a problem rendering the template:\n' + e)
  }
  return output
}
465708
function tryFile(file) {
	return new Promise((resolve, reject) => {
		fs.stat(file, (err, stat) => {
			if (err) {
				return reject(err);
			}

			if (!stat.isFile()) {
				return reject(new Error(`${file} is not a file`));
			}

			resolve(file);
		});
	});
}
1062454
function( path, callback ) {
		var match = munit.isRegExp( render.options.file_match ) ? render.options.file_match : rtestfile;

		path += '/';
		fs.readdir( path, function( e, files ) {
			if ( e ) {
				return callback( e );
			}

			async.each( files || [],
				function( file, callback ) {
					var fullpath = path + file;

					fs.stat( fullpath, function( e, stat ) {
						if ( e ) {
							callback( e );
						}
						else if ( stat.isDirectory() ) {
							render._renderPath( fullpath, callback );
						}
						else {
							if ( stat.isFile() && match.exec( file ) ) {
								munit.require( fullpath );
							}

							callback();
						}
					});
				},
				callback
			);
		});
	}
309705
function parser(file, callback) {
  // file exit conditions
  if(file.isNull()) {
    return callback(null, file); // pass along
  }

  if(file.isStream()) {
    return callback(new Error('Streaming not supported'));
  }

  try {

    var
      /** @type {string} */
      text     = String(file.contents.toString('utf8')),
      lines    = text.split('\n'),
      filename = file.path.substring(0, file.path.length - 4),
      key      = 'server/documents',
      position = filename.indexOf(key)
    ;

    // exit conditions
    if(!lines) {
      return;
    }
    if(position < 0) {
      return callback(null, file);
    }

    filename = filename.substring(position + key.length + 1, filename.length);

    var
      lineCount = lines.length,
      active    = false,
      yaml      = [],
      categories = [
        'UI Element',
        'UI Global',
        'UI Collection',
        'UI View',
        'UI Module',
        'UI Behavior'
      ],
      index,
      meta,
      line
    ;

    for(index = 0; index < lineCount; index++) {

      line = lines[index];

      // Wait for metadata block to begin
      if(!active) {
        if(startsWith(line, '---')) {
          active = true;
        }
        continue;
      }
      // End of metadata block, stop parsing.
      if(startsWith(line, '---')) {
        break;
      }
      yaml.push(line);
    }


    // Parse yaml.
    meta = YAML.parse(yaml.join('\n'));
    if(meta && meta.type && meta.title && inArray(meta.type, categories) ) {
      meta.category = meta.type;
      meta.filename = filename;
      meta.url      = '/' + filename;
      meta.title    = meta.title;
      // Primary key will by filepath
      data[meta.element] = meta;
    }
    else {
      // skip
      // console.log(meta);
    }


  }

  catch(error) {
    console.log(error, filename);
  }

  callback(null, file);

}
613110
function(render, fn) {
      if (typeof render === 'function') {
        fn = render;
        render = false;
      }

      // separate the tracking of the application over rendered pages
      if (render) {
        app.render('partials/analytics', function(error, html) {
          if (error) {
            return fn(error);
          }

          // hack :-\ (because the HTML gets cached)
          fn(
            error,
            html.replace(config.analytics.id, config.analytics['render-id'])
          );
        });
      } else {
        // this doesn't get called anymore
        app.render('analytics', { id: app.get('analytics id') }, fn);
      }
    }
189762
function(callback) {

			var fileLoop = function(currentDir,templateDirectories,cb) {
				var callback_has_been_called = false
				fs.readdir(currentDir,function(err,files) {
					if (err) {
						return console.log('Unable to find files in path',currentDir)
					}
					var num = files.length

					var finishFile = function(i) {
						if (!(--num)) {
							if (!callback_has_been_called) {
								callback_has_been_called = true
								return cb()
							}
						} else {
							buildFileData(i+1)
						}
					}

					var buildFileData = function(i) {
						var file = files[i]
						var filepath = currentDir + '/' + file

						fs.stat(filepath,function(err2,stats) {
							if (err2) {
								return console.log('Unable to find file',filepath)
							}

							if (stats && stats.isDirectory()) {
								var pugatizerPath = '    puglatizer' + currentDir.replace(templateDirectories,'').replace(/\//g,'"]["') + '"]["' + file.replace('.pug','') + '"] = {}\r\n'
								pugatizerPath = pugatizerPath.replace('puglatizer"]','puglatizer')
								fs.appendFileSync(outputFile,pugatizerPath)
								fileLoop(filepath,templateDirectories,function() {
									finishFile(i)
								})
							} else if (stats && stats.isFile()) {
								var ext = path.extname(filepath)
								if (ext == '.pug') {
									var pugatizerPath = '    puglatizer' + currentDir.replace(templateDirectories,'').replace(/\//g,'"]["') + '"]["' + file.replace('.pug','') + '"] = '
									pugatizerPath = pugatizerPath.replace('puglatizer"]','puglatizer')
									buildTemplateFromFile(filepath,options,function(err,template) {
										pugatizerPath += minify.js(template.toString()) + ';\r\n\r\n'
										fs.appendFileSync(outputFile,pugatizerPath)
										finishFile(i)
									})
								} else {
									finishFile(i)
								}
							} else {
								finishFile(i)
							}
						})
					}

					if (!num) {
						return console.log('Unable to find files in path',currentDir)
					} else {
						buildFileData(0)
					}

				})

			}
			
			fileLoop(templateDirectories,templateDirectories,function() {
				return callback()
			})
		}
280741
function renderHTML(callback) {
            async.map(codeList, function (locals, n) {
                locals.req = req;
                ViewHelper.render({
                    cache: true,
                    path: SCRIPT_JADE
                }, locals, n)
            }, function (err, buf) {
                if (!err) {
                    buf = buf || [];
                    buf.splice(0, 0, SCRIPT_START_TAG);
                    buf.push(bottomScriptList.join(""));
                    buf.push(SCRIPT_END_TAG);
                }
                callback(err, buf.join(""));
            });
        }
179031
function processFile(md) {
  return (file, callback) => {
    let content;
    let footnotes;
    try {
      const tokens = md.parse(file.meta.content, {});
      const footnoteTokens = popFootnoteTokens(tokens);
      footnotes = footnoteTokensToMeta(footnoteTokens, md);
      content = md.renderer.render(tokens, md.options, {});
    } catch (error) {
      console.error(`${file.path}: Could not render the content`);
      async.nextTick(callback, error);
      return;
    }

    const meta = Object.assign({}, file.meta, { content, footnotes });
    async.nextTick(callback, null, Object.assign({}, file, { meta }));
  };
}