Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

tags for embedded ruby

5 views
Skip to first unread message

Dan Allen

unread,
May 6, 2002, 9:03:38 PM5/6/02
to
After reading endless xml books and watching all of these languages
like perl, python and ruby go the way of PHP and make embedding code
within html possible, I don't understand why the standards for xml
processing instructions are not followed. It seems like it could be
endlessly flexible since the language could come up with its own
constructs while still following the recommended standard. This
allows scripts written with embedded code to be valid xml and more
appropriate when having to store the data as xml documents. Examples
would be as follows

<?rb puts "hello world"?> ruby
<?py print "hello word",?> python
<?perl print "hello world"?> perl

Seems to me very straightforward and follows the precendent that PHP
started. In addition to this, it could be extended to include the
sort tags syntax by making

<?rbe ... for expressions
<?rbi ... for ignored code

I wish I could just shout this out for all to hear because it seems so
obvious but no one is going this way. Since we are early in eruby
development, maybe it is not to late to get it to catch on. Thoughts?

Dan Allen

ja...@rubyxml.com

unread,
May 6, 2002, 9:25:58 PM5/6/02
to

> -----Original Message-----
> From: Dan Allen [mailto:bigre...@yahoo.com]
> Subject: tags for embedded ruby

>
> After reading endless xml books and watching all of these languages
> like perl, python and ruby go the way of PHP and make embedding code
> within html possible, I don't understand why the standards for xml
> processing instructions are not followed. It seems like it could be
> endlessly flexible since the language could come up with its own
> constructs while still following the recommended standard. This
> allows scripts written with embedded code to be valid xml and more
> appropriate when having to store the data as xml documents. Examples
> would be as follows
>
> <?rb puts "hello world"?> ruby
> <?py print "hello word",?> python
> <?perl print "hello world"?> perl

Have you seen ruby-tmpl? It uses PIs for template instructions.


James

Sean Chittenden

unread,
May 6, 2002, 9:41:48 PM5/6/02
to

<personal_opinion mixed_in_sarcasm="yes">

I don't think it's too late for this to happen and I've often wondered
about introducing a new directive for Apache so that eRuby processes
<?erb ?> or some such tag. I'll probably start diving into a patch or
two for that in a few weeks and will solicit Shugo for his thoughts on
how to broach the topic.

As for why things are the way they are? You're living with software
that's been written in the wake of ASP (thank you Microsoft) and JSP
(and thank you Sun, I hope your stock continues to do as well as it
has over the last few months. heh, keep it up the world will be a
better place). <% %> was really fashionable when eRuby was first
written... since then XML's become king of the week and eRuby hasn't
accommodated. At the same time, eRuby is a stand alone binary that
gets used outside of mod_ruby, so there's going to have to be a
transition path to an updated syntax. That said, I read about 6mo+
ago that processing instructions (PI's, ex: <?[\w]+ ?>) had fallen out
of favor with the W3C and there was some hint of it being depreciated.
What's the markup to supersede it? ::shrug:: Prince XSL is on the
rise so I'd put my money there. With PHP at its level of popularity,
who knows how that'll factor in. *ML/W3C reminds me of the family of
the ancient Greek gods: there's always something interesting and F-'ed
up happening.

</personal_opinion>

::grin:: -sc

--
Sean Chittenden

Sean Chittenden

unread,
May 6, 2002, 9:41:49 PM5/6/02
to
> > After reading endless xml books and watching all of these languages
> > like perl, python and ruby go the way of PHP and make embedding code
> > within html possible, I don't understand why the standards for xml
> > processing instructions are not followed. It seems like it could be
> > endlessly flexible since the language could come up with its own
> > constructs while still following the recommended standard. This
> > allows scripts written with embedded code to be valid xml and more
> > appropriate when having to store the data as xml documents. Examples
> > would be as follows
> >
> > <?rb puts "hello world"?> ruby
> > <?py print "hello word",?> python
> > <?perl print "hello world"?> perl
>
> Have you seen ruby-tmpl? It uses PIs for template instructions.

And is about to get a rewrite into C here in the not too distant
future... :~) -sc

--
Sean Chittenden

Hal E. Fulton

unread,
May 7, 2002, 12:13:47 AM5/7/02
to
----- Original Message -----
From: "Sean Chittenden" <se...@chittenden.org>
To: "ruby-talk ML" <ruby...@ruby-lang.org>; "Dan Allen"
<bigre...@yahoo.com>
Cc: "ruby-talk ML" <ruby...@ruby-lang.org>
Sent: Monday, May 06, 2002 8:37 PM
Subject: Re: tags for embedded ruby


> ML/W3C reminds me of the family of
> the ancient Greek gods: there's always something interesting and F-'ed
> up happening.

That is the best and funniest analogy I have seen in
a month. Thanks!

Hal Fulton


Tobias Reif

unread,
May 7, 2002, 7:20:46 AM5/7/02
to
Sean Chittenden wrote:

> since then XML's become king of the week


If you go to
http://www.w3.org/TR/html4/
and click the link
"Latest version of HTML:"
http://www.w3.org/TR/html/
, you'll land @ the XHTML^(TM) 1.0 spec.


> What's the markup to supersede it? ::shrug:: Prince XSL is on the
> rise so I'd put my money there.


XSL/XSLFO is not to supersede XHTML. It's for different things.

Tobi

--
http://www.pinkjuice.com/

Tobias Reif

unread,
May 7, 2002, 7:46:46 AM5/7/02
to
Dan Allen wrote:

> After reading endless xml books and watching all of these languages
> like perl, python and ruby go the way of PHP and make embedding code
> within html possible, I don't understand why the standards for xml
> processing instructions are not followed.


You mean in eruby? Months ago, I mailed em, asking for XHTML, but they
replied no, IIRC.

Anyways, for small homecooked stuff, you can use what you want:
from
http://www.pinkjuice.com/howto/RubySVG/examples.xhtml
:
http://www.rubynewbies.com/~tobi/show_source.rb?file=h_time.rb&format=.xhtml

(you may want to change the regex to /.../m), as in the fragment below

Tobi


doc = <<DELIMITER
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>get MIMEtype</title>
</head>
<body>
<form action="mime.rb">
<fieldset style="border:none">
<input type="text" size="40" name="url" maxlength="400"
value="http://" />
<input type="submit" value="get MIME type" />
</fieldset>
</form>
<?ruby '<p>The content-type sent for' ruby?>
<?ruby @url ruby?>
<?ruby 'is <br />' ruby?>
<?ruby $mime_type = get_mime_type @url ruby?>
<?ruby
if $mime_type == 'image/svg+xml'
'<br /> which is the correct MIME type for SVG.'
else
'<br />(if the content is SVG, the MIME type (content-type header)
should be<br />image/svg+xml<br />)</p>'
end
ruby?>
<p>see <a
href="http://www.pinkjuice.com/SVG/mime.xhtml">www.pinkjuice.com/SVG/mime.xhtml</a></p>
<p><img
src="http://www.pinkjuice.com/pics/sgaier_nl_ruby/banner8b.png"
alt="powered by Ruby"/></p>
</body>
</html>
DELIMITER

resolved_doc = doc.gsub /<\?ruby\s+(.*?)\s+ruby\?>/m do
eval $1
end

print "content-type: text/html\n\n"
print resolved_doc

--
http://www.pinkjuice.com/

0 new messages