Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > New HTML Toolkit Idea

Reply
Thread Tools

New HTML Toolkit Idea

 
 
Bill Atkins
Guest
Posts: n/a
 
      04-14-2004
I was thinking today about how much I hate writing scripts to generate
HTML and I sat down and wrote some code. I'm thinking about making a
simple toolkit to generate HTML in an abstract way. Here's my sample
code:

# tests a simple HTML generation toolkit - this is how a working
script ought to work

data = [[1, 2, 3], [4, 5, 6]]

puts RHTk.new do
title "A Test of RHTk - The Ruby HTML ToolKit"
include_css "style/rhtk.css"
body do
header1 "Here's a sample header", :class => 'modern'
table do
data.each do |i|
row do
data[i].each do |d|
column d
end
end
end
end
out "that's all for now"
end
end

The RHTk constructor assembles a string of HTML based on all the code
executed within its block. The output would be neatly tabified, giving
you something like this:

<html>
<head>
<title>
<link rel="stylesheet" href="style/rhtk.css">
</head>
<body>
<h1 class="modern">Here's a sample header.</h1>
<table>
<!-- main table begin -->
<tr>
<td>
1
</td>
<td>
2
</td>
<td>
3
</td>
</tr>
<tr>
<td>
4
</td>
<td>
5
</td>
<td>
6
</td>
</tr>
<!-- main table end -->
that's all for now
</body>
</html>

Is this worth pursuing? Is there something already in existence that
does the same thing? I'd like to hear what everyone's thoughts about
this are.

Bill
 
Reply With Quote
 
 
 
 
Robert Klemme
Guest
Posts: n/a
 
      04-14-2004

"Bill Atkins" <(E-Mail Removed)> schrieb im Newsbeitrag
news:(E-Mail Removed) om...
> Is this worth pursuing? Is there something already in existence that
> does the same thing? I'd like to hear what everyone's thoughts about
> this are.


Class CGI does already HTML generation although IMHO this should be put
into a separate class since HTML generation is not limited to web
application. Dunno though whether someone has factored that code out
already. If not, you could join forces.

Kind regards

robert

 
Reply With Quote
 
 
 
 
gabriele renzi
Guest
Posts: n/a
 
      04-14-2004
il 14 Apr 2004 08:04:29 -0700, http://www.velocityreviews.com/forums/(E-Mail Removed) (Bill Atkins) ha
scritto::

>I was thinking today about how much I hate writing scripts to generate
>HTML and I sat down and wrote some code. I'm thinking about making a
>simple toolkit to generate HTML in an abstract way. Here's my sample
>code:
>
> # tests a simple HTML generation toolkit - this is how a working
>script ought to work



this is *much* like CGI.rb.
Anyway I'd use one of (red|blue)cloth or RDoc to write html in a more
simple way, then tweak the interface a little with a css.


 
Reply With Quote
 
Kaspar Schiess
Guest
Posts: n/a
 
      04-14-2004
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Bill Atkins wrote:

| Is this worth pursuing? Is there something already in existence that
| does the same thing? I'd like to hear what everyone's thoughts about
| this are.

HTML generation in Borges (http://borges.rubyforge.org) works much that
way.

kaspar - code philosopher

- -- stolen off the net --
a dozen dogs bark
outside m[y] jail window
they love to irritate
let us in gruff bang
lo nice quie[t] reappears
once i have my ax
-- a Scrabble poem, using all the tiles, http://www.cheapass.com/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (MingW32)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFAfXrDFifl4CA0ImQRAkOVAJ93fohmT9F/RNLzxkNsMIGD0HUYxQCfVDGd
DP3L0ooTg4gu0YRcmGop9hs=
=3kor
-----END PGP SIGNATURE-----


 
Reply With Quote
 
Ollivier Robert
Guest
Posts: n/a
 
      04-16-2004
In article <(E-Mail Removed) >,
Bill Atkins <(E-Mail Removed)> wrote:
> I was thinking today about how much I hate writing scripts to generate
> HTML and I sat down and wrote some code. I'm thinking about making a
> simple toolkit to generate HTML in an abstract way. Here's my sample
> code:


> puts RHTk.new do
> title "A Test of RHTk - The Ruby HTML ToolKit"
> include_css "style/rhtk.css"
> body do


I know these methods of wrapping HTML tags into classes/objects is "en
vogue" but really you ought to work in a MVC-based system, separating the
code from data and presentation. The code (controller) should instanciate
the data (model) through templates (view).

That way you don't have to change the code to change presentation or your
data. Even if you have to change the code, it will be a _code_ change, not
a presentation one.

Amrita is the way IMNSHO.
--
Ollivier ROBERT -=- EEC/AMI -=- (E-Mail Removed)
Usenet Canal Historique FreeBSD: The Power to Serve!
 
Reply With Quote
 
Kaspar Schiess
Guest
Posts: n/a
 
      04-16-2004
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

| I know these methods of wrapping HTML tags into classes/objects is "en
| vogue" but really you ought to work in a MVC-based system, separating the
| code from data and presentation. The code (controller) should instanciate
| the data (model) through templates (view).

I find that these separations add invariably a lot of complexity to the
system and often are not really used; redesigns are often on all three
sides (m v and c).

So I reverted to making clean html and doing the rest in css. Of course
I can see a lot of projects where that is not an option; Amrita is
definitly a good (=lean) solution to the MVC pattern.

Cocoon shows how complicated one can get...


kaspar - code philosopher

- -- stolen off the net --
I'm inclined to think that caffeine, sugar, fat and alcohol are the four
basic food groups. This means that an Irish coffee is the most
nourishing drink ever made, because it contains all four.
-- Dave Brown
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (MingW32)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFAf7zTFifl4CA0ImQRAoThAKCvokIdTOSTAzP1a+/ZRVU5bdAd/wCfQuX0
9PmHYiJ8OCGa4xfNsNXc5WI=
=22WG
-----END PGP SIGNATURE-----


 
Reply With Quote
 
Ollivier Robert
Guest
Posts: n/a
 
      04-16-2004
In article <(E-Mail Removed)>, Kaspar Schiess <(E-Mail Removed)> wrote:
> I find that these separations add invariably a lot of complexity to the
> system and often are not really used; redesigns are often on all three
> sides (m v and c).


I'd the minimum is to separate HTML from the code and going through
templates. CSS is of course to be used fro the presentation layer.

> So I reverted to making clean html and doing the rest in css. Of course
> I can see a lot of projects where that is not an option; Amrita is
> definitly a good (=lean) solution to the MVC pattern.
>
> Cocoon shows how complicated one can get...

--
Ollivier ROBERT -=- FreeBSD: The Power to Serve! -=- (E-Mail Removed)
Darwin snuadh.freenix.org Kernel Version 7.3.0: Fri Mar 5 14:22:55 PST 2004
 
Reply With Quote
 
Kaspar Schiess
Guest
Posts: n/a
 
      04-16-2004
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

| I'd the minimum is to separate HTML from the code and going through
| templates. CSS is of course to be used fro the presentation layer.

Using the term minimum like that, you have to define what for. If I
write a small web application that needs to display some data, then the
Borges way is good enough. Adding an MVC pattern to that seems overhead
and adding to the complexity of thought more than anything else.

I have helped develop a major CMS system and been trough with seperation
~ of code from presentation. Code and presentation can be thought of
apart, but in real world they have many inherent dependencies.

I just advise people to do things simple while that works, and use the
big cannons on big animals. Did the point of cocoon being the thing to
look at at the other end of the complexity scale get across ?

kaspar - code philosopher

- -- stolen off the net --
Excess on occasion is exhilarating. It prevents moderation from
acquiring the deadening effect of a habit.
~ -- W. Somerset Maugham


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (MingW32)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFAf9cSFifl4CA0ImQRAuJfAJ4kx/XinOYb/m+HDe+YJ16zQTK/aACeJ1FP
nVRLlcmlo7LJSkWKuNrSnOw=
=cehg
-----END PGP SIGNATURE-----



 
Reply With Quote
 
Kaspar Schiess
Guest
Posts: n/a
 
      04-17-2004
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello it's me,

| Would that be typo3?
No, its not. The thing I am talking about is called 'obtree', is not
open source at all and was programmed in c++.

What is interesting is that at some point or another, all these systems
contain a scripting language, in our case ECMA-Script.

| What are your thoughts on using Ruby and/or a Borges-like framework in
some
| future incarnation of a CMS?

I think that is a good idea, as long as you manage a good synthesis
between Application-like design and the Page metaphor that often
underlies CMS systems.

Do you know about Cocoon and Cocoon Flow ?

I have some experience on the field, but I cannot say that it makes me a
positive person to converse with about these issues. I have more often
than not seen CMS systems detourned as application servers where they
should not have been. I think it is unhealthy to stay with one metaphor,
but one should really know about both.

I guess what I am trying to say is that keeping things simple plays an
important part when it comes to .. creating html pages, because that is
what the fuzz is often about. Few people have content-syndication or
multiple output formats implemented. And those who have.. often did it
from scratch.

What kind of system are you thinking about ?

~ kaspar - code philosopher

- -- stolen off the net --
Please help me. When you download files on hacking and the file
extension is "c" how do you use it?
-- antons @ iafrica.com, in alt.hackers.malicious
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (MingW32)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFAgU5nFifl4CA0ImQRAnD3AJ4yRlTVYbpJvjHGkzf2gH ttWtmapACfZzqo
o4tZmK28bk8iksORd76M/L8=
=jgU7
-----END PGP SIGNATURE-----


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: App idea, Any idea on implementation? Matthew_WARREN@bnpparibas.com Python 0 02-05-2008 05:50 PM
App idea, Any idea on implementation? Dr Mephesto Python 3 02-05-2008 06:55 AM
Nested conditional expressions ---- good idea/bad idea? nimmi_srivastav@yahoo.com C Programming 10 02-02-2005 10:51 PM
New HTML Toolkit Bill Atkins Ruby 0 04-14-2004 05:59 PM
Using Localization Toolkit and Html controls Jonas ASP .Net 1 08-19-2003 03:46 PM



Advertisments