Permalink
Browse files

added possibility to name the module in a .yaws file

git-svn-id: https://erlyaws.svn.sourceforge.net/svnroot/erlyaws/trunk/yaws@858 9fbdc01b-0d2c-0410-bfb7-fb27d70d8b52
  • Loading branch information...
1 parent 2682b97 commit f6dbbc9020e0d1761c94156ff2b3ab6cc2603709 @klacke committed Mar 21, 2005
Showing with 51 additions and 21 deletions.
  1. +26 −13 src/yaws_compile.erl
  2. +1 −1 www/appmods.yaws
  3. +1 −1 www/configuration.yaws
  4. +19 −2 www/dynamic.yaws
  5. +1 −1 www/post.yaws
  6. +1 −1 www/ssi.yaws
  7. +1 −1 www/stream.yaws
  8. +1 −1 www/yman.yaws
View
@@ -95,17 +95,17 @@ compile_file(C, LineNo, Chars, init, NumChars, Ack, Errs) ->
?Debug("SKIP ~p~n", [Chars]),
L=length(Chars),
compile_file(C, LineNo+1, line(), init, NumChars-L, Ack, Errs);
- "<erl>" ++ _ -> %% first chunk is erl, skip whistespace
+ "<erl" ++ _ -> %% first chunk is erl, skip whistespace
compile_file(C, LineNo, Chars, html, NumChars, Ack, Errs);
_ ->
%% first chunk is html, keep whitespace
file_position_bof(),
compile_file(C,1,line(),html,0,[], Errs)
end;
-compile_file(C, LineNo, Chars = "<erl>" ++ _Tail, html, NumChars, Ack,Es) ->
+compile_file(C, LineNo, Chars = "<erl" ++ Tail, html, NumChars, Ack,Es) ->
?Debug("start erl:~p",[LineNo]),
- C2 = new_out_file(LineNo, C, C#comp.gc),
+ C2 = new_out_file(LineNo, C, Tail, C#comp.gc),
C3 = C2#comp{startline = LineNo},
L = length(Chars),
if
@@ -188,8 +188,8 @@ compile_file(C, LineNo, [], html, NumChars, Ack, Es) ->
compile_file(C, LineNo+1, line(), html, NumChars, Ack, Es);
compile_file(C, LineNo, Chars, html, NumChars, Ack,Es) ->
- case has_str(Chars, ["<erl>", "%%", "<verbatim>"]) of
- {ok, Skipped, "<erl>"++_ = Chars2} ->
+ case has_str(Chars, ["<erl", "%%", "<verbatim>"]) of
+ {ok, Skipped, "<erl"++_ = Chars2} ->
compile_file(C, LineNo, Chars2, html, NumChars+Skipped, Ack, Es);
{ok, Skipped, "<verbatim>"++_ = Chars2} ->
compile_file(C, LineNo, Chars2, html, NumChars+Skipped, Ack, Es);
@@ -251,15 +251,28 @@ is_exported(Fun, A, Mod) ->
end.
+new_out_file_name(Tail) ->
+ case Tail of
+ ">" ++ _ ->
+ Mnum = case catch gen_server:call(yaws_server, mnum) of
+ {'EXIT', _} ->
+ 1;
+ Other ->
+ Other
+ end,
+ [$m | integer_to_list(Mnum)];
+ _ ->
+ case string:tokens(Tail, " =>\r\n\"") of
+ ["module", Module] ->
+ Module
+ end
+ end.
+
+
+
%% this will generate 10 lines
-new_out_file(Line, C, GC) ->
- Mnum = case catch gen_server:call(yaws_server, mnum) of
- {'EXIT', _} ->
- 1;
- Other ->
- Other
- end,
- Module = [$m | integer_to_list(Mnum)],
+new_out_file(Line, C, Tail, GC) ->
+ Module = new_out_file_name(Tail),
OutFile = filename:join([yaws:tmp_dir(), "yaws", GC#gconf.id, Module ++ ".erl"]),
?Debug("Writing outout file~s~n", [OutFile]),
{ok, Out} = file:open(OutFile, [write]),
View
@@ -4,7 +4,7 @@
box(Str) ->
{'div',[{class,"box"}],
- {pre,[],Str}}.
+ {pre,[], yaws_api:htmlize(Str)}}.
tbox(T) ->
box(lists:flatten(io_lib:format("~p",[T]))).
View
@@ -3,7 +3,7 @@
box(Str) ->
{'div',[{class,"box"}],
- {pre,[],Str}}.
+ {pre,[], yaws_api:htmlize(Str)}}.
out(A) ->
View
@@ -4,7 +4,7 @@
box(Str) ->
{'div',[{class,"box"}],
- {pre,[],Str}}.
+ {pre, [], yaws_api:htmlize(Str)}}.
tbox(T) ->
box(lists:flatten(io_lib:format("~p",[T]))).
@@ -215,7 +215,24 @@ out(A) ->
ssi("ssi/dynamic.2"),
{p,[], "And some of the refered records are defined as:"},
- ssi("ssi/dynamic.3")]}]}].
+ ssi("ssi/dynamic.3"),
+
+ {p, [], "Each chunk of erlang code will be compiled into a separate module. "
+ "The module names are automatically generated. If we have functions inside the "
+ "erlang chunks that we want to call from other chunks or modules, it is possible "
+ " to explicitly name the modue that will be used as in: "},
+
+ box("
+ \<erl module=foobar>
+ out(A) ->
+ io:format('This is the foobar module',[]).
+
+ func() ->
+ i_am_exported_from_foobar.
+ \</erl>")
+
+
+ ]}]}].
View
@@ -3,7 +3,7 @@
box(Str) ->
{'div',[{class,"box"}],
- {pre,[],Str}}.
+ {pre,[], yaws_api:htmlize(Str)}}.
fpostvar(A, Key) ->
case postvar(A,"lang") of
View
@@ -4,7 +4,7 @@
box(Str) ->
{'div',[{class,"box"}],
- {pre,[],Str}}.
+ {pre,[],yaws_api:htmlize(Str)}}.
tbox(T) ->
box(lists:flatten(io_lib:format("~p",[T]))).
View
@@ -4,7 +4,7 @@
box(Str) ->
{'div',[{class,"box"}],
- {pre,[],Str}}.
+ {pre,[],yaws_api:htmlize(Str)}}.
tbox(T) ->
box(lists:flatten(io_lib:format("~p",[T]))).
View
@@ -3,7 +3,7 @@
prebox(Str) ->
{'div',[{class,"man"}],
- {pre,[], Str}}.
+ {pre,[], yaws_api:htmlize(Str)}}.
out(A) ->

0 comments on commit f6dbbc9

Please sign in to comment.