Permalink
Browse files

minor whitespace changes

  • Loading branch information...
1 parent 623742a commit d6ebbc6126ed221e7b19ab7d3d9f86332c66f865 @ericbmerritt ericbmerritt committed May 6, 2012
View
@@ -1,8 +1,8 @@
0.7
- changed format of compiled templates from string to binaries
-- API changes:
- render now returns a deeplist with mixed strings and binaries.
+- API changes:
+ render now returns a deeplist with mixed strings and binaries.
Works without problems in yaws
added render_str to return a string like render worked previously
added render_bin: returns a list of binaries
@@ -12,11 +12,11 @@
- added nested attribute references for all tokens (eg. foo.bar.baz)
- added sgte_dict module. Wraps the erlang dict module.
-- API: added rec_to_name_kv/2 Converts a record to a proplist
- to be used in the rendering phase. The result is
+- API: added rec_to_name_kv/2 Converts a record to a proplist
+ to be used in the rendering phase. The result is
{rec_name, [{field1, val1}, {field2, val2}, ...]}
-- API: added rec_to_kv/2 Converts a record to a proplist
- to be used in the rendering phase. The result is
+- API: added rec_to_kv/2 Converts a record to a proplist
+ to be used in the rendering phase. The result is
[{field1, val1}, {field2, val2}, ...]
- switch unit test to eunit
View
@@ -8,7 +8,7 @@ SHELL = /bin/sh
#tags command and options
TAG_CMD = etags
-TAG_FLAGS =
+TAG_FLAGS =
LIB_FILES = /usr/local/lib/erlang/lib/sg*/*.erl /usr/local/lib/erlang/lib/sg*/src/*.erl
View
@@ -44,7 +44,7 @@ AC_SUBST(LD_SHARED)
define(OUTPUT_FILES,
- include.mk)
+ include.mk)
AC_OUTPUT(OUTPUT_FILES,
[
View
@@ -41,7 +41,7 @@ APPSCRIPT = '$$vsn=shift; $$mods=""; while(@ARGV){ $$_=shift; s/^([A-Z].*)$$/\'\
../ebin/%.app: %.app.src ../vsn.mk Makefile
perl -e $(APPSCRIPT) "$(VSN)" $(MODULES) < $< > $@
-../ebin/%.appup: %.appup
+../ebin/%.appup: %.appup
cp $< $@
../ebin/%.$(EMULATOR): %.erl $(wildcard $(YAWSDIR)/lib/*/*/*.hrl)
View
@@ -1,10 +1,10 @@
@title sgte - A simple Erlang Template Engine
-@doc
-<p><em>sgte</em> is a library implementing a Template Engine.
+@doc
+<p><em>sgte</em> is a library implementing a Template Engine.
The template system is inspired on <a href="http://www.stringtemplate.org">String Template</a>
</p><p>
-The template source can be a string or binary or a filename.
+The template source can be a string or binary or a filename.
The use of the engine is as simple as (from the command line):
<pre>
> {ok, Compiled} = sgte:compile(TmplStr),
@@ -16,10 +16,10 @@ or:
> sgte:render(Compiled, Data).
</pre>
-When compile/1 or compile_file/1 are called, the template is "compiled"
+When compile/1 or compile_file/1 are called, the template is "compiled"
to an internal representation made of mixed binaries and erlang terms.
-Then one of the render functions (render, render_str, or render_bin)
+Then one of the render functions (render, render_str, or render_bin)
can be called passing the Data to be rendered in the template.
<ul>
<li>render/2 and render/3 returns a deep iolist() suitable e.g. to use in yaws</li>
@@ -32,13 +32,13 @@ the produced is easier to read.
</p>
<p>
Data can be a Dict or a proplist (e.g. [{attr1, Val1}, {attr2, Val2}])
-Values can be a simple value or a function/1. In this case the function is
+Values can be a simple value or a function/1. In this case the function is
called with Data as an argument.
</p>
<h3>Template Features</h3>
<h4>Attribute reference</h4>
-Attribute reference is written as:
+Attribute reference is written as:
<pre>
$name$
</pre> Here is an example:
@@ -72,7 +72,7 @@ $apply myFun aVar$
result of myFun(aVar). Otherwhise the result is the value of
myFun.
-<h4>Conditional evaluation</h4>
+<h4>Conditional evaluation</h4>
<pre>
$if title$
&lt;h1&gt;$title$&lt;/h1&gt;
@@ -87,7 +87,7 @@ if names is a list [{username, "foo"}, {username, "bar"}]
$map li names$
</pre>
map li template to names. Each element in names is passed to the template with name attr.
-If li is the template:
+If li is the template:
<pre>
&lt;li&gt;&lt;b&gt;$username$&lt;/b&gt;&lt;/li&gt;</pre>
We get the result:
@@ -115,7 +115,7 @@ $map:{&lt;li&gt;&lt;b&gt;$username$&lt;/b&gt;&lt;/li&gt;} names$
</pre>
<h4>Internationalization support using gettext</h4>
-Gettext is a package that can be found in <a href="http://jungerl.sourceforge.net/">jungerl</a>. It
+Gettext is a package that can be found in <a href="http://jungerl.sourceforge.net/">jungerl</a>. It
supports internationalization using the <a href="http://www.gnu.org/software/gettext/">GNU Gettext format</a>.
<pre>
$txt:{Hello World}$
View
@@ -1,11 +1,11 @@
-{application, sgte,
- [{description, "sgte - a simple Erlang template engine"},
- {vsn, "0.7.1"},
- {modules, [sgte,
- sgte_parse,
- sgte_render,
- sgte_gettext,
- sgte_dict]},
- {registered, []},
- {applications, [kernel, stdlib]}
- ]}.
+{application, sgte,
+ [{description, "sgte - a simple Erlang template engine"},
+ {vsn, "0.7.1"},
+ {modules, [sgte,
+ sgte_parse,
+ sgte_render,
+ sgte_gettext,
+ sgte_dict]},
+ {registered, []},
+ {applications, [kernel, stdlib]}
+ ]}.
View
@@ -25,12 +25,12 @@
-endif.
%% API
--export([compile/1,
+-export([compile/1,
compile/2,
- compile_file/1,
- compile_file/2,
- render/2,
- render/3,
+ compile_file/1,
+ compile_file/2,
+ render/2,
+ render/3,
render_str/2,
render_str/3,
render_bin/2,
@@ -57,7 +57,7 @@
%% @type compiled() = [char()|token()]
%% token() = tupe().
%%
-%% @doc Compiles the template string T and returns the compiled
+%% @doc Compiles the template string T and returns the compiled
%% template or an error.
%% @end
%%--------------------------------------------------------------------
@@ -73,7 +73,7 @@ compile(T) when is_list(T) ->
%% option() = {encoding, encoding()},
%% encoding() = latin1 | utf8 | {utf16,little} | {utf16,big} | {utf32,little} | {utf32,big}
%%
-%% @doc Compiles the template string T and returns the compiled
+%% @doc Compiles the template string T and returns the compiled
%% template or an error.
%% @end
%%--------------------------------------------------------------------
@@ -85,35 +85,35 @@ compile(T, [{encoding, InEncoding}]) when is_list(T) ->
%%--------------------------------------------------------------------
%% @spec compile_file(FileName) -> {ok, C::compiled()} | {error,Reason}
%%
-%% @doc Compiles the template file FileName and returns the compiled
+%% @doc Compiles the template file FileName and returns the compiled
%% template or an error.
%% @end
%%--------------------------------------------------------------------
compile_file(FileName) ->
case file:read_file(FileName) of
- {ok, Bin} ->
- compile(Bin);
- Err ->
- Err
+ {ok, Bin} ->
+ compile(Bin);
+ Err ->
+ Err
end.
%%--------------------------------------------------------------------
%% @spec compile_file(FileName, Options::options()) -> {ok, C::compiled()} | {error,Reason}
%%
-%% @doc Compiles the template file FileName and returns the compiled
+%% @doc Compiles the template file FileName and returns the compiled
%% template or an error.
%% @end
%%--------------------------------------------------------------------
compile_file(FileName, Options) ->
case file:read_file(FileName) of
- {ok, Bin} ->
- compile(Bin, Options);
- Err ->
- Err
+ {ok, Bin} ->
+ compile(Bin, Options);
+ Err ->
+ Err
end.
%%--------------------------------------------------------------------
-%% @spec render(C::compiled(),
-%% Data::data(),
+%% @spec render(C::compiled(),
+%% Data::data(),
%% Options::options()) -> string()
%%
%% @type data() = [tuple()]|dict()
@@ -173,7 +173,7 @@ render_bin(Compiled, Data) ->
%%
%% @type gettext_tuple() = {Key, LineNo}
%%
-%% @doc Extracts from template T the list of gettext keys
+%% @doc Extracts from template T the list of gettext keys
%% with associated line numbers.
%% This is a utility function to use in cojunction with gettext
%% to create initial .po files.
@@ -183,16 +183,16 @@ gettext_strings(Template) when is_binary(Template) ->
sgte_parse:gettext_strings(unicode:characters_to_list(Template));
gettext_strings(FileName) ->
case file:read_file(FileName) of
- {ok, Bin} ->
- gettext_strings(Bin);
- Err ->
- Err
+ {ok, Bin} ->
+ gettext_strings(Bin);
+ Err ->
+ Err
end.
%%--------------------------------------------------------------------
%% @spec gettext_strings(T::template(), {encoding, Enc::encoding}) -> [gettext_tuple()]
%%
-%% @doc Extracts from template T the list of gettext keys
+%% @doc Extracts from template T the list of gettext keys
%% with associated line numbers.
%% This is a utility function to use in cojunction with gettext
%% to create initial .po files.
@@ -202,10 +202,10 @@ gettext_strings(Template, Enc) when is_binary(Template) ->
sgte_parse:gettext_strings(unicode:characters_to_list(Template, Enc));
gettext_strings(FileName, Enc) ->
case file:read_file(FileName) of
- {ok, Bin} ->
- gettext_strings(Bin, Enc);
- Err ->
- Err
+ {ok, Bin} ->
+ gettext_strings(Bin, Enc);
+ Err ->
+ Err
end.
%%--------------------------------------------------------------------
@@ -214,9 +214,9 @@ gettext_strings(FileName, Enc) ->
%%
%% @type src_files() = [string()]. Source files to parse for gettext strings.
%%
-%% @doc Creates the gettext template file (.pot).
-%% SrcFiles is the list of files to be parsed for gettext strings.
-%% Each gettext string found will be written to the .pot file.
+%% @doc Creates the gettext template file (.pot).
+%% SrcFiles is the list of files to be parsed for gettext strings.
+%% Each gettext string found will be written to the .pot file.
%% The default name of the generated file will be messages.pot.
%% @end
%%--------------------------------------------------------------------
@@ -225,37 +225,37 @@ gettext_init(SrcFiles) ->
sgte_gettext:gettext_init(TargetDir, SrcFiles, "messages.pot").
%%--------------------------------------------------------------------
-%% @spec gettext_init(TargetDir::target_dir(),
-%% SrcFiles::src_files()) ->
+%% @spec gettext_init(TargetDir::target_dir(),
+%% SrcFiles::src_files()) ->
%% ok | {error, Reason}
%%
%% @type target_dir() = string(). Dir where the .pot file will be written
%%
-%% @doc Creates the gettext template file (.pot).
-%% TargetDir is the directory where the file will be created.
-%% If TargetDir doesn't exists it will be created.
-%% SrcFiles is the list of files to be parsed for gettext strings.
-%% Each gettext string found will be written to the .pot file.
+%% @doc Creates the gettext template file (.pot).
+%% TargetDir is the directory where the file will be created.
+%% If TargetDir doesn't exists it will be created.
+%% SrcFiles is the list of files to be parsed for gettext strings.
+%% Each gettext string found will be written to the .pot file.
%% The file name of the generated file will be messages.pot.
%% @end
%%--------------------------------------------------------------------
gettext_init(TargetDir, SrcFiles) ->
sgte_gettext:gettext_init(TargetDir, SrcFiles, "messages.pot").
%%--------------------------------------------------------------------
-%% @spec gettext_init(TargetDir::target_dir(),
-%% SrcFiles::src_files(),
-%% Domain::domain()) ->
+%% @spec gettext_init(TargetDir::target_dir(),
+%% SrcFiles::src_files(),
+%% Domain::domain()) ->
%% ok | {error, Reason}
%%
%% @type domain() = string(). The name of the .po file to write.
%%
-%% @doc Creates the gettext template file (.pot).
-%% TargetDir is the directory where the file will be created.
-%% If TargetDir doesn't exists it will be created.
-%% SrcFiles is the list of files to be parsed for gettext strings.
-%% Each gettext string found will be written to the .pot file.
-%% Domain (when present) is the name of the file to generate.
+%% @doc Creates the gettext template file (.pot).
+%% TargetDir is the directory where the file will be created.
+%% If TargetDir doesn't exists it will be created.
+%% SrcFiles is the list of files to be parsed for gettext strings.
+%% Each gettext string found will be written to the .pot file.
+%% Domain (when present) is the name of the file to generate.
%% If no Domain is defined the default name will be messages.pot.
%% @end
%%--------------------------------------------------------------------
View
@@ -15,11 +15,11 @@
%%% srl. Portions created by S.G. Consulting s.r.l. are Copyright (C)
%%% 2007 S.G. Consulting srl. All Rights Reserved.
%%%
-%%% @doc
-%%% <p>Implements a dictionary and a record like data structure.
+%%% @doc
+%%% <p>Implements a dictionary and a record like data structure.
%%% Uses the dict module and extends it to support nested dicts.</p>
%%%
-%%% <p>This module is the interface used to access data in the
+%%% <p>This module is the interface used to access data in the
%%% render phase.</p>
%%% @end
%%%
@@ -37,10 +37,10 @@
rfoldl/2,
rfoldr/2,
rappend/3,
- find/2,
- store/3,
- merge/3,
- from_list/1,
+ find/2,
+ store/3,
+ merge/3,
+ from_list/1,
rec_to_name_kv/2,
rec_to_kv/2]).
@@ -149,7 +149,7 @@ rec_to_name_kv(RecordTuple, Keys) ->
{error, too_much_keys}
end
end.
-
+
rec_to_kv(RecordTuple, Keys) ->
[_Name|Values] = tuple_to_list(RecordTuple),
case length(Values) =:= length(Keys) of
Oops, something went wrong.

0 comments on commit d6ebbc6

Please sign in to comment.