Erlang/OTP Forums

Author Message

<  Advanced Erlang/OTP  ~  JSP-like rebuild of source files prior to page impressions..

seancharles
Posted: Sat Jan 05, 2008 6:23 pm Reply with quote
User Joined: 18 Jul 2007 Posts: 57
A while back I posted a somewhat lengthy hack on how to make emacs talk to yaws and (with some code) make it compile and load a module when you saved it in emacs so that web development was 'easier' with Erlang and yaws.

However, I have had more time to see that Erlang does actually come with the kitchen sink and I have now replaced *all that code* with this code:
Code:
%% This is for DEVELOPMENT ONLY!  It allows developers to edit files
%% and just refresh the web browser page, just like any other script
%% based development environment.

update_modules() ->
    Sources = filelib:fold_files(
      "/Users/seancharles/Projects/foobar",
      ".*\..erl$",
      true,
      fun(F,Acc) -> [F|Acc] end,
      []),
    make:files(
      Sources,
      [debug_info, load]).

In my central controller module, I call update_modules() before actually processing the latest page request... for development it is perfect as I can use *ANY EDITOR* I like now, not just emacs, and the make system rebuilds anything I just saved before dishing out the page.

Try it, I can't believe I got this far without this bit of code! In my .erlang startup file I also have the same code 'in-lined' so that the system is totally up to date before it runs.

Party on, 2008 is going to be a kick-ass Erlang powered mega-year, at least for me anyway!

Yeeeeeeeeeeeeeeeeeehaaaaaaaaaaa!
Smile
->Sean Charles

PS: Is there *anything at all* missing from Erlang and and it's toolset ? It's PERFECT I tell you!
View user's profile Send private message

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum