<commit_before>module.exports = plaintemplate

var parse = require('plaintemplate-parse')
var merge = require('merge')

function plaintemplate(input, context, tagHandler, parserOptions) {
  if (context === undefined) {
    context = { } }
  if (tagHandler === undefined) {
    tagHandler = defaultTagHandler }
  return stringify(parse(input, parserOptions), context, tagHandler) }

function stringify(tokens, context, tagHandler) {
  return tokens.reduce(
    function(output, token) {
      return (
        output +
        ( ( 'text' in token ) ?
          token.text :
          tagHandler(token, context, stringify) ) ) },
    '') }

function defaultTagHandler(token, context, stringify) {
  var key, elements, length
  var tag = token.tag

  function addPosition(error, message) {
    error.message = (
      message + ' at ' +
      'line ' + token.position.line + ', ' +
      'column ' + token.position.column)
    error.position = token.position
    return error }

  if (startsWith('insert ', tag)) {
    key = tag.substring(7)
    if (context.hasOwnProperty(key)) {
      return context[key] }
    else {
      throw addPosition(new Error(), ( 'No variable "' + key + '"' )) }
    return ( context.hasOwnProperty(key) ? context[key] : '' ) }
  else if (startsWith('if ', tag)) {
    key = tag.substring(3)
    if (context.hasOwnProperty(key)) {
      return (
        !context[key] ?
          '' : stringify(token.content, context, defaultTagHandler) ) }
    else {
      throw addPosition(new Error(), ( 'No variable "' + key + '"' )) } }
  else if (startsWith('unless ', tag)) {
    key = tag.substring(7)
    if (context.hasOwnProperty(key)) {
      return (
        !context[key] ?<commit_msg>Remove dead code<commit_after>module.exports = plaintemplate

var parse = require('plaintemplate-parse')
var merge = require('merge')

function plaintemplate(input, context, tagHandler, parserOptions) {
  if (context === undefined) {
    context = { } }
  if (tagHandler === undefined) {
    tagHandler = defaultTagHandler }
  return stringify(parse(input, parserOptions), context, tagHandler) }

function stringify(tokens, context, tagHandler) {
  return tokens.reduce(
    function(output, token) {
      return (
        output +
        ( ( 'text' in token ) ?
          token.text :
          tagHandler(token, context, stringify) ) ) },
    '') }

function defaultTagHandler(token, context, stringify) {
  var key, elements, length
  var tag = token.tag

  function addPosition(error, message) {
    error.message = (
      message + ' at ' +
      'line ' + token.position.line + ', ' +
      'column ' + token.position.column)
    error.position = token.position
    return error }

  if (startsWith('insert ', tag)) {
    key = tag.substring(7)
    if (context.hasOwnProperty(key)) {
      return context[key] }
    else {
      throw addPosition(new Error(), ( 'No variable "' + key + '"' )) } }
  else if (startsWith('if ', tag)) {
    key = tag.substring(3)
    if (context.hasOwnProperty(key)) {
      return (
        !context[key] ?
          '' : stringify(token.content, context, defaultTagHandler) ) }
    else {
      throw addPosition(new Error(), ( 'No variable "' + key + '"' )) } }
  else if (startsWith('unless ', tag)) {
    key = tag.substring(7)
    if (context.hasOwnProperty(key)) {
      return (
        !context[key] ?
{'fraction_non_alphanumeric': 0.1425595238095238, 'fraction_numerical': 0.0017857142857142857, 'mean_word_length': 2.908139534883721, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6995350', 'n_tokens_mistral': 1002, 'n_tokens_neox': 1016, 'n_words': 235}