Jaws - coming soon - testers and advice wanted

bryan rasmussen rasmussen.bryan@REDACTED
Mon Feb 20 10:44:54 CET 2006


I might be able to do testing, dependent on figuring out my schedule
which for the next 4 months is pretty hairy.

A propos the javascript: http://mcc.id.au/xpathjs/
xpath in javascript.

So perhaps it would be able to run an xpath, assuming that one gave
the a element an id :

//div[a[@id='myid']]

Cheers,
Bryan Rasmussen





On 2/20/06, Joe Armstrong (AL/EAB) <joe.armstrong@REDACTED> wrote:
>
> Hello,
>
> Progress report - jaws (yaws + templates) is progressing nicely.
> I have finally "made up my mind" (TM) and decided on a template syntax
> (two years thought and half a dozen prototypes "down the drain") -
> a compiler for this syntax has now been up and running for a few weeks
> and I am finalising the Ajax support.
>
> jaws is a template language for yaws (jaws is inspired by PHP, velocity
> and AJAX)
> - this posting contains a "first look" at the syntax. I'm not going to
> describe the semantics - you have to *guess* - it's rather easy.
> (Hints all webpages and templates get compiled to single functions)
>
> A *single* jaws file contains templates for *many* webpages - so that an
> entire application can be shipped as a single file.
>
> Here's a simple example, assumed to be in the file foo.jaws
>
>      @module foo
>
>        @webPage test(_)
>        <? N = 25, "" ?>
>
>        <P>factorial <? N ?> is <? fac(N) ?>
>
>        @erl
>        fac(0) -> 1;
>        fac(N) -> N * fac(N-1).
>
>        @webPage form(A)
>        <form method="post" action="./foo.jaws?page=posted">
>       <input name="fac" size="20">
>        </form>
>
>        @webPage posted(A)
>        <? {ok, X} = yaws_api:postvar(A, "fac"),
>         N = list_to_integer(N), "" ?>
>
>      <? banner([{"name","joe"},{"likes", "Erlang"}]) ?>
>
>        <p>Fac <? N ?> is <? red(fac(N)) ?>
>
>        @template red(X)
>        <font color="red"><? X ?></font>
>
>        @template banner(X)
>
>        <p>Hello ${name:X} i hear you like ${likes:X}
>
>      @webPage ajax(A)
>        <div id="tag1">
>        ...
>        </div>
>
>        <a href='javascript:erlcall'("foo", "myfunc", "")'>update</a>
>
>        @webPage myfunc(A)
>
>        myfunc(Args) ->
>           [replace_contents("tag1", "<h1>Hi .... "].
>
>        @webPage redirect(A)
>        <? Headers = [{"redirect", "http:// ..."}], "" ?>
>
>        <h1> You'll soon be redirected.
>
> This defines eight webpages and two templates in one jaws file. It
> gives examples of
>
>        - template expansion
>        - form handling
>        - ajax
>        - header manipulation (in the redirect example)
>
> << computationally <? fac(N) ?> is about 10-20 times faster than PHP
> and it works for bignums :-) >>
>
> It seems to me to be desirable to have the code which handles a form
> *immediately after the code which defines the form* (and not in another
> file) - it also seems desirable to be able to program HTML with
> subroutines, like this:
>
>        @webPage foo(A)
>
>        Some html <? fancy_box(A) ?>
>        ... <? fancy_box(B) ?> ...
>
>        @template fancy_box(A)
>        <table> .... <? A ?> ... </table>
>
> Note also how the site of ajax call is lexically near to the code which
> handles the call.
>
> javascript:erlcall(M, F, A) allows javascript to call an arbitary Erlang
> {M,F,A}
> This is achieved with ajax and a JSON encoding. MFA returns a list
> of actions that are to be performed on the webpage - ie
> (replace_contents("tag1" , HTML))
> sets the innerHTML field of tag1 to HTML.
>
> At this stage I need two things:
>        1) Testers - a few good people who are interested in this kind
> of
>           stuff
>        2) javascript help - the result of myfunc(Args) is a list of
> actions to be
>           performed on a web page. A typical example is
>
>           replace_contents(Tag, Html)
>
>           When this is called in Erlang a JSON encoded term is sent
> back to the
> web page and after a little trickery
>
>        jsReplaceContents(tag, html) is called
>
> where
>
>        function jsReplaceContents(tag, html) {
>                document.getElementById(tag).innerHTML = html;
>        }
>
> I have defined a few simple functions (replace_contents(tag, HTML),
> delete_tag(Tag) etc.
>
> But I am really stretching my knowledge of javascript here.
>
> If any javascript guru wants to help please contact me.
>
> In particular does anybody have any ideas how to do this?
>
> If I have this
>
>         <div id="foo">
>          ....
>          ...  <a href="javascript:bar()">click</a>
>
>         </div>
>
>  I want bar() to compute the id if the nearest containing div - in this
> case "foo" any ideas how to do this? - do I really have to "walk the
> tree" from the root of the DOM tree?
>
> /Joe
>



More information about the erlang-questions mailing list