<commit_before># ErlyDTL plugin.

ERLYDTL_CASES = compile full-path include-template opts path-full-path-suffix suffix
ERLYDTL_TARGETS = $(addprefix erlydtl-,$(ERLYDTL_CASES))

.PHONY: erlydtl $(ERLYDTL_TARGETS)

erlydtl: $(ERLYDTL_TARGETS)

erlydtl-compile: build clean

	$i "Bootstrap a new OTP library named $(APP)"
	$t mkdir $(APP)/
	$t cp ../erlang.mk $(APP)/
	$t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v

	$i "Add ErlyDTL to the list of dependencies"
	$t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = erlydtl\n"}' $(APP)/Makefile

	$i "Generate ErlyDTL templates"
	$t mkdir $(APP)/templates/
	$t touch $(APP)/templates/$(APP)_one.dtl
	$t touch $(APP)/templates/$(APP)_two.dtl

	$i "Build the application"
	$t $(MAKE) -C $(APP) $v

	$i "Check that ErlyDTL templates are compiled"
	$t test -f $(APP)/ebin/$(APP)_one_dtl.beam
	$t test -f $(APP)/ebin/$(APP)_two_dtl.beam

	$i "Check that ErlyDTL generated modules are included in .app file"
	$t $(ERL) -pa $(APP)/ebin/ -eval " \
		ok = application:load($(APP)), \
		{ok, [$(APP_)_one_dtl, $(APP)_two_dtl]} = application:get_key($(APP), modules), \
		halt()"

erlydtl-full-path: build clean

	$i "Bootstrap a new OTP library named $(APP)"
	$t mkdir $(APP)/
	$t cp ../erlang.mk $(APP)/
	$t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v

	$i "Add ErlyDTL to the list of dependencies; set DTL_FULL_PATH"
	$t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = erlydtl\nDTL_FULL_PATH = 1\n"}' $(APP)/Makefile

	$i "Generate ErlyDTL templates"
	$t mkdir -p $(APP)/templates/deep/
	$t touch $(APP)/templates/$(APP)_one.dtl
	$t touch $(APP)/templates/deep/$(APP)_two.dtl<commit_msg>Add a test for ErlyDTL with a custom tag<commit_after># ErlyDTL plugin.

ERLYDTL_CASES = compile custom-tag full-path include-template opts path-full-path-suffix suffix
ERLYDTL_TARGETS = $(addprefix erlydtl-,$(ERLYDTL_CASES))

.PHONY: erlydtl $(ERLYDTL_TARGETS)

erlydtl: $(ERLYDTL_TARGETS)

erlydtl-compile: build clean

	$i "Bootstrap a new OTP library named $(APP)"
	$t mkdir $(APP)/
	$t cp ../erlang.mk $(APP)/
	$t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v

	$i "Add ErlyDTL to the list of dependencies"
	$t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = erlydtl\n"}' $(APP)/Makefile

	$i "Generate ErlyDTL templates"
	$t mkdir $(APP)/templates/
	$t touch $(APP)/templates/$(APP)_one.dtl
	$t touch $(APP)/templates/$(APP)_two.dtl

	$i "Build the application"
	$t $(MAKE) -C $(APP) $v

	$i "Check that ErlyDTL templates are compiled"
	$t test -f $(APP)/ebin/$(APP)_one_dtl.beam
	$t test -f $(APP)/ebin/$(APP)_two_dtl.beam

	$i "Check that ErlyDTL generated modules are included in .app file"
	$t $(ERL) -pa $(APP)/ebin/ -eval " \
		ok = application:load($(APP)), \
		{ok, [$(APP_)_one_dtl, $(APP)_two_dtl]} = application:get_key($(APP), modules), \
		halt()"

erlydtl-custom-tag: build clean

	$i "Bootstrap a new OTP library named $(APP)"
	$t mkdir $(APP)/
	$t cp ../erlang.mk $(APP)/
	$t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v

	$i "Add ErlyDTL to the list of dependencies"
	$t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = erlydtl\n"}' $(APP)/Makefile

	$i "Generate an ErlyDTL library module containing a custom tag"
	$t printf "%s\n" \
		"-module($(APP)_lib)." \
		"-behavior(erlydtl_library)." \
		"-export([version/0, inventory/1, mytag/2])." \
		"version() -> 1." \
		"inventory(filters) -> [];" \
		"inventory(tags) -> [mytag]." \
		"mytag(_,_) -> <<\"hello\">>." > $(APP)/src/$(APP)_lib.erl

	$i "Add our library to the ErlyDTL options"
	$t echo "DTL_OPTS = {libraries, [{erlang_mk, $(APP)_lib}]}" >> $(APP)/Makefile

	$i "Generate an ErlyDTL template that uses a custom tag"
	$t mkdir $(APP)/templates/
	$t printf "%s\n" \
		"{% load erlang_mk %}" \
		"{% mytag as value %}" \
		"{{ value }}" > $(APP)/templates/$(APP).dtl

	$i "Build the application"
	$t $(MAKE) -C $(APP) $v

	$i "Check that the ErlyDTL template is compiled"
	$t test -f $(APP)/ebin/$(APP)_dtl.beam

	$i "Check that ErlyDTL generated modules are included in .app file"
	$t $(ERL) -pa $(APP)/ebin/ -eval " \
		ok = application:load($(APP)), \
		{ok, [$(APP_)_dtl, $(APP)_lib]} = application:get_key($(APP), modules), \
		halt()"

	$i "Confirm the custom tag is used"
	$t $(ERL) -pa $(APP)/ebin/ $(APP)/deps/*/ebin/ -eval \
		'file:write_file("$(APP)/OUT", element(2, $(APP)_dtl:render())), halt()'
	$t cat $(APP)/OUT | grep -q hello

erlydtl-full-path: build clean

	$i "Bootstrap a new OTP library named $(APP)"
	$t mkdir $(APP)/
	$t cp ../erlang.mk $(APP)/
	$t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v

	$i "Add ErlyDTL to the list of dependencies; set DTL_FULL_PATH"
	$t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = erlydtl\nDTL_FULL_PATH = 1\n"}' $(APP)/Makefile

	$i "Generate ErlyDTL templates"
	$t mkdir -p $(APP)/templates/deep/
	$t touch $(APP)/templates/$(APP)_one.dtl
	$t touch $(APP)/templates/deep/$(APP)_two.dtl
{'fraction_non_alphanumeric': 0.1978269782697827, 'fraction_numerical': 0.0024600246002460025, 'mean_word_length': 3.854726368159204, 'pattern_counts': {'":': 0, '<': 5, '<?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': '7450330', 'n_tokens_mistral': 2083, 'n_tokens_neox': 1995, 'n_words': 552}