aboutsummaryrefslogtreecommitdiffstats
path: root/test/plugin_erlydtl.mk
diff options
context:
space:
mode:
authorKrzysztof Jurewicz <[email protected]>2016-03-31 17:23:50 +0200
committerKrzysztof Jurewicz <[email protected]>2016-04-03 17:17:38 +0200
commit6c4a17ee75a4bef75863b2a65842fa55f1ab43aa (patch)
tree982db630419ba40751af136e111cdb0458855564 /test/plugin_erlydtl.mk
parent1fee577a15f5dbcc391b8f555458dad68f24afde (diff)
downloaderlang.mk-6c4a17ee75a4bef75863b2a65842fa55f1ab43aa.tar.gz
erlang.mk-6c4a17ee75a4bef75863b2a65842fa55f1ab43aa.tar.bz2
erlang.mk-6c4a17ee75a4bef75863b2a65842fa55f1ab43aa.zip
Add possibility to specify custom ErlyDTL options
Diffstat (limited to 'test/plugin_erlydtl.mk')
-rw-r--r--test/plugin_erlydtl.mk39
1 files changed, 38 insertions, 1 deletions
diff --git a/test/plugin_erlydtl.mk b/test/plugin_erlydtl.mk
index b96596d..ddb32d3 100644
--- a/test/plugin_erlydtl.mk
+++ b/test/plugin_erlydtl.mk
@@ -1,6 +1,6 @@
# ErlyDTL plugin.
-ERLYDTL_CASES = compile full-path
+ERLYDTL_CASES = compile full-path opts
ERLYDTL_TARGETS = $(addprefix erlydtl-,$(ERLYDTL_CASES))
.PHONY: erlydtl $(ERLYDTL_TARGETS)
@@ -62,3 +62,40 @@ erlydtl-full-path: build clean
ok = application:load($(APP)), \
{ok, [deep_$(APP)_two_dtl, $(APP_)_one_dtl]} = application:get_key($(APP), modules), \
halt()"
+
+erlydtl-opts: 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 template"
+ $t mkdir $(APP)/templates/
+ $t echo "{{ foo }}" > $(APP)/templates/$(APP)_foo.dtl
+
+ $i "Build the application with auto escape turned on"
+ $t $(MAKE) -C $(APP) DTL_OPTS=auto_escape $v
+
+ $i "Check that HTML is escaped"
+ $t $(ERL) -pa $(APP)/ebin/ $(APP)/deps/erlydtl/ebin/ -eval " \
+ ok = application:load($(APP)), \
+ {ok, Result} = $(APP)_foo_dtl:render([{foo, <<\"<&>\">>}]), \
+ <<\"&lt;&amp;&gt;\", _/binary>> = iolist_to_binary(Result), \
+ halt()"
+
+ $i "Clean the application"
+ $t $(MAKE) -C $(APP) clean $v
+
+ $i "Build the application with auto escape turned off"
+ $t $(MAKE) -C $(APP) "DTL_OPTS={auto_escape, false}" $v
+
+ $i "Check that HTML is not escaped"
+ $t $(ERL) -pa $(APP)/ebin/ $(APP)/deps/erlydtl/ebin/ -eval " \
+ ok = application:load($(APP)), \
+ {ok, Result} = $(APP)_foo_dtl:render([{foo, <<\"<&>\">>}]), \
+ <<\"<&>\", _/binary>> = iolist_to_binary(Result), \
+ halt()"