<commit_before>#
# Create a temporary directory to store compiled templates
#

COMPILED_DIR="./compiled_tmp"
rm -rf "$COMPILED_DIR"
mkdir "$COMPILED_DIR"


#
# Compile templates
#

TEMPLATES_DIR="src/mist/io/static/js/app/templates"

for f in $TEMPLATES_DIR"/"*.html
do
    echo "Compiling: $f"
    FILE_NAME=$(basename "$f")
    FILE_NAME="${FILE_NAME%.*}"
    ember-precompile "$f" -f "$COMPILED_DIR""/""$FILE_NAME"".js"

done


#
# Concatinate files
#

echo""
echo "Concatinating files..."
HTML_BUILD="src/mist/io/static/js/app/templates/build.js"

if [ -f $HTML_BUILD ]
then 
    rm $HTML_BUILD
fi
touch $HTML_BUILD

for f in $COMPILED_DIR"/"*.js
do
    cat "$f" >> $HTML_BUILD
done


#
# Add define header in build.js
#

echo "Adding define wrapper on: $HTML_BUILD"
HEADER="define('app/templates/build', ['ember'], function() {
"
echo "$HEADER" | cat - "$HTML_BUILD" > temp && mv temp "$HTML_BUILD"
echo "});" >> "$HTML_BUILD"

#clean up
echo "Cleaning up"
rm -rf $COMPILED_DIR
echo "Done"<commit_msg>Optimize html build script<commit_after>#####################################################
#	
#	Compiles multiple handlebars templates into
#   a single file for optimized performacne
#
####################################################

TEMPLATES_DIR="src/mist/io/static/js/app/templates"
BUILD_PATH="src/mist/io/static/js/app/templates/build.js"

# Wrap file into a define statement to access it in app.js
echo "define('app/templates/build', ['ember'], function() {
" > $BUILD_PATH

# Compile html files and append them to build.js
for f in $TEMPLATES_DIR"/"*.html
do
    echo "Compiling: $f"
    ember-precompile "$f" >> $BUILD_PATH

done

# Close wrapper
echo "});" >> $BUILD_PATH

{'fraction_non_alphanumeric': 0.20518867924528303, 'fraction_numerical': 0.0, 'mean_word_length': 4.694630872483222, 'pattern_counts': {'":': 0, '<': 3, '<?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': '3458750', 'n_tokens_mistral': 601, 'n_tokens_neox': 585, 'n_words': 149}