Packages
template_compiler
1.5.0
3.6.0
3.5.0
3.4.1
3.4.0
3.3.0
3.2.0
3.1.0
3.0.0
2.14.0
2.13.2
2.13.1
2.13.0
2.12.0
2.11.0
2.10.1
2.10.0
2.9.0
2.8.1
2.8.0
2.7.0
2.6.0
2.5.0
2.4.0
2.3.1
2.3.0
2.2.0
2.1.1
2.1.0
2.0.0
1.6.0
1.5.1
1.5.0
1.4.0
1.3.3
1.3.2
1.3.1
1.3.0
1.2.0
1.1.0
1.0.2
1.0.1
1.0.0
1.0.0-alpha8
1.0.0-alpha7
1.0.0-alpha6
1.0.0-alpha5
1.0.0-alpha4
1.0.0-alpha3
1.0.0-alpha2
Zotonic Template Compiler
Current section
Files
Jump to
Current section
Files
src/template_compiler_internal.hrl
%% @author Marc Worrell <marc@worrell.nl>
%% @copyright 2016 Marc Worrell
%% @doc Template compiler internal definitions.
%% Copyright 2016 Marc Worrell
%%
%% Licensed under the Apache License, Version 2.0 (the "License");
%% you may not use this file except in compliance with the License.
%% You may obtain a copy of the License at
%%
%% http://www.apache.org/licenses/LICENSE-2.0
%%
%% Unless required by applicable law or agreed to in writing, software
%% distributed under the License is distributed on an "AS IS" BASIS,
%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
%% See the License for the specific language governing permissions and
%% limitations under the License.
%% @doc Increment this with compiler bug fixes
-define(COMPILER_VERSION, 1).
-type linecol() :: {Line::integer(), Column::integer(), file:filename_all()}.
-type token() :: {atom(), linecol(), term()}
| identifier_token().
-type identifier_token() :: {identifier, linecol(), binary()}.
-type block_element() :: {block, identifier_token(), elements()}.
-type elements() :: list( element() ).
-type element() :: block_element()
| true
| false
| undefined
| term().
%% @doc Treewalk state. Has counter for variable names and flags if the forloop, unique-var,
%% and/or includes with inherited arguments are used inside a code block.
-record(ws, {
nr = 1 :: integer(),
custom_tags = [],
is_forloop_var = false :: boolean(),
is_autoid_var = false :: boolean()
}).
%% @doc State for the compiler. Also records the current block's arguments variable, and context variable.
-record(cs, {
filename = <<>> :: binary(),
module = undefined :: atom(),
block = undefined :: atom(),
blocks = [] :: list( {atom(), erl_syntax:syntaxTree(), #ws{}} ),
runtime = template_compiler_runtime :: atom(),
context = undefined :: term(),
vars_var = "Vars" :: string(),
context_var = "Context" :: string(),
context_vars = [] :: list(binary()),
is_autoescape = false :: boolean()
}).
-ifdef(fun_stacktrace).
-define(WITH_STACKTRACE(T, R, S), T:R -> S = erlang:get_stacktrace(),).
-else.
-define(WITH_STACKTRACE(T, R, S), T:R:S ->).
-endif.