It is possible if you run the code first through ERB and then through
PHP or vice versa.
How slow it will be depends on your deployment type - i.e. whether do
you run PHP and/or Ruby as CGI, mod_ruby, using mongrel etc.
If mod_php allows you to define a post_request filter, that might
help. Or you could create a subrequest to php, and than process its
output.
I see a maintainability problem here - two languages intermixed.
The easier way would be to separate all the php or ruby stuff to a
separate webservice/subpage, and include its output to the main page.
...and if you want to really inter-mix ruby and php, that would be a
nightmare
as in:
<% 1..2.each do |i| %>
<?php
?>
<% end %>
J.
···
On 7/12/07, Vadim Shevchenko <veejar.net@gmail.com> wrote:
For example I have such html-page:
test.html
<html>
<body>
<%
puts 'hello'
%>
<hr>
<?php
phpinfo();
?>
</body>
</html>
===========
Main web-server script-language is Ruby.
I want to include PHP-code.
I've been thinking about this as well lately.
Since Rails is overkill for a lot of little things, it would be nice if ERb had more ability.
ERb lacks some of the functionality and flexibility of embedded php.
With php you can just include a file, but ERb doesn't let you do that (AFAIK).
John Joyce
···
On Jul 12, 2007, at 9:23 AM, Jano Svitok wrote:
On 7/12/07, Vadim Shevchenko <veejar.net@gmail.com> wrote:
For example I have such html-page:
test.html
<html>
<body>
<%
puts 'hello'
%>
<hr>
<?php
phpinfo();
?>
</body>
</html>
===========
Main web-server script-language is Ruby.
I want to include PHP-code.
Is it posiible?
It is possible if you run the code first through ERB and then through
PHP or vice versa.
How slow it will be depends on your deployment type - i.e. whether do
you run PHP and/or Ruby as CGI, mod_ruby, using mongrel etc.
If mod_php allows you to define a post_request filter, that might
help. Or you could create a subrequest to php, and than process its
output.
I see a maintainability problem here - two languages intermixed.
The easier way would be to separate all the php or ruby stuff to a
separate webservice/subpage, and include its output to the main page.
...and if you want to really inter-mix ruby and php, that would be a
nightmare
as in:
Main web-server script-language is Ruby.
I want to include PHP-code.
Is it posiible?
Try using SSI for the php code.
SSI works super, but I have such problem:
I want to include in html-file some php-code one of counter-systems
written on PHP.
By using SSI, I must write php-code to some php-file and when this php
will be included, php-script don't know about html-file, about first
request uri.
For counter-system it's bad variant.
···
On Jul 12, 2007, at 09:12 , Vadim Shevchenko wrote:
I've been thinking about this as well lately.
Since Rails is overkill for a lot of little things, it would be nice if
ERb had more ability.
ERb lacks some of the functionality and flexibility of embedded php.
With php you can just include a file, but ERb doesn't let you do that
(AFAIK).
Couldn't you just put the Erb inside the html? Like:
<html><body>
<!-- stuff up here -->
<%= Erb.new(IO.read(filename)).result %>
<!-- stuff down here -->
</body></html>
···
--
Travis Warlick
"Programming in Java is like dealing with your mom --
it's kind, forgiving, and gently chastising.
Programming in C++ is like dealing with a disgruntled
girlfriend -- it's cold, unforgiving, and doesn't tell
you what you've done wrong."
It might be possible to use ERb (Ruby) to insert the PHP.
And then have the server first process files with Ruby, then with PHP.
Depends on the server. It's ugly, maybe a little slower, but probably possible.
···
On Jul 30, 2007, at 7:48 AM, Vadim Shevchenko wrote:
Wayne E. Seguin wrote:
On Jul 12, 2007, at 09:12 , Vadim Shevchenko wrote:
===========
Main web-server script-language is Ruby.
I want to include PHP-code.
Is it posiible?
Try using SSI for the php code.
SSI works super, but I have such problem:
I want to include in html-file some php-code one of counter-systems
written on PHP.
By using SSI, I must write php-code to some php-file and when this php
will be included, php-script don't know about html-file, about first
request uri.
For counter-system it's bad variant.
-- Posted via http://www.ruby-forum.com/\.
Let me toy with it a bit and see how much I love/hate it.
JJ
···
On Jul 12, 2007, at 5:46 PM, Travis D Warlick Jr wrote:
John Joyce wrote:
I've been thinking about this as well lately.
Since Rails is overkill for a lot of little things, it would be nice if
ERb had more ability.
ERb lacks some of the functionality and flexibility of embedded php.
With php you can just include a file, but ERb doesn't let you do that
(AFAIK).
Couldn't you just put the Erb inside the html? Like:
<html><body>
<!-- stuff up here -->
<%= Erb.new(IO.read(filename)).result %>
<!-- stuff down here -->
</body></html>
--
Travis Warlick
"Programming in Java is like dealing with your mom --
it's kind, forgiving, and gently chastising.
Programming in C++ is like dealing with a disgruntled
girlfriend -- it's cold, unforgiving, and doesn't tell
you what you've done wrong."
On Jul 30, 12:22 pm, John Joyce <dangerwillrobinsondan...@gmail.com> wrote:
On Jul 30, 2007, at 7:48 AM, Vadim Shevchenko wrote:
> Wayne E. Seguin wrote:
>> On Jul 12, 2007, at 09:12 , Vadim Shevchenko wrote:
>>> ===========
>>> Main web-server script-language is Ruby.
>>> I want to include PHP-code.
>>> Is it posiible?
>> Try using SSI for the php code.
> SSI works super, but I have such problem:
> I want to include in html-file some php-code one of counter-systems
> written on PHP.
> By using SSI, I must write php-code to some php-file and when this php
> will be included, php-script don't know about html-file, about first
> request uri.
> For counter-system it's bad variant.
> --
> Posted viahttp://www.ruby-forum.com/.
It might be possible to use ERb (Ruby) to insert the PHP.
And then have the server first process files with Ruby, then with PHP.
Depends on the server. It's ugly, maybe a little slower, but probably
possible.
On Jul 30, 2007, at 7:48 AM, Vadim Shevchenko wrote:
Try using SSI for the php code.
It might be possible to use ERb (Ruby) to insert the PHP.
And then have the server first process files with Ruby, then with PHP.
Depends on the server. It's ugly, maybe a little slower, but probably
possible.
How can I use ERB for processig PHP-code? ERB parse only Ruby-code. Or
not?
--
Posted via http://www.ruby-forum.com/\.
On Jul 30, 12:22 pm, John Joyce <dangerwillrobinsondan...@gmail.com> > wrote:
>>> I want to include PHP-code.
> request uri.
> For counter-system it's bad variant.
> --
> Posted viahttp://www.ruby-forum.com/.
It might be possible to use ERb (Ruby) to insert the PHP.
And then have the server first process files with Ruby, then with PHP.
Depends on the server. It's ugly, maybe a little slower, but probably
possible.
That's OK I guess, but it's not as graceful as usual Ruby things.
I guess I'm going to look into Camping and those others.
I checked out the Merb site once but it was all RDoc with no solid examples.
CGI is just too ugly, it might as well be Perl for that, I wish DreamHost would run mod_ruby...
I'm just finding that Rails is just way more than what I want or need. Lots of cool stuff in it, but the problem is that there is just so much there. Getting started is easy enough, but things start to grind down to a crawl as you beginning unravelling all the details. It's like any big framework, it's highly productive and useful AFTER you've spent months learning it. There's definitely a learning curve and things start to get pretty complicated pretty quickly.
It's too bad that ERb itself isn't better tutorialized.
···
On Jul 12, 2007, at 4:50 PM, Jeremy Henty wrote:
On 2007-07-12, Phrogz <phrogz@mac.com> wrote:
On Jul 12, 12:43 pm, Jeremy Henty <onepo...@starurchin.org> wrote:
On 2007-07-12, John Joyce <dangerwillrobinsondan...@gmail.com> >>> wrote:
With php you can just include a file, but ERb doesn't let you do
that (AFAIK).
<%= IO.read "yes_it_does.txt" %>
Not quite when you want the included file to have ERB commands in it:
On Jul 31, 2:21 am, Vadim Shevchenko <veejar....@gmail.com> wrote:
jzakiya wrote:
> On Jul 30, 12:22 pm, John Joyce <dangerwillrobinsondan...@gmail.com> > > wrote:
>> >>> I want to include PHP-code.
>> > request uri.
>> > For counter-system it's bad variant.
>> > --
>> > Posted viahttp://www.ruby-forum.com/.
>> It might be possible to use ERb (Ruby) to insert the PHP.
>> And then have the server first process files with Ruby, then with PHP.
>> Depends on the server. It's ugly, maybe a little slower, but probably
>> possible.
>>>
>>>> With php you can just include a file, but ERb doesn't let you do
>>>> that (AFAIK).
>>>
>>> <%= IO.read "yes_it_does.txt" %>
>>
>> Not quite when you want the included file to have ERB commands in it:
>
> Good point!
>
> <%= ERB.new(IO.read("how_about_this_then.erb")).result(binding) %>
>
> Jeremy Henty
>
That's OK I guess, but it's not as graceful as usual Ruby things.
I guess I'm going to look into Camping and those others.
I checked out the Merb site once but it was all RDoc with no solid
examples.
You can of course make it more graceful:
def erb_include(path, b = nil)
b = binding unless b
ERB.new(IO.read(path)).result(b)
end
<%= erb_include("file.erb") %>
It's still a bit icky w/ local vars [But that's part of the reason I
don't like templating like this anyway]
CGI is just too ugly, it might as well be Perl for that, I wish
···
On 7/12/07, John Joyce <dangerwillrobinsondanger@gmail.com> wrote:
On Jul 12, 2007, at 4:50 PM, Jeremy Henty wrote:
> On 2007-07-12, Phrogz <phrogz@mac.com> wrote:
>> On Jul 12, 12:43 pm, Jeremy Henty <onepo...@starurchin.org> wrote:
>>> On 2007-07-12, John Joyce <dangerwillrobinsondan...@gmail.com> > >>> wrote:
DreamHost would run mod_ruby...
I'm just finding that Rails is just way more than what I want or
need. Lots of cool stuff in it, but the problem is that there is just
so much there. Getting started is easy enough, but things start to
grind down to a crawl as you beginning unravelling all the details.
It's like any big framework, it's highly productive and useful AFTER
you've spent months learning it. There's definitely a learning curve
and things start to get pretty complicated pretty quickly.
It's too bad that ERb itself isn't better tutorialized.
There are several forms of "eruby"
Erubis can work for many languages, but I don't know if it can do them all at the same time.
ERb is the Ruby standard library eruby implementation, as far as I know, it does not handle PHP
Erubis seems cool, but the docs are a bit difficult to read.
···
On Jul 31, 2007, at 2:34 PM, jzakiya wrote:
On Jul 31, 2:21 am, Vadim Shevchenko <veejar....@gmail.com> wrote:
jzakiya wrote:
On Jul 30, 12:22 pm, John Joyce <dangerwillrobinsondan...@gmail.com> >>> wrote:
I want to include PHP-code.
request uri.
For counter-system it's bad variant.
--
Posted viahttp://www.ruby-forum.com/.
It might be possible to use ERb (Ruby) to insert the PHP.
And then have the server first process files with Ruby, then with PHP.
Depends on the server. It's ugly, maybe a little slower, but probably
possible.