Permalink
Browse files

Restructure compiler code (close #136)

The common infrastructure routines are left in erlydtl_compiler,
while those specific for compiling to .beam files are moved into
erlydtl_beam_compiler and generic stuff is put in erlydtl_compiler_utils.
  • Loading branch information...
1 parent eba8043 commit 26b6a793e12fbe68afc37365298dd60a8e608876 @kaos kaos committed Feb 24, 2014
View
@@ -54,3 +54,7 @@
pos={1,1},
state=in_text
}).
+
+
+-define(ERR(Err, Ctx), erlydtl_compiler_utils:add_error(?MODULE, Err, Ctx)).
+-define(WARN(Warn, Ctx), erlydtl_compiler_utils:add_warning(?MODULE, Warn, Ctx)).
View
@@ -2,14 +2,17 @@
%%% File: erlydtl.erl
%%% @author Roberto Saccon <rsaccon@gmail.com> [http://rsaccon.com]
%%% @author Evan Miller <emmiller@gmail.com>
+%%% @author Andreas Stenius <kaos@astekk.se>
%%% @copyright 2008 Roberto Saccon, Evan Miller
+%%% @copyright 2014 Andreas Stenius
%%% @doc
%%% Public interface for ErlyDTL
%%% @end
%%%
%%% The MIT License
%%%
%%% Copyright (c) 2008 Roberto Saccon, Evan Miller
+%%% Copyright (c) 2014 Andreas Stenius
%%%
%%% Permission is hereby granted, free of charge, to any person obtaining a copy
%%% of this software and associated documentation files (the "Software"), to deal
@@ -30,12 +33,18 @@
%%% THE SOFTWARE.
%%%
%%% @since 2007-11-11 by Roberto Saccon, Evan Miller
+%%% @since 2014 by Andreas Stenius
%%%-------------------------------------------------------------------
-module(erlydtl).
-author('rsaccon@gmail.com').
-author('emmiller@gmail.com').
+-author('Andreas Stenius <kaos@astekk.se>').
+
+%% --------------------------------------------------------------------
%% API
+%% --------------------------------------------------------------------
+
-export([compile_file/2, compile_file/3]).
-export([compile_template/2, compile_template/3]).
-export([compile/2, compile/3]).
@@ -50,6 +59,11 @@
-type ok_ret() :: {ok, Module::atom()} | {ok, Module::atom(), warnings()}.
-type err_ret() :: error | {error, errors(), warnings()}.
+
+%% --------------------------------------------------------------------
+%% Compile file
+%% --------------------------------------------------------------------
+
-spec compile_file( list() | binary(), atom() ) -> {ok, Module::atom()} | error.
compile_file(File, Module) ->
erlydtl_compiler:compile_file(File, Module, erlydtl_compiler:default_options()).
@@ -58,6 +72,11 @@ compile_file(File, Module) ->
compile_file(File, Module, Options) ->
erlydtl_compiler:compile_file(File, Module, Options).
+
+%% --------------------------------------------------------------------
+%% Compile template
+%% --------------------------------------------------------------------
+
-spec compile_template( list() | binary(), atom() ) -> {ok, Module::atom()} | error.
compile_template(Template, Module) ->
erlydtl_compiler:compile_template(Template, Module, erlydtl_compiler:default_options()).
@@ -66,6 +85,11 @@ compile_template(Template, Module) ->
compile_template(Template, Module, Options) ->
erlydtl_compiler:compile_template(Template, Module, Options).
+
+%% --------------------------------------------------------------------
+%% Compile directory
+%% --------------------------------------------------------------------
+
-spec compile_dir(list() | binary(), atom()) -> {ok, Module::atom()} | error.
compile_dir(DirectoryPath, Module) ->
erlydtl_compiler:compile_dir(DirectoryPath, Module, erlydtl_compiler:default_options()).
@@ -75,6 +99,10 @@ compile_dir(DirectoryPath, Module, Options) ->
erlydtl_compiler:compile_dir(DirectoryPath, Module, Options).
+%% --------------------------------------------------------------------
+%% Legacy API
+%% --------------------------------------------------------------------
+
%% keep for backwards compatibility, with a tuple-twist to ease migration / offer alternative path..
-spec compile(FileOrBinary, atom() ) -> {ok, Module::atom()} | error
when FileOrBinary :: list() | binary()
Oops, something went wrong.

0 comments on commit 26b6a79

Please sign in to comment.