Permalink
Browse files

Use correct docroot in included templates. Thanks to Tobias Loefgren.

git-svn-id: http://erlydtl.googlecode.com/svn/trunk@152 a5195066-8e3e-0410-a82a-05b01b1b9875
  • Loading branch information...
1 parent 5803797 commit 292951c8bc7acb4248c28472f6786ae3398786dd emmiller committed Feb 11, 2009
@@ -0,0 +1,3 @@
+{% extends "path1/base1" %}
+{% block title %}replacing the base title{% endblock %}
+{% block content %}replacing the base content - variable: {{ test_var }} after variable {% endblock %}
@@ -0,0 +1,5 @@
+main file
+
+{% include "path1/template1" %}
+
+{{ base_var }}
@@ -0,0 +1,3 @@
+Including another template: {% include "base" %}
+
+test variable: {{ test_var }}
@@ -0,0 +1,6 @@
+{% extends "../path2/base2" %}
+
+{% block title2 %}block title 2 from base1 {% endblock %}
+
+
+
@@ -0,0 +1,5 @@
+This is template 1.
+
+{{ test_var }}
+
+{% include "../path2/template2" %}
@@ -0,0 +1,14 @@
+{{ base_var }}
+
+base2 template
+
+{% block title %}block title in base2, should be hidden by main template{% endblock %}
+{% block title2 %}block title2 in base2, should be hidden by base1{% endblock %}
+
+more of base2 template
+
+{% block content %}block content in base 2, should be overwritten{% endblock %}
+
+{% block content2 %}block content2 in base 2, should pass through{% endblock %}
+
+end of base2 template
@@ -0,0 +1,2 @@
+
+This is template 2
@@ -293,7 +293,8 @@ body_ast([{extends, {string_literal, _Pos, String}} | ThisParseTree], Context, T
with_dependency({File, CheckSum}, body_ast(ParentParseTree, Context#dtl_context{
block_dict = dict:merge(fun(_Key, _ParentVal, ChildVal) -> ChildVal end,
BlockDict, Context#dtl_context.block_dict),
- parse_trail = [File | Context#dtl_context.parse_trail]}, TreeWalker));
+ parse_trail = [File | Context#dtl_context.parse_trail],
+ doc_root = filename:dirname(File)}, TreeWalker));
Err ->
throw(Err)
end
@@ -449,7 +450,8 @@ include_ast(File, Context, TreeWalker) ->
case parse(FilePath, Context) of
{ok, InclusionParseTree, CheckSum} ->
with_dependency({FilePath, CheckSum}, body_ast(InclusionParseTree, Context#dtl_context{
- parse_trail = [FilePath | Context#dtl_context.parse_trail]}, TreeWalker));
+ parse_trail = [FilePath | Context#dtl_context.parse_trail],
+ doc_root = filename:dirname(FilePath) }, TreeWalker));
Err ->
throw(Err)
end.
@@ -45,7 +45,8 @@ test_list() ->
"for_records_preset", "include", "if", "if_preset", "ifequal",
"ifequal_preset", "ifnotequal", "ifnotequal_preset", "now",
"var", "var_preset", "var_error", "cycle", "custom_tag",
- "custom_tag_error", "custom_call"].
+ "custom_tag_error", "custom_call",
+ "include_template", "include_path", "extends_path" ].
setup_compile("for_list_preset") ->
CompileVars = [{fruit_list, [["apple", "apples"], ["banana", "bananas"], ["coconut", "coconuts"]]}],
@@ -144,6 +145,16 @@ setup("cycle") ->
RenderVars = [{test, [integer_to_list(X) || X <- lists:seq(1, 20)]},
{a, "Apple"}, {b, "Banana"}, {c, "Cherry"}],
{ok, RenderVars};
+setup("include_template") ->
+ RenderVars = [{base_var, "base-barstring"}, {test_var, "test-barstring"}],
+ {ok, RenderVars};
+setup("include_path") ->
+ RenderVars = [{base_var, "base-barstring"}, {test_var, "test-barstring"}],
+ {ok, RenderVars};
+setup("extends_path") ->
+ RenderVars = [{base_var, "base-barstring"}, {test_var, "test-barstring"}],
+ {ok, RenderVars};
+
%%--------------------------------------------------------------------
%% Custom tags
%%--------------------------------------------------------------------

0 comments on commit 292951c

Please sign in to comment.