amrita 0.8.1 
Author Message
 amrita 0.8.1

Amrita is a a html/xhtml template library for Ruby.
It makes html documents from a template and a model data.

Key feature

* The template for amrita is a pure html/xhtml document without
  special tags like <?...?> or <% .. %>

* The template can be written by designers using almost any HTML
  Editor.

* Need no change on Ruby code to change the view of ((*dynamic*)) part
  (not only static part) of the template

* The model data may be standard Ruby data, Hash, Array, String... or
  an instance of a classes you made.

* The output is controlled by ((*data*)) no by logic. So It's easy to
  write, test, debug code. (Good for eXtreamPrograming)

* HTML template can be compiled into Ruby code before execution
  with a little effort.

Amrita mixes a template and model data up to a html document naturally
matching the +id+ attribute of HTML element to model data.

For detail see http://www.*-*-*.com/

--



Tue, 04 Jan 2005 10:31:30 GMT  
 amrita 0.8.1

Quote:

> Amrita is a a html/xhtml template library for Ruby.
> It makes html documents from a template and a model data.

very nice work. i thiink this is the best looking html/xhtml template
system i've seen so far. few questions:

1. can dummy data be used in the template itself for designer purposes?

2. how does it far with xml itself? (if no, would you add that support?)

3. and finally, how fast is it?

i had stared my own xml/html/xhtml template system myself based on
zope's tals, call xmlTails, though i got it to work it used eval a lot,
which i didn't like and it was exceedly slow. with Amrita i think i can
happily dump that into my trash can. yes?

--
~transami

  _(")_  dobee dobee do...
   \v/  
   ^ ^



Tue, 04 Jan 2005 12:41:33 GMT  
 amrita 0.8.1

Quote:

> Amrita is a a html/xhtml template library for Ruby.
> It makes html documents from a template and a model data.

This is a really cool, clean approach - I very much like being able to
see the skeleton of the page without looking at the template (most
templating systems require starting by reading the template and
piecing everything together from there).

To throw out a couple of thoughts:

- It would be cool during development to have the template completely
inferred from the data; obviously it would have to make some arbitrary
choices (lists vs. tables, anchors vs. buttons) but it would probably
be good enough to get a prototype up for simple sites.

- If I were using it, I'd want to mix callbacks in for form elements
and links, so that you could do, say,

i = 0
data = {"count" => i,
        "increment" => callback{i += 1},
        "decrement" => callback{i -= 1}}

and then have a template like

<h1 id="count">
<a id="increment">++</a> <a id="decrement">--</a>

and have it do the obvious thing.  Obviously this requires a lot more
infrastructure than just Amrita, but it's completely doable.

Avi



Tue, 04 Jan 2005 15:45:57 GMT  
 amrita 0.8.1
On Fri, Jul 19, 2002 at 01:36:52PM +0900,

Quote:


> > Amrita is a a html/xhtml template library for Ruby.
> > It makes html documents from a template and a model data.

> very nice work. i thiink this is the best looking html/xhtml template
> system i've seen so far. few questions:

Thnak you.

Quote:
> 1. can dummy data be used in the template itself for designer purposes?

Yes, dummy data will be deleted in real use.

    tmpl = TemplateText.new "<p id=xyz>This is dummy data</p>"
    data = {  :xyz => "This is real data" }
    tmpl.expand(STDOUT, data) # =><p>This is real data</p>

Quote:
> 2. how does it far with xml itself? (if no, would you add that support?)

I think it can be used with xml right now.

Html dependent parts are

   * parser will add omitted tags for html

     but it doese not matter for well-formed xml/xhtml

   * parser will generate special data for <pre>.....</pre>

     I think I can provide a flag to avoid this feature if you need.

   * pretty printer uses html tag info (see lib/amrita/format.rb:227)

     but you can avoid this feature not setting prettypring flag or
     provide tag info yourself fit to your DTD.

Quote:
> 3. and finally, how fast is it?

It's slow but has pre-compiled mode. In pre-compiled mode, it runs as
fast as a standard ruby script like

    STDOUT << "<html>........"
    STDOUT << "<ul>"
    some_array.each do |x|
      STDOUT << "<li>"> << x
    end
    .....

see sample/tour/precompile.rb and docs/Tour:177 for detail.

--
Taku Nakajima



Tue, 04 Jan 2005 15:59:53 GMT  
 amrita 0.8.1

Quote:
> This is a really cool, clean approach (...)

Doesn't Iowa have a similar approach? How would you compare
both?

Regards,
Pit



Tue, 04 Jan 2005 16:25:53 GMT  
 amrita 0.8.1

Quote:


> > This is a really cool, clean approach (...)

> Doesn't Iowa have a similar approach? How would you compare
> both?

Similar, yes, although a comparison is difficult because Iowa is
bidirectional (data goes from your model out to the template, through
an HTTP response/request cycle, and the back to your model), which
complicates things a lot.

The two main differences in terms of templating are that Iowa's
bindings are a flat namespace whereas Amrita uses hierarchy, and that
Iowa has a lot of back and forth interaction between the template and
the model, whereas Amrita takes a more pipelined approach - once the
data tree is built, that's all the template refers to.  This
simplifies iteration logic in particular.

What would be interesting to me would be an Amrita like system that
introduced Iowa's bidirectionality by storing blocks inside the data
tree.  Particularly if combined with call/cc based session management.



Wed, 05 Jan 2005 05:34:00 GMT  
 amrita 0.8.1

Quote:

> What would be interesting to me would be an Amrita like system that
> introduced Iowa's bidirectionality by storing blocks inside the data
> tree.  Particularly if combined with call/cc based session management.

not sure if i follow you here exactly, but i've been trying to do
something similiar with object <-> gui communication. in fact after
reading you plug for amrita i was surprised by the coorelations, the
distinction being only that Amrita goes one direction, where i was
trying to go back again.

i have yet to succeed in this endeavor. i have come to realize that
there is much more to the whole thing then i initially thought, but i
will keep tinkering away at it. perhaps eventually i have something
useable. (in the mean time, i've switched to rebol for gui front ends.
oh well.)

~transami

  _(")_  dobee dobee do...
   \v/  
   ^ ^



Wed, 05 Jan 2005 11:28:10 GMT  
 amrita 0.8.1

Quote:
> (Comparison between bidirectional Iowa and pipelined Amrita
> and ideas for a combination of both)

Thanks a lot.
Pit


Wed, 05 Jan 2005 21:20:29 GMT  
 amrita 0.8.1
Hi:

I downloaded amrita (stable version) and ran
 make test_it

and got several errors. Did I do something wrong or get the
incorrect version?

Thanks

Jim

 make test_it
(cd test; ruby -I../lib testall.rb)
E.E..E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E..E.E.E.F.......................E.....E.........
Time: 0.654986
FAILURES!!!
Test Results:
 Run: 82/82(158 asserts) Failures: 1 Errors: 45
Failures: 1

        from testall.rb:22
Errors: 45
./lib/amrita/parser.rb:433:in `parse'(TestFormat): error hapend in :4(<p> can't be in <id>)
==> id="body">body text will be inserted here</p>
</body>

</html>
 (Amrita::HtmlParseError)
        from ../lib/amrita/parser.rb:398:in `parse_text'
        from ./testformat.rb:50:in `test_asisformatter'
        from testall.rb:22
./lib/amrita/parser.rb:433:in `parse'(TestFormat): error hapend in :0(</p> can't be in <__id>)

--
Jim Freeze
If only I had something clever to say for my comment...
~



Wed, 05 Jan 2005 23:20:04 GMT  
 amrita 0.8.1
You need strscan:

See: http://www.loveruby.net/ja/prog/strscan.html

-rich

Quote:
> -----Original Message-----

> Sent: Saturday, July 20, 2002 11:16 AM
> To: ruby-talk ML
> Subject: Re: [ANN] amrita 0.8.1

> Hi:

> I downloaded amrita (stable version) and ran
>  make test_it

> and got several errors. Did I do something wrong or get the
> incorrect version?

> Thanks

> Jim

>  make test_it
> (cd test; ruby -I../lib testall.rb)

E.E..E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E
.E

- Show quoted text -

Quote:
> .E.E.E..E.E.E.F.......................E.....E.........
> Time: 0.654986
> FAILURES!!!
> Test Results:
>  Run: 82/82(158 asserts) Failures: 1 Errors: 45
> Failures: 1
> ./testparser.rb:31:in `test_scanner'(TestHtmlParser):



> (RUNIT::AssertionFailedError)
>         from testall.rb:22
> Errors: 45
> ../lib/amrita/parser.rb:433:in `parse'(TestFormat): error hapend in
:4(<p>
> can't be in <id>)
> ==> id="body">body text will be inserted here</p>
> </body>

> </html>
>  (Amrita::HtmlParseError)
>         from ../lib/amrita/parser.rb:398:in `parse_text'
>         from ./testformat.rb:50:in `test_asisformatter'
>         from testall.rb:22
> ../lib/amrita/parser.rb:433:in `parse'(TestFormat): error hapend in
> :0(</p> can't be in <__id>)

> --
> Jim Freeze
> If only I had something clever to say for my comment...
> ~



Thu, 06 Jan 2005 02:16:49 GMT  
 amrita 0.8.1
Hi,

Anyone can tell me how to use the TkImage class method? Seems it is much
different from the Perl/Tk.
In Perl/Tk there is no "new" method, but according to the
Rdoc,http://www.eng.dmu.ac.uk/~hgs/ruby/ruby-1.6.7-rdocs/,there is a new
method.  And I have tried for severl times,such as
  TkImage.new{type "phoimage"
                        file "xxxx.gif"
                        }
 but still cannot use it to create a image. Thanks.



Thu, 06 Jan 2005 05:29:46 GMT  
 amrita 0.8.1

M>   TkImage.new{type "phoimage"
M>                         file "xxxx.gif"
M>                         }

 Apparently you want a PhotoImage, try

    TkPhotoImage.new { file "xxxx.gif" }

Guy Decoux



Thu, 06 Jan 2005 17:07:07 GMT  
 amrita 0.8.1
Quote:
>Thanks,I know how to create a photoimage, but I don't know how to use

Image.new;can it create a new image?According to the Rdoc, should be
"new(keys=nil)".Thanks again.


Quote:

>M>   TkImage.new{type "phoimage"
>M>                         file "xxxx.gif"
>M>                         }

> Apparently you want a PhotoImage, try

>    TkPhotoImage.new { file "xxxx.gif" }

>Guy Decoux



Thu, 06 Jan 2005 23:13:27 GMT  
 amrita 0.8.1

Quote:

>> Thanks,I know how to create a photoimage, but I don't know how to use

M> Image.new;can it create a new image?According to the Rdoc, should be
M> "new(keys=nil)".Thanks again.

 The best is to do like ruby, i.e. to create a subclass of TkImage to

   class TkPhotoImage < TkImage
      def initialize(*args)

         super
      end
      # etc
   end

 There is only one problem : in tcl/tk it exist *only* 2 types of Image
 defined by tk :
   * 'photo' defined by TkPhotoImage
   * 'bitmap' defined by TkBitmapImage

 This mean that if you want to use an Image, you must fatally use
 TkImagePhoto or TkBitmapImage. TkImage is useless for you except if you
 use an tcl/tk extensions which define its own image type.

Guy Decoux



Thu, 06 Jan 2005 23:29:40 GMT  
 
 [ 33 post ]  Go to page: [1] [2] [3]

 Relevant Pages 

1. amrita question

2. amrita parsing

3. Amrita substitution question

4. Question about Amrita

5. Amrita Question

6. Amrita Question - using a() with nested elements

7. Using amrita for generating static content?

8. amrita/cgikit/iowa/others?

9. amrita-user mailing list

10. Allowing "&nbsp;" within Amrita

11. amrita V0.9.1(first beta release)

12. A completely different Amrita has a Ruby interface

 

 
Powered by phpBB® Forum Software