Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: asonge/erlydtl
base: master
...
head fork: devinus/erlydtl
compare: master
Checking mergeability… Don’t worry, you can still create the pull request.
  • 1 commit
  • 24 files changed
  • 0 commit comments
  • 1 contributor
Commits on Apr 08, 2010
Devin Torres Inline compressed JS tags 36c6a1e
View
BIN  .DS_Store
Binary file not shown
View
BIN  bin/yuicompressor.jar
Binary file not shown
View
21 ebin/erlydtl.app
@@ -0,0 +1,21 @@
+%% -*- mode: erlang -*-
+{application, erlydtl,
+ [{description, "ErlyDTL implements most but not all of the Django Template Language"},
+ {vsn, "0.5.3"},
+ {modules, [
+ erlydtl,
+ erlydtl_compiler,
+ erlydtl_dateformat,
+ erlydtl_dateformat_tests,
+ erlydtl_deps,
+ erlydtl_example_variable_storage,
+ erlydtl_filters,
+ erlydtl_functional_tests,
+ erlydtl_parser,
+ erlydtl_runtime,
+ erlydtl_scanner,
+ erlydtl_unittests
+ ]},
+ {applications, [kernel, stdlib]},
+ {registered, []}
+ ]}.
View
BIN  ebin/erlydtl.beam
Binary file not shown
View
BIN  ebin/erlydtl_compiler.beam
Binary file not shown
View
BIN  ebin/erlydtl_dateformat.beam
Binary file not shown
View
BIN  ebin/erlydtl_dateformat_tests.beam
Binary file not shown
View
BIN  ebin/erlydtl_deps.beam
Binary file not shown
View
BIN  ebin/erlydtl_example_variable_storage.beam
Binary file not shown
View
BIN  ebin/erlydtl_filters.beam
Binary file not shown
View
BIN  ebin/erlydtl_functional_tests.beam
Binary file not shown
View
BIN  ebin/erlydtl_parser.beam
Binary file not shown
View
BIN  ebin/erlydtl_runtime.beam
Binary file not shown
View
BIN  ebin/erlydtl_scanner.beam
Binary file not shown
View
BIN  ebin/erlydtl_static_compiler.beam
Binary file not shown
View
BIN  ebin/erlydtl_unittests.beam
Binary file not shown
View
6,078 examples/docroot/jquery.js
6,078 additions, 0 deletions not shown
View
1  examples/docroot/js
@@ -0,0 +1 @@
+{% js "jquery.js" %}
View
29 src/erlydtl/erlydtl_compiler.erl
@@ -51,7 +51,10 @@
reader = {file, read_file},
module = [],
compiler_options = [verbose, report_errors],
- force_recompile = false}).
+ force_recompile = false,
+ js_dir = "",
+ js_compile_enabled = false,
+ js_compile_command = undefined}).
-record(ast_info, {
dependencies = [],
@@ -148,7 +151,10 @@ init_dtl_context(File, Module, Options) ->
vars = proplists:get_value(vars, Options, Ctx#dtl_context.vars),
reader = proplists:get_value(reader, Options, Ctx#dtl_context.reader),
compiler_options = proplists:get_value(compiler_options, Options, Ctx#dtl_context.compiler_options),
- force_recompile = proplists:get_value(force_recompile, Options, Ctx#dtl_context.force_recompile)}.
+ force_recompile = proplists:get_value(force_recompile, Options, Ctx#dtl_context.force_recompile),
+ js_dir = proplists:get_value(js_dir, Options, filename:dirname(File)),
+ js_compile_enabled = proplists:get_value(js_compile_enabled, Options, Ctx#dtl_context.js_compile_enabled),
+ js_compile_command = proplists:get_value(js_compile_command, Options, Ctx#dtl_context.js_compile_command)}.
is_up_to_date(_, #dtl_context{force_recompile = true}) ->
@@ -383,7 +389,9 @@ body_ast(DjangoParseTree, Context, TreeWalker) ->
({'cycle', Names}, TreeWalkerAcc) ->
cycle_ast(Names, Context, TreeWalkerAcc);
({'cycle_compat', Names}, TreeWalkerAcc) ->
- cycle_compat_ast(Names, Context, TreeWalkerAcc)
+ cycle_compat_ast(Names, Context, TreeWalkerAcc);
+ ({'js', FileList}, TreeWalkerAcc) ->
+ js_ast(FileList, Context, TreeWalkerAcc)
end, TreeWalker, DjangoParseTree),
{AstList, {Info, TreeWalker3}} = lists:mapfoldl(
fun({Ast, Info}, {InfoAcc, TreeWalkerAcc}) ->
@@ -407,7 +415,8 @@ body_ast(DjangoParseTree, Context, TreeWalker) ->
PreRenderAst = erl_syntax:function(erl_syntax:atom(Name),
[erl_syntax:clause([erl_syntax:variable("Variables")], none, [Ast])]),
PreRenderAsts = Info#ast_info.pre_render_asts,
- Info1 = Info#ast_info{pre_render_asts = [PreRenderAst | PreRenderAsts]},
+ io:format("PresetVars: ~p~n", [PresetVars]),
+ Info1 = Info#ast_info{pre_render_asts = [PreRenderAst | PreRenderAsts]},
{Ast1, {merge_info(Info1, InfoAcc), TreeWalkerAcc#treewalker{counter = Counter + 1}}}
end
end, {#ast_info{}, TreeWalker2}, AstInfoList),
@@ -685,6 +694,18 @@ now_ast(FormatString, _Context, TreeWalker) ->
[erl_syntax:string(UnescapeOuter)]),
#ast_info{}}, TreeWalker}.
+js_ast(FileList, Context, TreeWalker) ->
+ Files = [unescape_string_literal(F) || {string_literal, _, F} <- FileList],
+ FilesAst = erl_syntax:list([erl_syntax:string(L) || L <- Files]),
+ DirAst = erl_syntax:string(Context#dtl_context.js_dir),
+ CmdAst = erl_syntax:string(Context#dtl_context.js_compile_command),
+ EnabledAst = erl_syntax:atom(Context#dtl_context.js_compile_enabled),
+ Ast = erl_syntax:application(
+ erl_syntax:atom(erlydtl_static_compiler),
+ erl_syntax:atom(compile_js),
+ [FilesAst, DirAst, CmdAst, EnabledAst]),
+ {{Ast, #ast_info{}}, TreeWalker}.
+
unescape_string_literal(String) ->
unescape_string_literal(string:strip(String, both, 34), [], noslash).
View
2,865 src/erlydtl/erlydtl_parser.erl
2,865 additions, 0 deletions not shown
View
15 src/erlydtl/erlydtl_parser.yrl
@@ -87,7 +87,7 @@ Nonterminals
Value
Variable
Filter
-
+
LoadTag
LoadNames
@@ -95,7 +95,10 @@ Nonterminals
Args
CallTag
- CallWithTag.
+ CallWithTag
+
+ JsTag
+ JsFiles.
Terminals
autoescape_keyword
@@ -135,7 +138,8 @@ Terminals
pipe
string_literal
text
- with_keyword.
+ with_keyword
+ js_keyword.
Rootsymbol
Elements.
@@ -159,6 +163,7 @@ Elements -> Elements CommentBlock : '$1' ++ ['$2'].
Elements -> Elements CustomTag : '$1' ++ ['$2'].
Elements -> Elements CallTag : '$1' ++ ['$2'].
Elements -> Elements CallWithTag : '$1' ++ ['$2'].
+Elements -> Elements JsTag : '$1' ++ ['$2'].
ValueBraced -> open_var Value close_var : '$2'.
@@ -245,3 +250,7 @@ Args -> Args identifier equal Value : '$1' ++ [{'$2', '$4'}].
CallTag -> open_tag call_keyword identifier close_tag : {call, '$3'}.
CallWithTag -> open_tag call_keyword identifier with_keyword Value close_tag : {call, '$3', '$5'}.
+
+JsTag -> open_tag js_keyword JsFiles close_tag : {js, '$3'}.
+JsFiles -> string_literal : ['$1'].
+JsFiles -> JsFiles string_literal : '$1' ++ ['$2'].
View
2  src/erlydtl/erlydtl_scanner.erl
@@ -62,7 +62,7 @@ scan([], Scanned, _, in_text) ->
"not", "or", "and", "comment", "endcomment", "cycle", "firstof",
"ifchanged", "ifequal", "endifequal", "ifnotequal", "endifnotequal",
"now", "regroup", "spaceless", "endspaceless", "ssi", "templatetag",
- "load", "call", "with"],
+ "load", "call", "with", "js"],
Type = case lists:member(RevString, Keywords) of
true ->
list_to_atom(RevString ++ "_keyword");
View
16 src/erlydtl/erlydtl_static_compiler.erl
@@ -0,0 +1,16 @@
+-module(erlydtl_static_compiler).
+
+-export([compile_js/4]).
+
+compile_js(Files, Dir, CompileCmd, _Enabled) ->
+ io:format("compile_js", []),
+ CompressedJs = case CompileCmd of
+ undefined -> <<>>;
+ Cmd -> os:cmd(io_lib:format(Cmd, [string:join([filename:join(Dir, F) || F <- Files], " ")]))
+ end,
+ Output = list_to_binary([
+ <<"<script type=\"text/javascript\"><!--">>, $\n,
+ CompressedJs, $\n,
+ <<"--></script>">>
+ ]),
+ Output.
View
2  src/tests/erlydtl_functional_tests.erl
@@ -47,7 +47,7 @@ test_list() ->
"var", "var_preset", "var_error", "cycle", "custom_tag",
"custom_tag_error", "custom_call",
"include_template", "include_path",
- "extends_path", "extends_path2" ].
+ "extends_path", "extends_path2", "js"].
setup_compile("for_list_preset") ->
CompileVars = [{fruit_list, [["apple", "apples"], ["banana", "bananas"], ["coconut", "coconuts"]]}],

No commit comments for this range

Something went wrong with that request. Please try again.