PHP ERB

P

Patrick May

Hello,

One of the nice things about php is that the '<?>' keys are close to
each other. One of the annoying things about asp and jsp is that '<>'
use one hand, and '%' uses another.

Attached is a patch to erb.rb that allows ?'s as well as %'s in erb
templates:

<% puts "this works" %>
<? puts "as does this" ?>

Let me know if there is anything I can do to make this a better patch.
If you want to play with this, you can grab the patched version of erb
from narf:

http://svn.narf-lib.org/svn/narf/trunk/lib/web/phprb.rb

I renamed the constant to PHPRB, so as not to collide with the standard
lib.

Cheers,

Patrick
 
A

Aredridel

Hello,

One of the nice things about php is that the '<?>' keys are close to
each other. One of the annoying things about asp and jsp is that '<>'
use one hand, and '%' uses another.

Attached is a patch to erb.rb that allows ?'s as well as %'s in erb
templates:

<% puts "this works" %>
<? puts "as does this" ?>

+1 in concept, because XML standards suggest it this way, too. However,
<?ruby is better, following the XML processing-instructions spec.
 
D

Douglas Livingstone

+1 in concept, because XML standards suggest it this way, too. However,
<?ruby is better, following the XML processing-instructions spec.

or just, <?r ?>

(The PHP people say not to use shorttags (<?= $var ?>) too, there was
a zend contest here the 2nd place guy got put down to 6th for that!
And the best prizes were in the top 5 :p )

Douglas
 
L

Luis G. Gómez

<?rb ?> gets my vote

Douglas said:
or just, <?r ?>

(The PHP people say not to use shorttags (<?= $var ?>) too, there was
a zend contest here the 2nd place guy got put down to 6th for that!
And the best prizes were in the top 5 :p )

Douglas
 
S

Stefan Scholl

+1 in concept, because XML standards suggest it this way, too. However,
<?ruby is better, following the XML processing-instructions spec.

Why bother? I don't think something like

<a href="foo/?baz=<?ruby print xyz.poo(42) ?>">

is valid XML either.
 
E

Eric Hodel

--Apple-Mail-9-998547119
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset=US-ASCII; format=flowed

Hello,

One of the nice things about php is that the '<?>' keys are close to
each other. One of the annoying things about asp and jsp is that '<>'
use one hand, and '%' uses another.

That's because you're using the wrong keyboard. Switch to dvorak
layout. ;)

Its even easier than <?, because you're not using your pinky to hit one
of the keys.

(No, really this kinda stuff is useful. :)

--
Eric Hodel - (e-mail address removed) - http://segment7.net
FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04

--Apple-Mail-9-998547119
content-type: application/pgp-signature; x-mac-type=70674453;
name=PGP.sig
content-description: This is a digitally signed message part
content-disposition: inline; filename=PGP.sig
content-transfer-encoding: 7bit

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (Darwin)

iD8DBQFB7FTyMypVHHlsnwQRAiT6AJ9+4yv3WWCuYgdbBnpflkIdPxgAnQCg3G+E
MJDEJwFhZVTGmWUdC+Kf5Ag=
=v3k/
-----END PGP SIGNATURE-----

--Apple-Mail-9-998547119--
 
G

George Moschovitis

Why bother? I don't think something like
<a href="foo/?baz=<?ruby print xyz.poo(42) ?>">
is valid XML either.

but,

<a href="foo/?baz=#{xyz.poo(42)}">...</a>
as used in Nitro is valid xml :)

-G.
 
S

Stefan Scholl

but,

<a href="foo/?baz=#{xyz.poo(42)}">...</a>
as used in Nitro is valid xml :)

<a href="foo/?baz=23" <?ruby if xyz.poo(42) ?> target="moep"
<?ruby else ?> title="Example" <?ruby end ?>>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,164
Messages
2,570,898
Members
47,440
Latest member
YoungBorel

Latest Threads

Top