# Copyright 2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

inherit rebar

DESCRIPTION="Django Template Language for Erlang"
HOMEPAGE="https://github.com/erlydtl/erlydtl"
SRC_URI="https://github.com/erlydtl/${PN}/archive/${PV}.tar.gz -> ${P}.tar.gz"

LICENSE="MIT"
SLOT="0"
KEYWORDS="~amd64 ~arm ~sparc ~x86"

DOCS=( NEWS.md README.markdown README_I18N )

src_prepare() {
	rebar_src_prepare

	# Upstream's {require_otp_vsn, "18"} is meant as "OTP 18 or newer".
	# However, rebar2 treats the value as a regular expression that must
	# match the OTP release, so the build aborts on any release but 18.
	sed -i '/^{require_otp_vsn,/d' rebar.config || die
}

src_test() {
	# Upstream compiles this test parser in a pre_hook which only exists in
	# rebar-tests.config.
	erlc -I include/erlydtl_preparser.hrl -o test \
		test/erlydtl_extension_testparser.yrl || die

	# rebar2 runs eunit from within .eunit/, but the tests use paths
	# relative to the project root.
	mkdir -p .eunit || die
	ln -s ../test .eunit/test || die

	rebar_src_test
}
