<commit_before>#!/bin/bash

###########################################################################
# TEMPLY - a simple template engine written in bash
# Author: <NAME> <<EMAIL>>
# License: MIT
###########################################################################

# main function you will call with your bash script
function temply {
	# replace tags which includes files ({include=FILENAME})
	function replaceFiles {
		echo "Replacing $1" >&2
		# get our base template which we want to replace in
		local template=`cat $1`
		# get the directory of the path in order to include all other files relativly
		local includePath=`dirname $1`
		# build our regex to match the include tags
		local re='(.*)\{include=([[:alnum:]_.\/]+)\}(.*)'
		# do for all include tags
		while [[ $template =~ $re ]]; do
			# replace files recursivly
			local rep=$(replaceFiles ${includePath}/${BASH_REMATCH[2]})
			# replace tag with real file
			local template="${BASH_REMATCH[1]}${rep}${BASH_REMATCH[3]}"
		done

		# return our replaced template
		echo "$template"
	}

	# replace variables we find in template
	function replaceVars {
		local template="$1"
		# build our regex to match variable tags
		local re='(.*)\{\$([[:alnum:]_-.]+)\}(.*)'
		# do for all variable tags
		while [[ $template =~ $re ]]; do
			local key="${BASH_REMATCH[2]}"
			# check if the key exists in the variable array
			if [ ${vars[$key]+yes} ]; then
				# it exists: replace the variable
				local rep="${vars[$key]}"
			else
				# it does not exist: throw a warning and drop the tag
				echo "WARNING: $key is not in your vars array!" >&2
				local rep=""<commit_msg>remove - from match group<commit_after>#!/bin/bash

###########################################################################
# TEMPLY - a simple template engine written in bash
# Author: <NAME> <<EMAIL>>
# License: MIT
###########################################################################

# main function you will call with your bash script
function temply {
	# replace tags which includes files ({include=FILENAME})
	function replaceFiles {
		echo "Replacing $1" >&2
		# get our base template which we want to replace in
		local template=`cat $1`
		# get the directory of the path in order to include all other files relativly
		local includePath=`dirname $1`
		# build our regex to match the include tags
		local re='(.*)\{include=([[:alnum:]_.\/]+)\}(.*)'
		# do for all include tags
		while [[ $template =~ $re ]]; do
			# replace files recursivly
			local rep=$(replaceFiles ${includePath}/${BASH_REMATCH[2]})
			# replace tag with real file
			local template="${BASH_REMATCH[1]}${rep}${BASH_REMATCH[3]}"
		done

		# return our replaced template
		echo "$template"
	}

	# replace variables we find in template
	function replaceVars {
		local template="$1"
		# build our regex to match variable tags
		local re='(.*)\{\$([[:alnum:]_.]+)\}(.*)'
		# do for all variable tags
		while [[ $template =~ $re ]]; do
			local key="${BASH_REMATCH[2]}"
			# check if the key exists in the variable array
			if [ ${vars[$key]+yes} ]; then
				# it exists: replace the variable
				local rep="${vars[$key]}"
			else
				# it does not exist: throw a warning and drop the tag
				echo "WARNING: $key is not in your vars array!" >&2
				local rep=""
{'fraction_non_alphanumeric': 0.2162656107219007, 'fraction_numerical': 0.006091989034419738, 'mean_word_length': 4.155416012558869, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, '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': '161099', 'n_tokens_mistral': 1072, 'n_tokens_neox': 935, 'n_words': 360}